diff --git a/certificates/index.php b/certificates/index.php index 26f450ed78..bbe4b1091c 100755 --- a/certificates/index.php +++ b/certificates/index.php @@ -5,12 +5,7 @@ * @package chamilo.certificate */ -/** - * Initialization - */ - require_once '../main/inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH).'certificate.lib.php'; $action = isset($_GET['action']) ? $_GET['action'] : null; @@ -42,7 +37,6 @@ switch ($action) { $pageFormat = $pdfParams['orientation'] == 'landscape' ? 'A4-L' : 'A4'; $userInfo = api_get_user_info($certificate->user_id); - $pdfName = replace_dangerous_char(get_lang('Certificate') . ' ' . $userInfo['username']); $pdf = new PDF($pageFormat, $pdfParams['orientation'], $pdfParams); diff --git a/composer.json b/composer.json index 88940e59e5..0ff1d56d4e 100755 --- a/composer.json +++ b/composer.json @@ -48,12 +48,17 @@ "jbroadway/urlify": "1.0.3-stable", "monolog/monolog": "~1.0", "doctrine/orm": "~2.2,>=2.2.3,<2.5", + "doctrine/migrations": "1.0.*@dev", "symfony/doctrine-bridge": "2.6.4", "symfony/validator": "2.6.4", "gedmo/doctrine-extensions": "~2.3", "sonata-project/user-bundle": "~2.2", - "fxp/composer-asset-plugin": "~1.0", + "ramsey/array_column": "~1.1", + "patchwork/utf8": "~1.2", + "ddeboer/data-import": "@stable", + "phpoffice/phpexcel": "~1.8", "webit/eval-math": "dev-master", + "fxp/composer-asset-plugin": "~1.0", "bower-asset/bootstrap": "3.3.*", "bower-asset/fontawesome": "4.3.*", "bower-asset/moment": "2.9", @@ -65,8 +70,7 @@ "bower-asset/mediaelement": "2.16.*", "bower-asset/modernizr": "2.8.*", "bower-asset/jqueryui-timepicker-addon": "1.5.*", - "ramsey/array_column": "~1.1", - "bower-asset/imageMap-resizer": "0.5.3" + "bower-asset/imageMap-resizer": "0.5.3" }, "require-dev": { "behat/behat": "2.5.*@stable", diff --git a/documentation/changelog.html b/documentation/changelog.html index 4c24e9ce0b..a1b06de85f 100755 --- a/documentation/changelog.html +++ b/documentation/changelog.html @@ -59,7 +59,11 @@

Stylesheets and theming

Web services

Removals

- +

Chamilo 1.9.10.2 - Sipán, 19th of March, 2015

Release notes - summary

diff --git a/index.php b/index.php index 6864ae0a68..f7bca34ea7 100755 --- a/index.php +++ b/index.php @@ -13,7 +13,6 @@ define('CHAMILO_HOMEPAGE', true); $cidReset = true; require_once 'main/inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH).'userportal.lib.php'; require_once 'main/chat/chat_functions.lib.php'; // The section (for the tabs). @@ -101,11 +100,6 @@ if (!empty($_POST['submitAuth'])) { Database::free_result($result_last_login); //Event::event_login(); - if (api_is_platform_admin()) { - // decode all open event informations and fill the track_c_* tables - include api_get_path(LIBRARY_PATH).'stats.lib.inc.php'; - decodeOpenInfos(); - } } // End login -- if ($_POST['submitAuth']) } else { diff --git a/main/admin/access_url_add_usergroup_to_url.php b/main/admin/access_url_add_usergroup_to_url.php index 0e7daa0d1c..2da1beed2e 100755 --- a/main/admin/access_url_add_usergroup_to_url.php +++ b/main/admin/access_url_add_usergroup_to_url.php @@ -24,10 +24,10 @@ $firstLetterUserGroup = null; $courses = array(); $url_list = array(); -$tbl_access_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); -$tbl_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); -$tbl_user = Database :: get_main_table(TABLE_MAIN_USER); -$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE); +$tbl_access_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); +$tbl_access_url = Database:: get_main_table(TABLE_MAIN_ACCESS_URL); +$tbl_user = Database:: get_main_table(TABLE_MAIN_USER); +$tbl_course = Database:: get_main_table(TABLE_MAIN_COURSE); $tool_name = get_lang('AddUserGroupToURL'); $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); diff --git a/main/admin/access_url_check_user_session.php b/main/admin/access_url_check_user_session.php index 55a28ed5d6..cf627677d7 100755 --- a/main/admin/access_url_check_user_session.php +++ b/main/admin/access_url_check_user_session.php @@ -21,9 +21,7 @@ $interbreadcrumb[]=array('url' => 'session_list.php','name' => get_lang('Session // Database Table Definitions $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); - $table_access_url_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); - $url_id = api_get_current_access_url_id(); $action = $_GET['action']; @@ -72,9 +70,10 @@ foreach($session_list as $session_item) { $sql = "SELECT u.user_id, lastname, firstname, username, access_url_id FROM $tbl_user u INNER JOIN $tbl_session_rel_user su - ON u.user_id = su.id_user AND su.relation_type<>".SESSION_RELATION_TYPE_RRHH." - LEFT OUTER JOIN $table_access_url_user uu ON (uu.user_id = u.user_id) - WHERE su.id_session = $session_id AND $access_where + ON u.user_id = su.user_id AND su.relation_type<>".SESSION_RELATION_TYPE_RRHH." + LEFT OUTER JOIN $table_access_url_user uu + ON (uu.user_id = u.user_id) + WHERE su.session_id = $session_id AND $access_where $order_clause"; $result = Database::query($sql); diff --git a/main/admin/access_url_edit_courses_to_url.php b/main/admin/access_url_edit_courses_to_url.php index cd6d2ff61b..02f3ebc8f9 100755 --- a/main/admin/access_url_edit_courses_to_url.php +++ b/main/admin/access_url_edit_courses_to_url.php @@ -83,17 +83,17 @@ $UserList = $SessionList = array(); $users = $sessions = array(); if (isset($_POST['form_sent']) && $_POST['form_sent']) { - $form_sent=$_POST['form_sent']; - $course_list=$_POST['course_list']; + $form_sent = $_POST['form_sent']; + $course_list = $_POST['course_list']; if (!is_array($course_list)) { - $course_list=array(); + $course_list = array(); } if ($form_sent == 1) { if ($access_url_id==0) { header('Location: access_url_edit_users_to_url.php?action=show_message&message='.get_lang('SelectURL')); - } elseif(is_array($course_list) ) { + } elseif (is_array($course_list)) { UrlManager::update_urls_rel_course($course_list, $access_url_id); header('Location: access_urls.php?action=show_message&message='.get_lang('CoursesWereEdited')); } @@ -115,16 +115,16 @@ $no_course_list = $course_list = array(); $ajax_search = $add_type == 'unique' ? true : false; if($ajax_search) { - $courses=UrlManager::get_url_rel_course_data($access_url_id); - foreach($courses as $course) { - $course_list[$course['course_code']] = $course ; + $courses = UrlManager::get_url_rel_course_data($access_url_id); + foreach ($courses as $course) { + $course_list[$course['c_id']] = $course; } } else { - $courses=UrlManager::get_url_rel_course_data(); + $courses = UrlManager::get_url_rel_course_data(); - foreach($courses as $course) { - if($course['access_url_id'] == $access_url_id) { - $course_list[$course['course_code']] = $course ; + foreach ($courses as $course) { + if ($course['access_url_id'] == $access_url_id) { + $course_list[$course['c_id']] = $course; } } @@ -132,12 +132,13 @@ if($ajax_search) { $sql="SELECT code, title FROM $tbl_course u ORDER BY title, code"; - $result=Database::query($sql); - $courses=Database::store_result($result); + $result = Database::query($sql); + $courses = Database::store_result($result); $course_list_leys = array_keys($course_list); - foreach($courses as $course) { - if (!in_array($course['code'],$course_list_leys)) - $no_course_list[$course['code']] = $course ; + foreach ($courses as $course) { + if (!in_array($course['id'], $course_list_leys)) { + $no_course_list[$course['id']] = $course; + } } } diff --git a/main/admin/access_url_edit_usergroup_to_url.php b/main/admin/access_url_edit_usergroup_to_url.php index 93f4622215..5c6e12abdd 100755 --- a/main/admin/access_url_edit_usergroup_to_url.php +++ b/main/admin/access_url_edit_usergroup_to_url.php @@ -317,7 +317,6 @@ function loadUsersInSelect(select){ else // XMLHttpRequest non supporté par le navigateur alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); - //xhr_object.open("GET", "loadUsersInSelect.ajax.php?id_session=&letter="+select.options[select.selectedIndex].text, false); xhr_object.open("POST", "loadUsersInSelect.ajax.php"); xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); nosessionUsers = makepost(document.getElementById('origin_users')); diff --git a/main/admin/add_courses_to_session.php b/main/admin/add_courses_to_session.php index b7324f3307..fd4026f0e3 100755 --- a/main/admin/add_courses_to_session.php +++ b/main/admin/add_courses_to_session.php @@ -115,24 +115,25 @@ $ajax_search = $add_type == 'unique' ? true : false; $nosessionCourses = $sessionCourses = array(); if ($ajax_search) { - $sql="SELECT code, title, visual_code, id_session + $sql="SELECT course.id, code, title, visual_code, session_id FROM $tbl_course course INNER JOIN $tbl_session_rel_course session_rel_course - ON course.code = session_rel_course.course_code - AND session_rel_course.id_session = ".intval($sessionId)." + ON + course.id = session_rel_course.c_id AND + session_rel_course.session_id = ".intval($sessionId)." ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title"; if (api_is_multiple_url_enabled()) { - $tbl_course_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); + $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 + $sql="SELECT course.id, code, title, visual_code, session_id FROM $tbl_course course INNER JOIN $tbl_session_rel_course session_rel_course - ON course.code = session_rel_course.course_code - AND session_rel_course.id_session = ".intval($sessionId)." - INNER JOIN $tbl_course_rel_access_url url_course ON (url_course.course_code=course.code) - WHERE access_url_id = $access_url_id + ON course.id = session_rel_course.c_id + AND session_rel_course.session_id = ".intval($sessionId)." + INNER JOIN $tbl_course_rel_access_url url_course ON (url_course.c_id = course.id) + WHERE access_url_id = $access_url_id ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title"; } } @@ -141,26 +142,29 @@ if ($ajax_search) { $Courses = Database::store_result($result); foreach ($Courses as $course) { - $sessionCourses[$course['code']] = $course ; + $sessionCourses[$course['id']] = $course ; } } else { - $sql = "SELECT code, title, visual_code, id_session + $sql = "SELECT course.id, code, title, visual_code, session_id FROM $tbl_course course LEFT JOIN $tbl_session_rel_course session_rel_course - ON course.code = session_rel_course.course_code - AND session_rel_course.id_session = ".intval($sessionId)." + ON + course.id = session_rel_course.c_id AND + session_rel_course.session_id = ".intval($sessionId)." ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title"; if (api_is_multiple_url_enabled()) { - $tbl_course_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); + $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 + $sql="SELECT course.id, code, title, visual_code, session_id FROM $tbl_course course LEFT JOIN $tbl_session_rel_course session_rel_course - ON course.code = session_rel_course.course_code - AND session_rel_course.id_session = ".intval($sessionId)." - INNER JOIN $tbl_course_rel_access_url url_course ON (url_course.course_code=course.code) + ON + course.id = session_rel_course.c_id AND + session_rel_course.session_id = ".intval($sessionId)." + INNER JOIN $tbl_course_rel_access_url url_course + ON (url_course.c_id = course.id) WHERE access_url_id = $access_url_id ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title"; } @@ -168,13 +172,14 @@ if ($ajax_search) { $result = Database::query($sql); $Courses = Database::store_result($result); foreach ($Courses as $course) { - if ($course['id_session'] == $sessionId) { - $sessionCourses[$course['code']] = $course ; + if ($course['session_id'] == $sessionId) { + $sessionCourses[$course['id']] = $course ; } else { - $nosessionCourses[$course['code']] = $course ; + $nosessionCourses[$course['id']] = $course ; } } } + unset($Courses); ?>
> @@ -198,15 +203,13 @@ unset($Courses); } else { ?>
- + + - + +
- &letter="+select.options[select.selectedIndex].text, false); xhr_object.open("POST", "loadUsersInSelect.ajax.php"); xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); nosessionUsers = makepost(document.getElementById('session_not_in_promotion')); diff --git a/main/admin/add_students_to_session.php b/main/admin/add_students_to_session.php index 52d6df240f..3e6fbd707c 100755 --- a/main/admin/add_students_to_session.php +++ b/main/admin/add_students_to_session.php @@ -154,7 +154,6 @@ echo Display::input('hidden', 'form_sent', '1'); else // XMLHttpRequest non supporté par le navigateur alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); - //xhr_object.open("GET", "loadUsersInSelect.ajax.php?id_session=&letter="+select.options[select.selectedIndex].text, false); xhr_object.open("POST", "loadUsersInSelect.ajax.php"); xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); nosessionUsers = makepost(document.getElementById('session_not_in_promotion')); diff --git a/main/admin/add_teachers_to_session.php b/main/admin/add_teachers_to_session.php index 204e9c58f1..814b41d6eb 100755 --- a/main/admin/add_teachers_to_session.php +++ b/main/admin/add_teachers_to_session.php @@ -158,7 +158,6 @@ echo Display::input('hidden', 'form_sent', '1'); else // XMLHttpRequest non supporté par le navigateur alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); - //xhr_object.open("GET", "loadUsersInSelect.ajax.php?id_session=&letter="+select.options[select.selectedIndex].text, false); xhr_object.open("POST", "loadUsersInSelect.ajax.php"); xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); nosessionUsers = makepost(document.getElementById('session_not_in_promotion')); @@ -170,7 +169,6 @@ echo Display::input('hidden', 'form_sent', '1'); xhr_object.onreadystatechange = function() { if(xhr_object.readyState == 4) { document.getElementById('content_source').innerHTML = result = xhr_object.responseText; - //alert(xhr_object.responseText); } } } diff --git a/main/admin/add_users_to_session.php b/main/admin/add_users_to_session.php index 622dabb495..6044774626 100755 --- a/main/admin/add_users_to_session.php +++ b/main/admin/add_users_to_session.php @@ -82,6 +82,7 @@ function search_users($needle, $type) $needle = Database::escape_string($needle); $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; $showOfficialCode = false; + global $_configuration; if (isset($_configuration['order_user_list_by_official_code']) && $_configuration['order_user_list_by_official_code'] @@ -101,8 +102,8 @@ function search_users($needle, $type) if (!empty($id_session)) { $id_session = intval($id_session); // check id_user from session_rel_user table - $sql = 'SELECT id_user FROM '.$tbl_session_rel_user.' - WHERE id_session ="'.$id_session.'" AND relation_type<>'.SESSION_RELATION_TYPE_RRHH.' '; + $sql = 'SELECT user_id FROM '.$tbl_session_rel_user.' + WHERE session_id = "'.$id_session.'" AND relation_type<>'.SESSION_RELATION_TYPE_RRHH.' '; $res = Database::query($sql); $user_ids = array(); if (Database::num_rows($res) > 0) { @@ -114,6 +115,7 @@ function search_users($needle, $type) $cond_user_id = ' AND user.user_id NOT IN('.implode(",",$user_ids).')'; } } + switch ($type) { case 'single': // search users where username or firstname or lastname begins likes $needle @@ -142,9 +144,9 @@ function search_users($needle, $type) case 'any_session': $sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname, official_code FROM '.$tbl_user.' user - LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.id_user = user.user_id) + LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.user_id = user.user_id) WHERE - s.id_user IS null AND + s.user_id IS NULL AND user.status<>'.DRH.' AND user.status<>6 '.$cond_user_id. $order_clause; @@ -159,7 +161,8 @@ function search_users($needle, $type) case 'single': $sql = 'SELECT user.user_id, username, lastname, firstname, official_code FROM '.$tbl_user.' user - INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id) + INNER JOIN '.$tbl_user_rel_access_url.' url_user + ON (url_user.user_id = user.user_id) WHERE access_url_id = '.$access_url_id.' AND ( @@ -185,11 +188,13 @@ function search_users($needle, $type) case 'any_session' : $sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname, official_code FROM '.$tbl_user.' user - LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.id_user = user.user_id) - INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id) + LEFT OUTER JOIN '.$tbl_session_rel_user.' s + ON (s.user_id = user.user_id) + INNER JOIN '.$tbl_user_rel_access_url.' url_user + ON (url_user.user_id=user.user_id) WHERE access_url_id = '.$access_url_id.' AND - s.id_user IS null AND + s.user_id IS null AND user.status<>'.DRH.' AND user.status<>6 '.$cond_user_id. $order_clause; @@ -292,13 +297,13 @@ $sessions = array(); $noPHP_SELF = true; if (isset($_POST['form_sent']) && $_POST['form_sent']) { - $form_sent = $_POST['form_sent']; - $firstLetterUser = $_POST['firstLetterUser']; - $firstLetterSession = $_POST['firstLetterSession']; - $UserList = $_POST['sessionUsersList']; + $form_sent = $_POST['form_sent']; + $firstLetterUser = isset($_POST['firstLetterUser']) ? $_POST['firstLetterUser'] : ''; + $firstLetterSession = isset($_POST['firstLetterSession']) ? $_POST['firstLetterSession'] : ''; + $UserList = $_POST['sessionUsersList']; if (!is_array($UserList)) { - $UserList=array(); + $UserList = array(); } if ($form_sent == 1) { @@ -328,12 +333,12 @@ if (isset($_configuration['order_user_list_by_official_code']) && } if ($ajax_search) { - $sql = "SELECT user_id, lastname, firstname, username, id_session, official_code + $sql = "SELECT u.user_id, lastname, firstname, username, session_id, official_code FROM $tbl_user u INNER JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND + ON $tbl_session_rel_user.user_id = u.user_id AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." - AND $tbl_session_rel_user.id_session = ".intval($id_session)." + AND $tbl_session_rel_user.session_id = ".intval($id_session)." WHERE u.status<>".DRH." AND u.status<>6 $order_clause"; @@ -341,12 +346,12 @@ if ($ajax_search) { $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { - $sql="SELECT u.user_id, lastname, firstname, username, id_session, official_code + $sql="SELECT u.user_id, lastname, firstname, username, session_id, official_code FROM $tbl_user u INNER JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND + ON $tbl_session_rel_user.user_id = u.user_id AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." - AND $tbl_session_rel_user.id_session = ".intval($id_session)." + AND $tbl_session_rel_user.session_id = ".intval($id_session)." INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id) WHERE access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6 $order_clause"; @@ -366,14 +371,14 @@ if ($ajax_search) { if ($sessionUser['status_in_session'] != 0) { continue; } - + if (!array_key_exists($sessionUser['user_id'], $sessionUsersList)) { continue; } - if ($sessionUser['count'] != $countSessionCoursesList) { + /*if ($sessionUser['count'] != $countSessionCoursesList) { unset($sessionUsersList[$sessionUser['user_id']]); - } + }*/ } unset($users); //clean to free memory @@ -427,21 +432,20 @@ if ($ajax_search) { $order_clause = " AND u.creator_id = " . api_get_user_id() . $order_clause; } if ($use_extra_fields) { - $sql = "SELECT user_id, lastname, firstname, username, id_session, official_code + $sql = "SELECT user_id, lastname, firstname, username, session_id, official_code FROM $tbl_user u LEFT JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND - $tbl_session_rel_user.id_session = '$id_session' AND + ON $tbl_session_rel_user.user_id = u.user_id AND + $tbl_session_rel_user.session_id = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." $where_filter AND u.status<>".DRH." AND u.status<>6 $order_clause"; - } else { - $sql = "SELECT user_id, lastname, firstname, username, id_session, official_code + $sql = "SELECT user_id, lastname, firstname, username, session_id, official_code FROM $tbl_user u LEFT JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND - $tbl_session_rel_user.id_session = '$id_session' AND + ON $tbl_session_rel_user.user_id = u.user_id AND + $tbl_session_rel_user.session_id = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." WHERE u.status<>".DRH." AND u.status<>6 $order_clause"; @@ -450,13 +454,14 @@ if ($ajax_search) { $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { - $sql = "SELECT u.user_id, lastname, firstname, username, id_session, official_code + $sql = "SELECT u.user_id, lastname, firstname, username, session_id, official_code FROM $tbl_user u LEFT JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND - $tbl_session_rel_user.id_session = '$id_session' AND + ON $tbl_session_rel_user.user_id = u.user_id AND + $tbl_session_rel_user.session_id = '$id_session' AND $tbl_session_rel_user.relation_type <> ".SESSION_RELATION_TYPE_RRHH." - INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id) + INNER JOIN $tbl_user_rel_access_url url_user + ON (url_user.user_id = u.user_id) WHERE access_url_id = $access_url_id $where_filter AND u.status<>".DRH." AND u.status<>6 $order_clause"; } @@ -478,11 +483,11 @@ if ($ajax_search) { unset($users); //clean to free memory //filling the correct users in list - $sql="SELECT user_id, lastname, firstname, username, id_session, official_code + $sql="SELECT user_id, lastname, firstname, username, session_id, official_code FROM $tbl_user u LEFT JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND - $tbl_session_rel_user.id_session = '$id_session' AND + ON $tbl_session_rel_user.user_id = u.user_id AND + $tbl_session_rel_user.session_id = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." WHERE u.status<>".DRH." AND u.status<>6 $order_clause"; @@ -490,17 +495,18 @@ if ($ajax_search) { $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { - $sql="SELECT u.user_id, lastname, firstname, username, id_session, official_code - FROM $tbl_user u - LEFT JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND - $tbl_session_rel_user.id_session = '$id_session' AND - $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." - INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id) - WHERE access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6 - $order_clause"; + $sql = "SELECT u.user_id, lastname, firstname, username, session_id, official_code + FROM $tbl_user u + LEFT JOIN $tbl_session_rel_user + ON $tbl_session_rel_user.user_id = u.user_id AND + $tbl_session_rel_user.session_id = '$id_session' AND + $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." + INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id) + WHERE access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6 + $order_clause"; } } + $result = Database::query($sql); $users = Database::store_result($result,'ASSOC'); foreach ($users as $uid => $user) { diff --git a/main/admin/add_users_to_usergroup.php b/main/admin/add_users_to_usergroup.php index b337a2ed31..ec55dfab99 100755 --- a/main/admin/add_users_to_usergroup.php +++ b/main/admin/add_users_to_usergroup.php @@ -132,7 +132,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'export') { $data[] = array($user['username'], $groupInfo['name']); } $filename = 'export_user_class_' . api_get_local_time(); - Export::export_table_csv($data, $filename); + Export::arrayToCsv($data, $filename); exit; } } diff --git a/main/admin/career_dashboard.php b/main/admin/career_dashboard.php index 94b2681651..c5a9280c04 100755 --- a/main/admin/career_dashboard.php +++ b/main/admin/career_dashboard.php @@ -1,12 +1,11 @@ 'index.php','name' => get_lang('PlatformAdmin')); $interbreadcrumb[]=array('url' => 'career_dashboard.php','name' => get_lang('CareersAndPromotions')); -Display :: display_header($nameTools); +Display :: display_header(null); $form = new FormValidator('filter_form','GET', api_get_self()); diff --git a/main/admin/class_import.php b/main/admin/class_import.php index fc607bc83b..17ebb4626a 100755 --- a/main/admin/class_import.php +++ b/main/admin/class_import.php @@ -78,7 +78,7 @@ $form->addElement('file', 'import_file', get_lang('ImportCSVFileLocation')); $form->addButtonImport(get_lang('Import')); if ($form->validate()) { - $classes = Import::csv_to_array($_FILES['import_file']['tmp_name']); + $classes = Import::csvToArray($_FILES['import_file']['tmp_name']); $errors = validate_data($classes); if (count($errors) == 0) { $number_of_added_classes = save_data($classes); diff --git a/main/admin/class_user_import.php b/main/admin/class_user_import.php index 3074ee2b08..f28bb54488 100755 --- a/main/admin/class_user_import.php +++ b/main/admin/class_user_import.php @@ -127,7 +127,7 @@ function save_data($users_classes) { * @return array All course-information read from the file */ function parse_csv_data($file) { - $courses = Import::csv_to_array($file); + $courses = Import::csvToArray($file); return $courses; } diff --git a/main/admin/configure_inscription.php b/main/admin/configure_inscription.php index 7cc36bbbb2..8bac4e087e 100755 --- a/main/admin/configure_inscription.php +++ b/main/admin/configure_inscription.php @@ -11,7 +11,7 @@ require_once '../inc/global.inc.php'; api_protect_admin_script(); // Load terms & conditions from the current lang -if (get_setting('allow_terms_conditions') == 'true') { +if (api_get_setting('allow_terms_conditions') == 'true') { $get = array_keys($_GET); if (isset($get)) { if ($get[0] == 'legal') { @@ -59,7 +59,7 @@ if (!empty($_SESSION['user_language_choice'])) { } elseif (!empty($_SESSION['_user']['language'])) { $lang = $_SESSION['_user']['language']; } else { - $lang = get_setting('platformLanguage'); + $lang = api_get_setting('platformLanguage'); } // ----- Ensuring availability of main files in the corresponding language ----- @@ -109,7 +109,7 @@ if (!empty($homep_new)) { } if (!empty($action)) { - if ($_POST['formSent']) { + if (isset($_POST['formSent'])) { switch ($action) { case 'edit_top': // Filter @@ -159,12 +159,12 @@ echo Display::page_header($tool_name); // The following security condition has been removed, because it makes no sense here. See Bug #1846. //// Forbidden to self-register -//if (get_setting('allow_registration') == 'false') { +//if (api_get_setting('allow_registration') == 'false') { // api_not_allowed(); //} //api_display_tool_title($tool_name); -if (get_setting('allow_registration') == 'approval') { +if (api_get_setting('allow_registration') == 'approval') { Display::display_normal_message(get_lang('YourAccountHasToBeApproved')); } //if openid was not found @@ -173,7 +173,7 @@ if (!empty($_GET['openid_msg']) && $_GET['openid_msg'] == 'idnotfound') { } $form = new FormValidator('registration'); -if (get_setting('allow_terms_conditions') == 'true') { +if (api_get_setting('allow_terms_conditions') == 'true') { $display_all_form = !isset($_SESSION['update_term_and_condition']['user_id']); } else { $display_all_form = true; @@ -229,12 +229,12 @@ if ($display_all_form) { } // LANGUAGE - if (get_setting('registration', 'language') == 'true') { + if (api_get_setting('registration', 'language') == 'true') { $form->addElement('select_language', 'language', get_lang('Language'), '', array('disabled' => 'disabled')); } // STUDENT/TEACHER - if (get_setting('allow_registration_as_teacher') != 'false') { + if (api_get_setting('allow_registration_as_teacher') != 'false') { $form->addElement('radio', 'status', get_lang('Status'), get_lang('RegStudent'), STUDENT, array('disabled' => 'disabled')); $form->addElement('radio', 'status', null, get_lang('RegAdmin'), COURSEMANAGER, array('disabled' => 'disabled')); } @@ -271,7 +271,7 @@ if ($display_all_form) { } // Terms and conditions -if (get_setting('allow_terms_conditions') == 'true') { +if (api_get_setting('allow_terms_conditions') == 'true') { $language = api_get_interface_language(); $language = api_get_language_id($language); $term_preview = LegalManager::get_last_condition($language); diff --git a/main/admin/course_add.php b/main/admin/course_add.php index ca02ca6ce0..d9076a3f87 100755 --- a/main/admin/course_add.php +++ b/main/admin/course_add.php @@ -40,18 +40,24 @@ $form = new FormValidator('update_course'); $form->addElement('header', $tool_name); // Title -$form->addText('title', get_lang('Title'), true, array ('class' => 'span6')); +$form->addText('title', get_lang('Title'), true); $form->applyFilter('title', 'html_filter'); $form->applyFilter('title', 'trim'); // Code -$form->addText('visual_code', array(get_lang('CourseCode'), get_lang('OnlyLettersAndNumbers')) , false, array('class' => 'span3', 'maxlength' => CourseManager::MAX_COURSE_LENGTH_CODE)); +$form->addText('visual_code', array(get_lang('CourseCode'), get_lang('OnlyLettersAndNumbers')) , false, array('maxlength' => CourseManager::MAX_COURSE_LENGTH_CODE)); $form->applyFilter('visual_code', 'api_strtoupper'); $form->applyFilter('visual_code', 'html_filter'); $form->addRule('visual_code', get_lang('Max'), 'maxlength', CourseManager::MAX_COURSE_LENGTH_CODE); -$form->addElement('select', 'course_teachers', get_lang('CourseTeachers'), $teachers, ' id="course_teachers" class="chzn-select" style="width:350px" multiple="multiple" '); +$form->addElement( + 'select', + 'course_teachers', + get_lang('CourseTeachers'), + $teachers, + ' id="course_teachers" class="chzn-select" style="width:350px" multiple="multiple" ' +); $form->applyFilter('course_teachers', 'html_filter'); // Category code @@ -123,33 +129,31 @@ $form->add_progress_bar(); $form->addButtonCreate(get_lang('CreateCourse')); // Set some default values. -$values['course_language'] = api_get_setting('platformLanguage'); -$values['disk_quota'] = round(api_get_setting('default_document_quotum')/1024/1024, 1); +$values['course_language'] = api_get_setting('platformLanguage'); +$values['disk_quota'] = round(api_get_setting('default_document_quotum')/1024/1024, 1); $default_course_visibility = api_get_setting('courses_default_creation_visibility'); if (isset($default_course_visibility)) { - $values['visibility'] = api_get_setting('courses_default_creation_visibility'); + $values['visibility'] = api_get_setting('courses_default_creation_visibility'); } else { - $values['visibility'] = COURSE_VISIBILITY_OPEN_PLATFORM; + $values['visibility'] = COURSE_VISIBILITY_OPEN_PLATFORM; } -$values['subscribe'] = 1; -$values['unsubscribe'] = 0; +$values['subscribe'] = 1; +$values['unsubscribe'] = 0; +$values['course_teachers'] = array(api_get_user_id()); $form->setDefaults($values); // Validate the form if ($form->validate()) { - $course = $form->exportValues(); - $teacher_id = $course['tutor_id']; - $course_teachers = $course['course_teachers']; + $course = $form->exportValues(); + $course_teachers = isset($course['course_teachers']) ? $course['course_teachers'] : null; $course['disk_quota'] = $course['disk_quota']*1024*1024; - - $course['exemplary_content'] = empty($course['exemplary_content']) ? false : true; - $course['teachers'] = $course_teachers; - $course['user_id'] = $teacher_id; - $course['wanted_code'] = $course['visual_code']; + $course['exemplary_content'] = empty($course['exemplary_content']) ? false : true; + $course['teachers'] = $course_teachers; + $course['wanted_code'] = $course['visual_code']; $course['gradebook_model_id'] = isset($course['gradebook_model_id']) ? $course['gradebook_model_id'] : null; // Fixing category code $course['course_category'] = $course['category_code']; diff --git a/main/admin/course_edit.php b/main/admin/course_edit.php index c322e089b0..b7532b79ad 100755 --- a/main/admin/course_edit.php +++ b/main/admin/course_edit.php @@ -34,6 +34,7 @@ $interbreadcrumb[] = array("url" => "course_list.php", "name" => get_lang('Cours // Get all course categories $table_user = Database :: get_main_table(TABLE_MAIN_USER); $course_code = $courseInfo['code']; +$courseId = $courseInfo['real_id']; // Get course teachers $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); @@ -43,7 +44,7 @@ $sql = "SELECT user.user_id,lastname,firstname WHERE course_user.status='1' AND course_user.user_id=user.user_id AND - course_user.course_code='" . $course_code . "'" . + course_user.c_id ='" . $courseId . "'" . $order_clause; $res = Database::query($sql); $course_teachers = array(); @@ -122,11 +123,11 @@ if (array_key_exists('add_teachers_to_sessions_courses', $courseInfo)) { $form->addElement('checkbox', 'add_teachers_to_sessions_courses', null, get_lang('TeachersWillBeAddedAsCoachInAllCourseSessions')); } -$coursesInSession = SessionManager::get_session_by_course($courseInfo['code']); +$coursesInSession = SessionManager::get_session_by_course($courseInfo['real_id']); if (!empty($coursesInSession)) { foreach ($coursesInSession as $session) { $sessionId = $session['id']; - $coaches = SessionManager::getCoachesByCourseSession($sessionId, $courseInfo['code']); + $coaches = SessionManager::getCoachesByCourseSession($sessionId, $courseInfo['real_id']); $teachers = $allTeachers; $sessionTeachers = array(); @@ -296,8 +297,6 @@ if ($form->validate()) { $warn = substr($warn, 0, -1); } - $tutor_id = isset($course['tutor_name']) ? $course['tutor_name'] : null; - $tutor_name = isset($platform_teachers[$tutor_id]) ? $platform_teachers[$tutor_id] : null; $teachers = $course['course_teachers']; $title = $course['title']; @@ -315,10 +314,10 @@ if ($form->validate()) { $department_url = 'http://' . $department_url; } - $sql = "UPDATE $course_table SET course_language='" . Database::escape_string($course_language) . "', + $sql = "UPDATE $course_table SET + course_language='" . Database::escape_string($course_language) . "', title='" . Database::escape_string($title) . "', category_code='" . Database::escape_string($category_code) . "', - tutor_name='" . Database::escape_string($tutor_name) . "', visual_code='" . Database::escape_string($visual_code) . "', department_name='" . Database::escape_string($department_name) . "', department_url='" . Database::escape_string($department_url) . "', @@ -343,7 +342,7 @@ if ($form->validate()) { if (!empty($sessionCoaches)) { foreach ($sessionCoaches as $sessionId => $teacherInfo) { $coachesToSubscribe = $teacherInfo['coaches_by_session']; - SessionManager::updateCoaches($sessionId, $course['code'], $coachesToSubscribe, true); + SessionManager::updateCoaches($sessionId, $courseId, $coachesToSubscribe, true); } } @@ -360,7 +359,7 @@ if ($form->validate()) { if (!empty($coachesToSubscribe)) { SessionManager::updateCoaches( $sessionId, - $course['code'], + $courseId, $coachesToSubscribe, true ); @@ -369,18 +368,20 @@ if ($form->validate()) { } } + // No need to register me as a teacher. + /* $sql = "INSERT IGNORE INTO " . $course_user_table . " SET - course_code = '" . Database::escape_string($course_code) . "', - user_id = '" . $tutor_id . "', - status = '1', - role = '', - tutor_id='0', - sort='0', - user_course_cat='0'"; + c_id = " . $courseInfo['real_id'] . ", + user_id = '" . $tutor_id . "', + status = '1', + is_tutor ='0', + sort = '0', + user_course_cat='0'"; Database::query($sql); - + */ if (array_key_exists('add_teachers_to_sessions_courses', $courseInfo)) { - $sql = "UPDATE $course_table SET add_teachers_to_sessions_courses = '$addTeacherToSessionCourses' + $sql = "UPDATE $course_table SET + add_teachers_to_sessions_courses = '$addTeacherToSessionCourses' WHERE id = " . $courseInfo['real_id']; Database::query($sql); } diff --git a/main/admin/course_export.php b/main/admin/course_export.php index 3ea7525760..49ef629a03 100755 --- a/main/admin/course_export.php +++ b/main/admin/course_export.php @@ -1,12 +1,11 @@ - - @@ -117,7 +115,9 @@ if (!empty($msg)) { - + diff --git a/main/admin/course_import.php b/main/admin/course_import.php index 7c055943e6..129e54347f 100755 --- a/main/admin/course_import.php +++ b/main/admin/course_import.php @@ -112,12 +112,12 @@ function save_data($courses) } $params = array(); - $params['title'] = $course['Title']; - $params['wanted_code'] = $course['Code']; - $params['tutor_name'] = null; - $params['course_category'] = $course['CourseCategory']; - $params['course_language'] = $course_language; - $params['user_id'] = $creatorId; + $params['title'] = $course['Title']; + $params['wanted_code'] = $course['Code']; + $params['tutor_name'] = null; + $params['course_category'] = $course['CourseCategory']; + $params['course_language'] = $course_language; + $params['user_id'] = $creatorId; $addMeAsTeacher = isset($_POST['add_me_as_teacher']) ? $_POST['add_me_as_teacher'] : false; $params['add_user_as_teacher'] = $addMeAsTeacher; @@ -151,7 +151,7 @@ function save_data($courses) */ function parse_csv_data($file) { - $courses = Import::csv_to_array($file); + $courses = Import::csvToArray($file); return $courses; } @@ -211,9 +211,8 @@ $form = new FormValidator('import', 'post', api_get_self(), null, array('enctype $form->addHeader($tool_name); $form->addElement('file', 'import_file', get_lang('ImportCSVFileLocation')); $form->addElement('checkbox', 'add_me_as_teacher', null, get_lang('AddMeAsTeacherInCourses')); -$form->addElement('button', 'save', get_lang('Import')); +$form->addButtonImport(get_lang('Import'), 'save'); $form->addElement('hidden', 'formSent', 1); -//$form->setDefaults(array('add_me_as_teacher' => 0)); $form->display(); ?> diff --git a/main/admin/course_information.php b/main/admin/course_information.php index c9f2948a35..7395550635 100755 --- a/main/admin/course_information.php +++ b/main/admin/course_information.php @@ -78,6 +78,7 @@ $code = Database::escape_string($_GET['code']); $sql = "SELECT * FROM $table_course WHERE code = '".$code."'"; $res = Database::query($sql); $course = Database::fetch_object($res); +$courseId = $course->id; $tool_name = $course->title.' ('.$course->visual_code.')'; Display::display_header($tool_name); ?> @@ -104,15 +105,17 @@ $table->display(); echo Display::page_header(get_lang('Users')); $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $table_user = Database :: get_main_table(TABLE_MAIN_USER); -$sql = "SELECT *,cu.status as course_status +$sql = "SELECT *, cu.status as course_status FROM $table_course_user cu, $table_user u"; if (api_is_multiple_url_enabled()) { $sql .= " INNER JOIN ".Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER)." url_rel_user ON u.user_id = url_rel_user.user_id AND url_rel_user.access_url_id = ".intval(api_get_current_access_url_id()); } -$sql .= " WHERE cu.user_id = u.user_id AND cu.course_code = '".$code."' - AND cu.relation_type <> ".COURSE_RELATION_TYPE_RRHH; +$sql .= " WHERE + cu.user_id = u.user_id AND + cu.c_id = '".$courseId."' AND + cu.relation_type <> ".COURSE_RELATION_TYPE_RRHH; $res = Database::query($sql); $is_western_name_order = api_is_western_name_order(); if (Database::num_rows($res) > 0) { @@ -150,8 +153,9 @@ if (Database::num_rows($res) > 0) { } else { echo get_lang('NoUsersInCourse'); } +$courseInfo = api_get_course_info($course->code); -$session_list = SessionManager::get_session_by_course($course->code); +$session_list = SessionManager::get_session_by_course($courseInfo['real_id']); $url = api_get_path(WEB_CODE_PATH); if (!empty($session_list)) { diff --git a/main/admin/course_list.php b/main/admin/course_list.php index fe51f8be5c..52b862246d 100755 --- a/main/admin/course_list.php +++ b/main/admin/course_list.php @@ -20,21 +20,22 @@ $sessionId = isset($_GET['session_id']) ? $_GET['session_id'] : null; function get_number_of_courses() { $course_table = Database :: get_main_table(TABLE_MAIN_COURSE); - $sql = "SELECT COUNT(code) AS total_number_of_items FROM $course_table"; + $sql = "SELECT COUNT(code) AS total_number_of_items FROM $course_table c"; if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1 ) { $access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); - $sql.= " INNER JOIN $access_url_rel_course_table url_rel_course ON (code=url_rel_course.course_code)"; + $sql.= " INNER JOIN $access_url_rel_course_table url_rel_course + ON (c.id = url_rel_course.c_id)"; } if (isset ($_GET['keyword'])) { $keyword = Database::escape_string("%".$_GET['keyword']."%"); $sql .= " WHERE ( - title LIKE '".$keyword."' OR - code LIKE '".$keyword."' OR - visual_code LIKE '".$keyword."' + c.title LIKE '".$keyword."' OR + c.code LIKE '".$keyword."' OR + c.visual_code LIKE '".$keyword."' ) "; } elseif (isset($_GET['keyword_code'])) { @@ -47,13 +48,13 @@ function get_number_of_courses() $keyword_unsubscribe = Database::escape_string($_GET['keyword_unsubscribe']); $sql .= " WHERE - (code LIKE '".$keyword_code."' OR visual_code LIKE '".$keyword_code."') AND - title LIKE '".$keyword_title."' AND - category_code LIKE '".$keyword_category."' AND - course_language LIKE '".$keyword_language."' AND - visibility LIKE '".$keyword_visibility."' AND - subscribe LIKE '".$keyword_subscribe."' AND - unsubscribe LIKE '".$keyword_unsubscribe."' + (c.code LIKE '".$keyword_code."' OR c.visual_code LIKE '".$keyword_code."') AND + c.title LIKE '".$keyword_title."' AND + c.category_code LIKE '".$keyword_category."' AND + c.course_language LIKE '".$keyword_language."' AND + c.visibility LIKE '".$keyword_visibility."' AND + c.subscribe LIKE '".$keyword_subscribe."' AND + c.unsubscribe LIKE '".$keyword_unsubscribe."' "; } @@ -61,7 +62,7 @@ function get_number_of_courses() if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1 ) { - $sql.= " AND url_rel_course.access_url_id=".api_get_current_access_url_id(); + $sql.= " AND url_rel_course.access_url_id = ".api_get_current_access_url_id(); } $res = Database::query($sql); @@ -100,7 +101,7 @@ function get_course_data($from, $number_of_items, $column, $direction) api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1 ) { $access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); - $sql.= " INNER JOIN $access_url_rel_course_table url_rel_course ON (code=url_rel_course.course_code)"; + $sql.= " INNER JOIN $access_url_rel_course_table url_rel_course ON (id = url_rel_course.c_id)"; } if (isset ($_GET['keyword'])) { @@ -182,7 +183,7 @@ function get_course_data_by_session($from, $number_of_items, $column, $direction c.visual_code FROM $course_table c INNER JOIN $session_rel_course r ON c.code = r.course_code - INNER JOIN $session s ON r.id_session = s.id + INNER JOIN $session s ON r.session_id = s.id "; if (isset($_GET['session_id']) && !empty($_GET['session_id'])) { diff --git a/main/admin/course_request_accepted.php b/main/admin/course_request_accepted.php index c5a461caf4..e15b221273 100755 --- a/main/admin/course_request_accepted.php +++ b/main/admin/course_request_accepted.php @@ -23,8 +23,8 @@ api_protect_admin_script(); $course_validation_feature = api_get_setting('course_validation') == 'true'; // Filltering passed to this page parameters. -$delete_course_request = intval($_GET['delete_course_request']); -$message = trim(Security::remove_XSS(stripslashes(urldecode($_GET['message'])))); +$delete_course_request = isset($_GET['delete_course_request']) ? intval($_GET['delete_course_request']) : ''; +$message = isset($_GET['message']) ? trim(Security::remove_XSS(stripslashes(urldecode($_GET['message'])))) : ''; $is_error_message = !empty($_GET['is_error_message']); if ($course_validation_feature) { @@ -84,17 +84,28 @@ function get_request_data($from, $number_of_items, $column, $direction) $keyword = isset($_GET['keyword']) ? Database::escape_string(trim($_GET['keyword'])) : null; $course_request_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST); - $sql = "SELECT id AS col0, - code AS col1, - title AS col2, - category_code AS col3, - tutor_name AS col4, - request_date AS col5, - id AS col6 - FROM $course_request_table WHERE status = ".COURSE_REQUEST_ACCEPTED; + $from = intval($from); + $number_of_items = intval($number_of_items); + $column = intval($column); + $direction = !in_array(strtolower(trim($direction)), ['asc','desc']) ? 'asc' : $direction; + + $sql = "SELECT + id AS col0, + code AS col1, + title AS col2, + category_code AS col3, + tutor_name AS col4, + request_date AS col5, + id AS col6 + FROM $course_request_table + WHERE status = ".COURSE_REQUEST_ACCEPTED; if ($keyword != '') { - $sql .= " AND (title LIKE '%".$keyword."%' OR code LIKE '%".$keyword."%' OR visual_code LIKE '%".$keyword."%')"; + $sql .= " AND ( + title LIKE '%".$keyword."%' OR + code LIKE '%".$keyword."%' OR + visual_code LIKE '%".$keyword."%' + )"; } $sql .= " ORDER BY col$column $direction "; $sql .= " LIMIT $from,$number_of_items"; @@ -115,8 +126,10 @@ function get_request_data($from, $number_of_items, $column, $direction) function modify_filter($id) { $code = CourseRequestManager::get_course_request_code($id); - $result = ''.Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align: middle;')).''. - ' '.Display::return_icon('delete.gif', get_lang('DeleteThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ACourseRequestWillBeDeleted'), $code), ENT_QUOTES)).'\')) return false;')).''; + $result = ''. + Display::return_icon('edit.png', get_lang('Edit'), array('style' => 'vertical-align: middle;')).''. + ' '. + Display::return_icon('delete.png', get_lang('DeleteThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ACourseRequestWillBeDeleted'), $code), ENT_QUOTES)).'\')) return false;')).''; return $result; } @@ -149,7 +162,6 @@ $form->addButtonSearch(get_lang('Search')); // The action bar. echo '
'; -//echo ''.Display::return_icon('courses.gif', get_lang('CourseList')).get_lang('CourseList').''; echo ' '.Display::return_icon('course_request_pending.png', get_lang('ReviewCourseRequests')).get_lang('ReviewCourseRequests').''; echo ' '.Display::return_icon('course_request_rejected.gif', get_lang('RejectedCourseRequests')).get_lang('RejectedCourseRequests').''; echo '
'; @@ -159,7 +171,6 @@ echo ''; // Create a sortable table with the course data. $table = new SortableTable('course_requests_accepted', 'get_number_of_requests', 'get_request_data', 5, 20, 'DESC'); -//$table->set_additional_parameters($parameters); $table->set_header(0, '', false); $table->set_header(1, get_lang('Code')); $table->set_header(2, get_lang('Title')); diff --git a/main/admin/course_request_edit.php b/main/admin/course_request_edit.php index 67490eefed..08c38bb929 100755 --- a/main/admin/course_request_edit.php +++ b/main/admin/course_request_edit.php @@ -31,10 +31,8 @@ if ($course_validation_feature) { $is_error_message = true; } else { - global $_configuration; - $dbnamelength = strlen($_configuration['db_prefix']); // Ensure the database prefix + database name do not get over 40 characters. - $maxlength = 40 - $dbnamelength; + $maxlength = 40; // Build the form. $form = new FormValidator('add_course', 'post', 'course_request_edit.php?id='.$id.'&caller='.$caller); diff --git a/main/admin/course_request_rejected.php b/main/admin/course_request_rejected.php index d9b27ce6ac..5f8e20ff0e 100755 --- a/main/admin/course_request_rejected.php +++ b/main/admin/course_request_rejected.php @@ -23,12 +23,12 @@ api_protect_admin_script(); $course_validation_feature = api_get_setting('course_validation') == 'true'; // Filltering passed to this page parameters. -$accept_course_request = intval($_GET['accept_course_request']); -$delete_course_request = intval($_GET['delete_course_request']); -$request_info = intval($_GET['request_info']); -$message = trim(Security::remove_XSS(stripslashes(urldecode($_GET['message'])))); +$accept_course_request = isset($_GET['accept_course_request']) ? intval($_GET['accept_course_request']) : ''; +$delete_course_request = isset($_GET['delete_course_request']) ? intval($_GET['delete_course_request']) : ''; +$request_info = isset($_GET['request_info']) ? intval($_GET['request_info']) : ''; +$message = isset($_GET['message']) ? trim(Security::remove_XSS(stripslashes(urldecode($_GET['message'])))) : ''; $is_error_message = !empty($_GET['is_error_message']); -$keyword = Database::escape_string(trim($_GET['keyword'])); +$keyword = isset($_GET['keyword']) ? Database::escape_string(trim($_GET['keyword'])) : ''; if ($course_validation_feature) { @@ -109,17 +109,23 @@ function get_number_of_requests() { */ function get_request_data($from, $number_of_items, $column, $direction) { global $keyword; - $course_request_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST); - $sql = "SELECT id AS col0, - code AS col1, - title AS col2, - category_code AS col3, - tutor_name AS col4, - request_date AS col5, - id AS col6 - FROM $course_request_table WHERE status = ".COURSE_REQUEST_REJECTED; + $from = intval($from); + $number_of_items = intval($number_of_items); + $column = intval($column); + $direction = !in_array(strtolower(trim($direction)), ['asc','desc']) ? 'asc' : $direction; + + $sql = "SELECT + id AS col0, + code AS col1, + title AS col2, + category_code AS col3, + tutor_name AS col4, + request_date AS col5, + id AS col6 + FROM $course_request_table + WHERE status = ".COURSE_REQUEST_REJECTED; if ($keyword != '') { $sql .= " AND (title LIKE '%".$keyword."%' OR code LIKE '%".$keyword."%' OR visual_code LIKE '%".$keyword."%')"; @@ -142,12 +148,12 @@ function get_request_data($from, $number_of_items, $column, $direction) { */ function modify_filter($id) { $code = CourseRequestManager::get_course_request_code($id); - $result = ''.Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align: middle;')).''. - ' '.Display::return_icon('action_accept.gif', get_lang('AcceptThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ANewCourseWillBeCreated'), $code), ENT_QUOTES)).'\')) return false;')).''; + $result = ''.Display::return_icon('edit.png', get_lang('Edit'), array('style' => 'vertical-align: middle;')).''. + ' '.Display::return_icon('accept.png', get_lang('AcceptThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ANewCourseWillBeCreated'), $code), ENT_QUOTES)).'\')) return false;')).''; if (!CourseRequestManager::additional_info_asked($id)) { $result .= ' '.Display::return_icon('request_info.gif', get_lang('AskAdditionalInfo'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('AdditionalInfoWillBeAsked'), $code), ENT_QUOTES)).'\')) return false;')).''; } - $result .= ' '.Display::return_icon('delete.gif', get_lang('DeleteThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ACourseRequestWillBeDeleted'), $code), ENT_QUOTES)).'\')) return false;')).''; + $result .= ' '.Display::return_icon('delete.png', get_lang('DeleteThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ACourseRequestWillBeDeleted'), $code), ENT_QUOTES)).'\')) return false;')).''; return $result; } @@ -182,7 +188,6 @@ $form->addButtonSearch(get_lang('Search')); // The action bar. echo '
'; -//echo ''.Display::return_icon('courses.gif', get_lang('CourseList')).get_lang('CourseList').''; echo ' '.Display::return_icon('course_request_pending.png', get_lang('ReviewCourseRequests')).get_lang('ReviewCourseRequests').''; echo ' '.Display::return_icon('course_request_accepted.gif', get_lang('AcceptedCourseRequests')).get_lang('AcceptedCourseRequests').''; echo '
'; @@ -192,7 +197,6 @@ echo ''; // Create a sortable table with the course data. $table = new SortableTable('course_requests_rejected', 'get_number_of_requests', 'get_request_data', 5, 20, 'DESC'); -//$table->set_additional_parameters($parameters); $table->set_header(0, '', false); $table->set_header(1, get_lang('Code')); $table->set_header(2, get_lang('Title')); diff --git a/main/admin/course_request_review.php b/main/admin/course_request_review.php index eb3bb572ef..886cc17a59 100755 --- a/main/admin/course_request_review.php +++ b/main/admin/course_request_review.php @@ -24,13 +24,13 @@ api_protect_admin_script(); $course_validation_feature = api_get_setting('course_validation') == 'true'; // Filltering passed to this page parameters. -$accept_course_request = intval($_GET['accept_course_request']); -$reject_course_request = intval($_GET['reject_course_request']); -$request_info = intval($_GET['request_info']); -$delete_course_request = intval($_GET['delete_course_request']); -$message = trim(Security::remove_XSS(stripslashes(urldecode($_GET['message'])))); -$is_error_message = !empty($_GET['is_error_message']); -$keyword = Database::escape_string(trim($_GET['keyword'])); +$accept_course_request = isset($_GET['accept_course_request']) ? intval($_GET['accept_course_request']) : ''; +$reject_course_request = isset($_GET['reject_course_request']) ? intval($_GET['reject_course_request']) : ''; +$request_info = isset($_GET['request_info']) ? intval($_GET['request_info']) : ''; +$delete_course_request = isset($_GET['delete_course_request']) ? intval($_GET['delete_course_request']) : ''; +$message = isset($_GET['message']) ? trim(Security::remove_XSS(stripslashes(urldecode($_GET['message'])))) : ''; +$is_error_message = isset($_GET['is_error_message']) ? !empty($_GET['is_error_message']) : ''; +$keyword = isset($_GET['keyword']) ? Database::escape_string(trim($_GET['keyword'])) : ''; if ($course_validation_feature) { @@ -188,14 +188,14 @@ function email_filter($teacher) function modify_filter($id) { $code = CourseRequestManager::get_course_request_code($id); - $result = ''.Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align: middle;')).''. + $result = ''.Display::return_icon('edit.png', get_lang('Edit'), array('style' => 'vertical-align: middle;')).''. ' '.Display::return_icon('accept.png', get_lang('AcceptThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ANewCourseWillBeCreated'), $code), ENT_QUOTES)).'\')) return false;'),16).''. ' '.Display::return_icon('error.png', get_lang('RejectThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ACourseRequestWillBeRejected'), $code), ENT_QUOTES)).'\')) return false;'),16).''; if (!CourseRequestManager::additional_info_asked($id)) { $result .= ' '.Display::return_icon('request_info.gif', get_lang('AskAdditionalInfo'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('AdditionalInfoWillBeAsked'), $code), ENT_QUOTES)).'\')) return false;')).''; } if (DELETE_ACTION_ENABLED) { - $result .= ' '.Display::return_icon('delete.gif', get_lang('DeleteThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ACourseRequestWillBeDeleted'), $code), ENT_QUOTES)).'\')) return false;')).''; + $result .= ' '.Display::return_icon('delete.png', get_lang('DeleteThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ACourseRequestWillBeDeleted'), $code), ENT_QUOTES)).'\')) return false;')).''; } return $result; diff --git a/main/admin/course_user_import.php b/main/admin/course_user_import.php index afd8ce7c6b..6cc588ddab 100755 --- a/main/admin/course_user_import.php +++ b/main/admin/course_user_import.php @@ -1,10 +1,12 @@ course_code] = $obj->status; + $db_subscriptions[$obj->c_id] = $obj->status; } $to_subscribe = array_diff(array_keys($csv_subscriptions), array_keys($db_subscriptions)); $to_unsubscribe = array_diff(array_keys($db_subscriptions), array_keys($csv_subscriptions)); if ($_POST['subscribe']) { - foreach ($to_subscribe as $course_code) { + foreach ($to_subscribe as $courseId) { + $courseInfo = api_get_course_info_by_id($courseId); + $course_code = $courseInfo['code']; + if (CourseManager :: course_exists($course_code)) { CourseManager::subscribe_user( $user_id, @@ -108,7 +113,10 @@ function save_data($users_courses) } if ($_POST['unsubscribe']) { - foreach ($to_unsubscribe as $course_code) { + foreach ($to_unsubscribe as $courseId) { + $courseInfo = api_get_course_info_by_id($courseId); + $course_code = $courseInfo['code']; + if (CourseManager :: course_exists($course_code)) { CourseManager::unsubscribe_user($user_id, $course_code); $course_info = CourseManager::get_course_information($course_code); @@ -129,7 +137,7 @@ function save_data($users_courses) */ function parse_csv_data($file) { - $courses = Import :: csv_to_array($file); + $courses = Import :: csvToArray($file); return $courses; } @@ -211,7 +219,7 @@ $form->display(); UserName;CourseCode;Status jdoe;course01; - adam;course01; +adam;course01; '; diff --git a/main/admin/course_user_import_by_email.php b/main/admin/course_user_import_by_email.php index ac8daf462c..23794ebc1a 100755 --- a/main/admin/course_user_import_by_email.php +++ b/main/admin/course_user_import_by_email.php @@ -90,14 +90,16 @@ function save_data($users_courses) $res = Database::query($sql); $db_subscriptions = array(); while ($obj = Database::fetch_object($res)) { - $db_subscriptions[$obj->course_code] = $obj->status; + $db_subscriptions[$obj->c_id] = $obj->status; } $to_subscribe = array_diff(array_keys($csv_subscriptions), array_keys($db_subscriptions)); $to_unsubscribe = array_diff(array_keys($db_subscriptions), array_keys($csv_subscriptions)); if ($_POST['subscribe']) { - foreach ($to_subscribe as $course_code) { + foreach ($to_subscribe as $courseId) { + $courseInfo = api_get_course_info_by_id($courseId); + $course_code = $courseInfo['code']; if (CourseManager :: course_exists($course_code)) { $course_info = CourseManager::get_course_information($course_code); $inserted_in_course[$course_code] = $course_info['title']; @@ -113,7 +115,9 @@ function save_data($users_courses) } if ($_POST['unsubscribe']) { - foreach ($to_unsubscribe as $course_code) { + foreach ($to_unsubscribe as $courseId) { + $courseInfo = api_get_course_info_by_id($courseId); + $course_code = $courseInfo['code']; if (CourseManager :: course_exists($course_code)) { CourseManager::unsubscribe_user($user_id, $course_code); $course_info = CourseManager::get_course_information($course_code); @@ -134,7 +138,7 @@ function save_data($users_courses) */ function parse_csv_data($file) { - $courses = Import :: csv_to_array($file); + $courses = Import :: csvToArray($file); return $courses; } diff --git a/main/admin/dashboard_add_courses_to_user.php b/main/admin/dashboard_add_courses_to_user.php index db4fbde051..f395fc7c7d 100755 --- a/main/admin/dashboard_add_courses_to_user.php +++ b/main/admin/dashboard_add_courses_to_user.php @@ -10,8 +10,6 @@ $cidReset = true; require_once '../inc/global.inc.php'; -global $_configuration; - $xajax = new xajax(); $xajax->registerFunction('search_courses'); @@ -56,7 +54,7 @@ if (!api_is_platform_admin()) { function search_courses($needle, $type) { - global $_configuration, $tbl_course, $tbl_course_rel_access_url,$user_id; + global $tbl_course, $tbl_course_rel_access_url,$user_id; $xajax_response = new xajaxResponse(); $return = ''; @@ -76,12 +74,20 @@ function search_courses($needle, $type) $without_assigned_courses = " AND c.code NOT IN(".implode(',',$assigned_courses_code).")"; } - if ($_configuration['multiple_access_urls']) { - $sql = "SELECT c.code, c.title FROM $tbl_course c LEFT JOIN $tbl_course_rel_access_url a ON (a.course_code = c.code) - WHERE c.code LIKE '$needle%' $without_assigned_courses AND access_url_id = ".api_get_current_access_url_id().""; + if (api_is_multiple_url_enabled()) { + $sql = "SELECT c.code, c.title + FROM $tbl_course c + LEFT JOIN $tbl_course_rel_access_url a + ON (a.c_id = c.id) + WHERE + c.code LIKE '$needle%' $without_assigned_courses AND + access_url_id = ".api_get_current_access_url_id(); } else { - $sql = "SELECT c.code, c.title FROM $tbl_course c - WHERE c.code LIKE '$needle%' $without_assigned_courses "; + $sql = "SELECT c.code, c.title + FROM $tbl_course c + WHERE + c.code LIKE '$needle%' + $without_assigned_courses "; } $rs = Database::query($sql); @@ -156,7 +162,7 @@ $UserList = array(); $msg = ''; if (isset($_POST['formSent']) && intval($_POST['formSent']) == 1) { $courses_list = $_POST['CoursesList']; - $affected_rows = CourseManager::suscribe_courses_to_hr_manager($user_id,$courses_list); + $affected_rows = CourseManager::subscribeCoursesToDrhManager($user_id, $courses_list); if ($affected_rows) { $msg = get_lang('AssignedCoursesHaveBeenUpdatedSuccessfully'); } @@ -195,14 +201,16 @@ if (isset($_POST['firstLetterCourse'])) { if (api_is_multiple_url_enabled()) { $sql = " SELECT c.code, c.title FROM $tbl_course c - LEFT JOIN $tbl_course_rel_access_url a ON (a.course_code = c.code) + LEFT JOIN $tbl_course_rel_access_url a + ON (a.c_id = c.id) WHERE c.code LIKE '$needle' $without_assigned_courses AND access_url_id = ".api_get_current_access_url_id()." ORDER BY c.title"; } else { - $sql= " SELECT c.code, c.title FROM $tbl_course c + $sql= " SELECT c.code, c.title + FROM $tbl_course c WHERE c.code LIKE '$needle' $without_assigned_courses ORDER BY c.title"; } diff --git a/main/admin/dashboard_add_sessions_to_user.php b/main/admin/dashboard_add_sessions_to_user.php index 9d7c0234bb..b0f49cc10e 100755 --- a/main/admin/dashboard_add_sessions_to_user.php +++ b/main/admin/dashboard_add_sessions_to_user.php @@ -9,7 +9,6 @@ $cidReset = true; require_once '../inc/global.inc.php'; -global $_configuration; // create an ajax object $xajax = new xajax(); @@ -57,7 +56,7 @@ if (!api_is_platform_admin() && !api_is_session_admin()) { function search_sessions($needle, $type) { - global $_configuration, $tbl_session_rel_access_url, $tbl_session, $user_id; + global $tbl_session_rel_access_url, $tbl_session, $user_id; $xajax_response = new xajaxResponse(); $return = ''; @@ -74,7 +73,7 @@ function search_sessions($needle, $type) $without_assigned_sessions = " AND s.id NOT IN(".implode(',', $assigned_sessions_id).")"; } - if ($_configuration['multiple_access_urls']) { + if (api_is_multiple_url_enabled()) { $sql = " SELECT s.id, s.name FROM $tbl_session s LEFT JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id) WHERE s.name LIKE '$needle%' $without_assigned_sessions AND access_url_id = ".api_get_current_access_url_id().""; diff --git a/main/admin/ldap_import_students_to_session.php b/main/admin/ldap_import_students_to_session.php index 68cd39fab1..11e3b1d3f8 100755 --- a/main/admin/ldap_import_students_to_session.php +++ b/main/admin/ldap_import_students_to_session.php @@ -158,24 +158,21 @@ elseif (!empty($annee) && !empty($id_session) && ($_POST['confirmed']=='yes')) $userid_match_login[$tmp] = $user_id; } } - if (!empty($_POST['id_session'])) - { + if (!empty($_POST['id_session'])) { $num = 0; $tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); - foreach($UserList as $user_id) - { + foreach ($UserList as $user_id) { $sql = 'INSERT INTO '.$tbl_session_user.' SET - id_user="'.intval($user_id).'", - id_session = "'.intval($id_session).'"'; + user_id ="'.intval($user_id).'", + session_id = "'.intval($id_session).'"'; $res_user = Database::query($sql); - if ($res_user) - { + if ($res_user) { $num++; } } - if($num>0) - { + + if($num>0) { $sql = 'UPDATE '.$tbl_session.' SET nbr_users = (nbr_users + '.$num.') WHERE id = '.intval($id_session); $res = Database::query($sql); } diff --git a/main/admin/ldap_synchro.php b/main/admin/ldap_synchro.php index 5cc1a53cc6..2c69af8b17 100755 --- a/main/admin/ldap_synchro.php +++ b/main/admin/ldap_synchro.php @@ -124,42 +124,41 @@ foreach($Sessions as $session){ print "> $name_session: ".count($UserAdd).get_lang('Added').' '.get_lang('And').' '.count($UserUpdate).' '.get_lang('Modified')."\n"; } - // Une fois les utilisateurs importer dans la base des utilisateurs, on peux les affecter a� la session - $result=Database::query("SELECT course_code FROM $tbl_session_rel_course " . - "WHERE id_session='$id_session'"); + // Une fois les utilisateurs importer dans la base des utilisateurs, on peux les affecter la session + $result=Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id='$id_session'"); $CourseList=array(); - while($row=Database::fetch_array($result)) - { - $CourseList[]=$row['course_code']; + while($row=Database::fetch_array($result)) { + $CourseList[]= $row['c_id']; } - foreach($CourseList as $enreg_course) - { + + foreach ($CourseList as $enreg_course) { // On ajoute la relation entre l'utilisateur et le cours - foreach($UserList as $enreg_user) - { - Database::query("INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user) VALUES('$id_session','$enreg_course','$enreg_user')"); + foreach ($UserList as $enreg_user) { + $sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(session_id,c_id,user_id) + VALUES('$id_session','$enreg_course','$enreg_user')"; + Database::query($sql); } - $sql = "SELECT COUNT(id_user) as nbUsers " . + $sql = "SELECT COUNT(user_id) as nbUsers " . "FROM $tbl_session_rel_course_rel_user " . - "WHERE id_session='$id_session' AND course_code='$enreg_course'"; + "WHERE session_id='$id_session' AND c_id='$enreg_course'"; $rs = Database::query($sql); list($nbr_users) = Database::fetch_array($rs); - $sql = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'"; + $sql = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users + WHERE session_id='$id_session' AND c_id = '$enreg_course'"; Database::query($sql); } // On ajoute la relation entre l'utilisateur et la session foreach($UserList as $enreg_user){ - $sql = "INSERT IGNORE INTO $tbl_session_rel_user(id_session, id_user) " . + $sql = "INSERT IGNORE INTO $tbl_session_rel_user(session_id, user_id) " . "VALUES('$id_session','$enreg_user')"; Database::query($sql); } - $sql = "SELECT COUNT(id_user) as nbUsers " . + $sql = "SELECT COUNT(user_id) as nbUsers " . "FROM $tbl_session_rel_user " . - "WHERE id_session='$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH.""; + "WHERE session_id='$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH.""; $rs = Database::query($sql); list($nbr_users) = Database::fetch_array($rs); $sql = "UPDATE $tbl_session SET nbr_users=$nbr_users WHERE id='$id_session'"; Database::query($sql); } } -?> diff --git a/main/admin/resume_session.php b/main/admin/resume_session.php index 26b5699b32..f37167b883 100755 --- a/main/admin/resume_session.php +++ b/main/admin/resume_session.php @@ -1,9 +1,11 @@ ".SESSION_RELATION_TYPE_RRHH." AND - srcru.id_session = '".intval($sessionId)."'"; + srcru.session_id = '".intval($sessionId)."'"; $rs = Database::query($sql); $course['nbr_users'] = Database::result($rs, 0, 0); // Get coachs of the courses in session - $sql = "SELECT user.lastname,user.firstname,user.username + $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($sessionId)."' AND - session_rcru.course_code ='".Database::escape_string($course['code'])."' AND + session_rcru.user_id = user.user_id AND + session_rcru.session_id = '".intval($sessionId)."' AND + session_rcru.c_id ='".intval($course['id'])."' AND session_rcru.status=2"; $rs = Database::query($sql); @@ -345,7 +350,7 @@ if ($session['nbr_courses'] == 0) { $orderButtons = null; $upIcon = 'up.png'; - $urlUp = api_get_self().'?id_session='.$sessionId.'&course_code='.$course['code'].'&action=move_up'; + $urlUp = api_get_self().'?id_session='.$sessionId.'&course_id='.$course['id'].'&action=move_up'; if ($count == 0) { $upIcon = 'up_na.png'; @@ -358,7 +363,7 @@ if ($session['nbr_courses'] == 0) { ); $downIcon = 'down.png'; - $downUrl = api_get_self().'?id_session='.$sessionId.'&course_code='.$course['code'].'&action=move_down'; + $downUrl = api_get_self().'?id_session='.$sessionId.'&course_id='.$course['id'].'&action=move_down'; if ($count +1 == count($courses)) { $downIcon = 'down_na.png'; diff --git a/main/admin/session_category_add.php b/main/admin/session_category_add.php index 1f0a7e66bf..1d3ba625df 100755 --- a/main/admin/session_category_add.php +++ b/main/admin/session_category_add.php @@ -63,7 +63,7 @@ if (!empty($return)) { -
+ '; echo ''; @@ -1426,31 +1472,91 @@ abstract class Question echo '
'; } - static function saveQuestionOption($question_id, $name, $course_id, $position = 0) { - $TBL_EXERCICE_QUESTION_OPTION = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); - $params['question_id'] = intval($question_id); - $params['name'] = $name; - $params['position'] = $position; - $params['c_id'] = $course_id; + /** + * @param int $question_id + * @param string $name + * @param int $course_id + * @param int $position + * @return bool|int + */ + static function saveQuestionOption($question_id, $name, $course_id, $position = 0) + { + $TBL_EXERCICE_QUESTION_OPTION = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); + $params['question_id'] = intval($question_id); + $params['name'] = $name; + $params['position'] = $position; + $params['c_id'] = $course_id; $result = self::readQuestionOption($question_id, $course_id); $last_id = Database::insert($TBL_EXERCICE_QUESTION_OPTION, $params); + if ($last_id) { + $sql = "UPDATE $TBL_EXERCICE_QUESTION_OPTION SET id = iid WHERE iid = $last_id"; + Database::query($sql); + } + return $last_id; } - static function deleteAllQuestionOptions($question_id, $course_id) { - $TBL_EXERCICE_QUESTION_OPTION = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); - Database::delete($TBL_EXERCICE_QUESTION_OPTION, array('c_id = ? AND question_id = ?'=> array($course_id, $question_id))); + /** + * @param int $question_id + * @param int $course_id + */ + static function deleteAllQuestionOptions($question_id, $course_id) + { + $TBL_EXERCICE_QUESTION_OPTION = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); + Database::delete( + $TBL_EXERCICE_QUESTION_OPTION, + array( + 'c_id = ? AND question_id = ?' => array( + $course_id, + $question_id + ) + ) + ); } - static function updateQuestionOption($id, $params, $course_id) { - $TBL_EXERCICE_QUESTION_OPTION = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); - $result = Database::update($TBL_EXERCICE_QUESTION_OPTION, $params, array('c_id = ? AND id = ?'=>array($course_id, $id))); + /** + * @param int $id + * @param array $params + * @param int $course_id + * @return bool|int + */ + static function updateQuestionOption($id, $params, $course_id) + { + $TBL_EXERCICE_QUESTION_OPTION = Database::get_course_table( + TABLE_QUIZ_QUESTION_OPTION + ); + $result = Database::update( + $TBL_EXERCICE_QUESTION_OPTION, + $params, + array('c_id = ? AND id = ?' => array($course_id, $id)) + ); return $result; } - static function readQuestionOption($question_id, $course_id) { - $TBL_EXERCICE_QUESTION_OPTION = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); - $result = Database::select('*', $TBL_EXERCICE_QUESTION_OPTION, array('where'=>array('c_id = ? AND question_id = ?' =>array($course_id, $question_id)), 'order'=>'id ASC')); + /** + * @param int $question_id + * @param int $course_id + * @return array + */ + static function readQuestionOption($question_id, $course_id) + { + $TBL_EXERCICE_QUESTION_OPTION = Database::get_course_table( + TABLE_QUIZ_QUESTION_OPTION + ); + $result = Database::select( + '*', + $TBL_EXERCICE_QUESTION_OPTION, + array( + 'where' => array( + 'c_id = ? AND question_id = ?' => array( + $course_id, + $question_id + ) + ), + 'order' => 'id ASC' + ) + ); + return $result; } @@ -1487,7 +1593,7 @@ abstract class Question $question_title = $this->question; // display question category, if any - $header = Testcategory::returnCategoryAndTitle($this->id); + $header = TestCategory::returnCategoryAndTitle($this->id); $show_media = null; if ($show_media) { $header .= $this->show_media_content(); @@ -1526,10 +1632,13 @@ abstract class Question $level = intval($level); // Get the max position - $sql = "SELECT max(position) as max_position" - ." FROM $tbl_quiz_question q INNER JOIN $tbl_quiz_rel_question r" - ." ON q.id = r.question_id" - ." AND exercice_id = $quiz_id AND q.c_id = $course_id AND r.c_id = $course_id"; + $sql = "SELECT max(position) as max_position + FROM $tbl_quiz_question q INNER JOIN $tbl_quiz_rel_question r + ON + q.id = r.question_id AND + exercice_id = $quiz_id AND + q.c_id = $course_id AND + r.c_id = $course_id"; $rs_max = Database::query($sql); $row_max = Database::fetch_object($rs_max); $max_position = $row_max->max_position +1; @@ -1537,22 +1646,28 @@ abstract class Question // Insert the new question $sql = "INSERT INTO $tbl_quiz_question (c_id, question, description, ponderation, position, type, level) VALUES ($course_id, '".Database::escape_string($question_name)."', '".Database::escape_string($question_description)."', '$max_score', $max_position, $type, $level)"; - Database::query($sql); + // Get the question ID $question_id = Database::insert_id(); + if ($question_id) { + + $sql = "UPDATE $tbl_quiz_question SET id = iid WHERE iid = $question_id"; + Database::query($sql); + + // Get the max question_order + $sql = "SELECT max(question_order) as max_order + FROM $tbl_quiz_rel_question + WHERE c_id = $course_id AND exercice_id = $quiz_id "; + $rs_max_order = Database::query($sql); + $row_max_order = Database::fetch_object($rs_max_order); + $max_order = $row_max_order->max_order + 1; + // Attach questions to quiz + $sql = "INSERT INTO $tbl_quiz_rel_question (c_id, question_id,exercice_id,question_order) + VALUES($course_id, $question_id, $quiz_id, $max_order)"; + Database::query($sql); + } - // Get the max question_order - $sql = "SELECT max(question_order) as max_order " - ."FROM $tbl_quiz_rel_question WHERE c_id = $course_id AND exercice_id = $quiz_id "; - $rs_max_order = Database::query($sql); - $row_max_order = Database::fetch_object($rs_max_order); - $max_order = $row_max_order->max_order + 1; - // Attach questions to quiz - $sql = "INSERT INTO $tbl_quiz_rel_question " - ."(c_id, question_id,exercice_id,question_order)" - ." VALUES($course_id, $question_id, $quiz_id, $max_order)"; - Database::query($sql); return $question_id; } diff --git a/main/exercice/question_admin.inc.php b/main/exercice/question_admin.inc.php index c4763204ce..5d64225052 100755 --- a/main/exercice/question_admin.inc.php +++ b/main/exercice/question_admin.inc.php @@ -22,12 +22,12 @@ if (is_object($objQuestion)) { // FORM CREATION $form = new FormValidator('question_admin_form','post', $action); if (isset($_GET['editQuestion'])) { - $class="btn btn-default"; - $text=' '.get_lang('ModifyQuestion'); + $class = "btn btn-default"; + $text = get_lang('ModifyQuestion'); $type = isset($_GET['type']) ? Security::remove_XSS($_GET['type']) : null; } else { - $class="btn btn-default"; - $text=' '.get_lang('AddQuestionToExercise'); + $class = "btn btn-default"; + $text = get_lang('AddQuestionToExercise'); $type = $_REQUEST['answerType']; } diff --git a/main/exercice/question_list_admin.inc.php b/main/exercice/question_list_admin.inc.php index ce6910fe41..6fe0969183 100755 --- a/main/exercice/question_list_admin.inc.php +++ b/main/exercice/question_list_admin.inc.php @@ -226,7 +226,7 @@ if (!$inATest) { $questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), ICON_SIZE_MEDIUM), array('style'=>$styleType)); // Question category - $txtQuestionCat = Security::remove_XSS(Testcategory::getCategoryNameForQuestion($objQuestionTmp->id)); + $txtQuestionCat = Security::remove_XSS(TestCategory::getCategoryNameForQuestion($objQuestionTmp->id)); if (empty($txtQuestionCat)) { $txtQuestionCat = "-"; } diff --git a/main/exercice/question_pool.php b/main/exercice/question_pool.php index 10acd427db..9fe207da11 100755 --- a/main/exercice/question_pool.php +++ b/main/exercice/question_pool.php @@ -269,8 +269,7 @@ if (!empty($session_id) && $session_id != '-1' && !empty($sessionList)) { if (api_is_platform_admin()) { $courseInfo = api_get_course_info(); if (!empty($course_list)) { - $courseIdList = array_keys($course_list); - if (!in_array($courseInfo['real_id'], $courseIdList)) { + if (!in_array($courseInfo['real_id'], $course_list)) { $course_list = array_merge($course_list, array($courseInfo)); } } else { @@ -323,7 +322,7 @@ $TBL_COURSE_REL_CATEGORY = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CA // Get course categories for the selected course // get category list for the course $selected_course -$categoryList = Testcategory::getCategoriesIdAndName($selected_course); +$categoryList = TestCategory::getCategoriesIdAndName($selected_course); $selectCourseCategory = Display::select( 'courseCategoryId', $categoryList, @@ -583,7 +582,7 @@ if ($exerciseId > 0) { } } - $categoryIdFromQuestion = Testcategory::getCategoryForQuestion( + $categoryIdFromQuestion = TestCategory::getCategoryForQuestion( $question_obj->id, $selected_course ); @@ -946,6 +945,6 @@ function get_question_type_for_question($in_selectedcourse, $in_questionid) */ function get_question_categorie_for_question($in_courseid, $in_questionid) { - $cat = Testcategory::getCategoryNameForQuestion($in_questionid, $in_courseid); + $cat = TestCategory::getCategoryNameForQuestion($in_questionid, $in_courseid); return $cat; } diff --git a/main/exercice/result.php b/main/exercice/result.php index 766bcaab44..2d95e1bd8f 100755 --- a/main/exercice/result.php +++ b/main/exercice/result.php @@ -1,9 +1,10 @@ read($exercise_id); } -//Only users can see their own results +// Only users can see their own results if (!$is_allowedToEdit) { if ($student_id != $current_user_id) { api_not_allowed($show_headers); diff --git a/main/exercice/tests_category.php b/main/exercice/tests_category.php index 943fda4c0f..8517fc6070 100755 --- a/main/exercice/tests_category.php +++ b/main/exercice/tests_category.php @@ -28,7 +28,7 @@ $this_section = SECTION_COURSES; if (!api_is_allowed_to_edit()) { api_not_allowed(true); } -$category = new Testcategory(); +$category = new TestCategory(); $courseId = api_get_course_int_id(); $sessionId = api_get_session_id(); @@ -55,14 +55,14 @@ Display::display_footer(); // FUNCTIONS // form to edit a category /** - * @todo move to testcategory.class.php + * @todo move to TestCategory.class.php * @param string $in_action */ function edit_category_form($in_action) { $in_action = Security::remove_XSS($in_action); if (isset($_GET['category_id']) && is_numeric($_GET['category_id'])) { $category_id = Security::remove_XSS($_GET['category_id']); - $objcat = new Testcategory($category_id); + $objcat = new TestCategory($category_id); // initiate the object $form = new FormValidator('note', 'post', api_get_self() . '?action=' . $in_action . '&category_id=' . $category_id); @@ -71,7 +71,7 @@ function edit_category_form($in_action) { $form->addElement('header', get_lang('EditCategory')); $form->addElement('hidden', 'category_id'); $form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95')); - $form->addHtmlEditor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200')); + $form->addHtmlEditor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Height' => '200')); $form->addButtonSave(get_lang('ModifyCategory'), 'SubmitNote'); // setting the defaults @@ -92,7 +92,7 @@ function edit_category_form($in_action) { $v_id = Security::remove_XSS($values['category_id']); $v_name = Security::remove_XSS($values['category_name'], COURSEMANAGER); $v_description = Security::remove_XSS($values['category_description'], COURSEMANAGER); - $objcat = new Testcategory($v_id, $v_name, $v_description); + $objcat = new TestCategory($v_id, $v_name, $v_description); if ($objcat->modifyCategory()) { Display::display_confirmation_message(get_lang('MofidfyCategoryDone')); } else { @@ -116,7 +116,7 @@ function edit_category_form($in_action) { function delete_category_form($in_action) { if (isset($_GET['category_id']) && is_numeric($_GET['category_id'])) { $category_id = Security::remove_XSS($_GET['category_id']); - $catobject = new Testcategory($category_id); + $catobject = new TestCategory($category_id); if ($catobject->removeCategory()) { Display::display_confirmation_message(get_lang('DeleteCategoryDone')); } else { @@ -129,7 +129,7 @@ function delete_category_form($in_action) { /** * form to add a category - * @todo move to testcategory.class.php + * @todo move to TestCategory.class.php * @param string $in_action */ function add_category_form($in_action) { @@ -139,7 +139,7 @@ function add_category_form($in_action) { // Setting the form elements $form->addElement('header', get_lang('AddACategory')); $form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95')); - $form->addHtmlEditor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200')); + $form->addHtmlEditor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Height' => '200')); $form->addButtonCreate(get_lang('AddTestCategory'), 'SubmitNote'); // setting the rules $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required'); @@ -150,7 +150,7 @@ function add_category_form($in_action) { $values = $form->exportValues(); $v_name = Security::remove_XSS($values['category_name'], COURSEMANAGER); $v_description = Security::remove_XSS($values['category_description'], COURSEMANAGER); - $objcat = new Testcategory(0, $v_name, $v_description); + $objcat = new TestCategory(0, $v_name, $v_description); if ($objcat->addCategoryInBDD()) { Display::display_confirmation_message(get_lang('AddCategoryDone')); } else { diff --git a/main/exercice/unique_answer.class.php b/main/exercice/unique_answer.class.php index b772810f10..faf22cbf0f 100755 --- a/main/exercice/unique_answer.class.php +++ b/main/exercice/unique_answer.class.php @@ -20,10 +20,10 @@ class UniqueAnswer extends Question /** * Constructor */ - public function UniqueAnswer() + public function __construct() { //this is highly important - parent::question(); + parent::__construct(); $this->type = UNIQUE_ANSWER; $this->isContent = $this->getIsContent(); } @@ -266,26 +266,11 @@ class UniqueAnswer extends Question $buttonGroup = []; //ie6 fix if ($obj_ex->edit_exercise_in_lp == true) { - if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') { - $buttonGroup[] = $form->createElement( - 'submit', - 'lessAnswers', - get_lang('LessAnswer'), - 'class="btn btn-primary"' - ); - $buttonGroup[] = $form->createElement( - 'submit', - 'moreAnswers', - get_lang('PlusAnswer'), - 'class="btn btn-primary"' - ); - $buttonGroup[] = $form->createElement('submit', 'submitQuestion', $text, 'class="' . $class . '"'); - } else { - //setting the save button here and not in the question class.php - $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true); - $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true); - $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true); - } + + //setting the save button here and not in the question class.php + $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true); + $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true); + $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true); $form->addGroup($buttonGroup); } @@ -484,6 +469,13 @@ class UniqueAnswer extends Question '0@@0@@0@@0' )"; Database::query($sql); + + $id = Database::insert_id(); + if ($id) { + $sql = "UPDATE $tbl_quiz_answer SET id = iid WHERE iid = $id"; + Database::query($sql); + } + if ($correct) { $sql = "UPDATE $tbl_quiz_question SET ponderation = (ponderation + $score) diff --git a/main/exercice/unique_answer_no_option.class.php b/main/exercice/unique_answer_no_option.class.php index a2dd3b4dfd..f7266b5bd3 100755 --- a/main/exercice/unique_answer_no_option.class.php +++ b/main/exercice/unique_answer_no_option.class.php @@ -18,10 +18,10 @@ class UniqueAnswerNoOption extends Question /** * Constructor */ - function UniqueAnswerNoOption() + public function __construct() { //this is highly important - parent::question(); + parent::__construct(); $this -> type = UNIQUE_ANSWER_NO_OPTION; $this -> isContent = $this-> getIsContent(); } @@ -244,34 +244,24 @@ class UniqueAnswerNoOption extends Question $form->addElement('html_editor', 'answer[' . $i . ']', null, array(), $editor_config); $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required'); - - $form->addElement('html_editor', 'comment[' . $i . ']', null, array(), $editor_config); //$form->addElement('select', 'destination'.$i, get_lang('SelectQuestion').' : ',$select_question,'multiple'); $form->addText("weighting[$i]", null, false, ['value' => 0, 'readonly' => 'readonly']); - + $form->addHTml(''); $form->addHtml(''); - $navigator_info = api_get_navigator(); - $buttonGroup = []; global $text, $class; //ie6 fix if ($obj_ex->edit_exercise_in_lp == true) { - if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') { - $buttonGroup[] = $form->createElement('submit', 'moreAnswers',' '. get_lang('PlusAnswer'), 'class="btn btn-default"'); - $buttonGroup[] = $form->createElement('submit', 'lessAnswers', ' '.get_lang('LessAnswer'), 'class="btn btn-default"'); - $buttonGroup[] = $form->createElement('submit', 'submitQuestion', $text, 'class="' . $class . '"'); - } else { - //setting the save button here and not in the question class.php - $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true); - $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true); - $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true); - } + //setting the save button here and not in the question class.php + $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true); + $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true); + $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true); $form->addGroup($buttonGroup); } diff --git a/main/exercice/upload_exercise.php b/main/exercice/upload_exercise.php index efdec1ac59..e0f3b40b56 100755 --- a/main/exercice/upload_exercise.php +++ b/main/exercice/upload_exercise.php @@ -346,9 +346,6 @@ function lp_upload_quiz_action_handling() { } } - //var_dump($answerValue); - - if ($useCustomScore) { if ($correct) { $score = $correctScore; @@ -381,8 +378,6 @@ function lp_upload_quiz_action_handling() { $total += $score; $id++; - - //var_dump($score); } $objAnswer->save(); @@ -399,7 +394,6 @@ function lp_upload_quiz_action_handling() { $questionObj->updateWeighting($total); break; } - //var_dump($total); $questionObj->save(); } else if ($detectQuestionType === FREE_ANSWER) { @@ -410,7 +404,7 @@ function lp_upload_quiz_action_handling() { } } } - // exit; + if (isset($_SESSION['lpobject'])) { if ($debug > 0) { error_log('New LP - SESSION[lpobject] is defined', 0); @@ -452,21 +446,23 @@ function lp_upload_quiz_action_handling() { * @param array $answers_data * @return int */ -function detectQuestionType($answers_data) { +function detectQuestionType($answers_data) +{ $correct = 0; $isNumeric = false; - foreach ($answers_data as $answer_data) { - if (strtolower($answer_data[3]) == 'x') { - $correct++; - } else { - if (is_numeric($answer_data[3])) { - $isNumeric = true; + + if (!empty($answers_data)) { + foreach ($answers_data as $answer_data) { + if (strtolower($answer_data[3]) == 'x') { + $correct++; + } else { + if (is_numeric($answer_data[3])) { + $isNumeric = true; + } } } } - $type = ''; - if ($correct == 1) { $type = UNIQUE_ANSWER; } else if ($correct > 1) { diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 37325c4cbc..c6b84c5e2f 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -1,5 +1,6 @@ 0) { api_item_property_update( api_get_course_info(), @@ -701,6 +706,10 @@ function store_forum($values) Database::query($sql); $last_id = Database::insert_id(); if ($last_id > 0) { + + $sql = "UPDATE $table_forums SET forum_id = $last_id WHERE iid = $last_id"; + Database::query($sql); + api_item_property_update($_course, TOOL_FORUM, $last_id, 'ForumAdded', api_get_user_id(), $group_id); api_set_default_visibility($last_id, TOOL_FORUM, $group_id); } @@ -1239,7 +1248,7 @@ function get_forum_categories($id = '') $session_id = api_get_session_id(); $course_id = api_get_course_int_id(); - $condition_session = api_get_session_condition($session_id, true, true); + $condition_session = api_get_session_condition($session_id, true, true, 'forum_categories.session_id'); $condition_session .= " AND forum_categories.c_id = $course_id AND item_properties.c_id = $course_id"; if (empty($id)) { @@ -1311,7 +1320,7 @@ function get_forums_in_category($cat_id) item_properties.tool='".TOOL_FORUM."' AND forum.c_id = $course_id ORDER BY forum.forum_order ASC"; - if (is_allowed_to_edit()) { + if (api_is_allowed_to_edit()) { $sql = "SELECT * FROM ".$table_forums." forum , ".$table_item_property." item_properties WHERE forum.forum_category = '".Database::escape_string($cat_id)."' AND @@ -1368,7 +1377,7 @@ function get_forums( $session_id = $sessionId; } - $condition_session = api_get_session_condition($session_id, true, false, 'id_session'); + $condition_session = api_get_session_condition($session_id, true, false, 'item_properties.session_id'); $course_id = $course_info['real_id']; $forum_list = array(); @@ -1402,7 +1411,7 @@ function get_forums( ON ( threads.thread_id=item_properties.ref AND threads.c_id = item_properties.c_id AND - threads.session_id = item_properties.id_session + threads.session_id = item_properties.session_id ) WHERE item_properties.visibility=1 AND @@ -1418,7 +1427,7 @@ function get_forums( posts.visible=1 AND posts.thread_id=threads.thread_id AND threads.thread_id=item_properties.ref AND - threads.session_id = item_properties.id_session AND + threads.session_id = item_properties.session_id AND item_properties.visibility=1 AND item_properties.tool='".TOOL_FORUM_THREAD."' AND threads.c_id = $course_id AND @@ -1427,7 +1436,7 @@ function get_forums( GROUP BY threads.forum_id"; // Course Admin - if (is_allowed_to_edit()) { + if (api_is_allowed_to_edit()) { // Select all the forum information of all forums (that are not deleted). $sql = "SELECT * FROM ".$table_forums." forum INNER JOIN ".$table_item_property." item_properties @@ -1451,7 +1460,7 @@ function get_forums( ON ( threads.thread_id=item_properties.ref AND threads.c_id = item_properties.c_id AND - threads.session_id = item_properties.id_session + threads.session_id = item_properties.session_id ) WHERE item_properties.visibility<>2 AND @@ -1465,7 +1474,7 @@ function get_forums( WHERE posts.thread_id=threads.thread_id AND threads.thread_id=item_properties.ref AND - threads.session_id = item_properties.id_session AND + threads.session_id = item_properties.session_id AND item_properties.visibility=1 AND item_properties.tool='".TOOL_FORUM_THREAD."' AND posts.c_id = $course_id AND @@ -1512,7 +1521,13 @@ function get_forums( // Select the last post and the poster (note: this is probably no longer needed). $sql4 = "SELECT - post.post_id, post.forum_id, post.poster_id, post.poster_name, post.post_date, users.lastname, users.firstname + post.post_id, + post.forum_id, + post.poster_id, + post.poster_name, + post.post_date, + users.lastname, + users.firstname FROM $table_posts post, $table_users users WHERE forum_id = ".intval($id)." AND @@ -1738,7 +1753,7 @@ function get_threads($forum_id, $course_code = null) thread.forum_id = ".intval($forum_id)." ORDER BY thread.thread_sticky DESC, thread.thread_date DESC"; - if (is_allowed_to_edit()) { + if (api_is_allowed_to_edit()) { // important note: it might seem a little bit awkward that we have 'thread.locked as locked' in the sql statement // because we also have thread.* in it. This is because thread has a field locked and post also has the same field // since we are merging these we would have the post.locked value but in fact we want the thread.locked value @@ -1794,7 +1809,7 @@ function get_posts($thread_id) /* * INNER JOIN $tableItemProperty i ON i.ref = posts.post_id AND i.c_id = posts.c_id* - i.id_session = $sessionId + i.session_id = $sessionId */ if (api_is_allowed_to_edit(null, true)) { $sql = "SELECT * FROM $table_posts posts @@ -1840,7 +1855,7 @@ function get_post_information($post_id) $table_users = Database :: get_main_table(TABLE_MAIN_USER); $course_id = api_get_course_int_id(); - $sql = "SELECT * FROM ".$table_posts."posts, ".$table_users." users + $sql = "SELECT * FROM ".$table_posts." posts, ".$table_users." users WHERE c_id = $course_id AND posts.poster_id=users.user_id AND @@ -1915,13 +1930,13 @@ function get_thread_users_details($thread_id) $sql = "SELECT DISTINCT user.user_id, user.lastname, user.firstname, thread_id FROM $t_posts , $t_users user, $t_session_rel_user session_rel_user_rel_course WHERE poster_id = user.user_id AND - user.user_id = session_rel_user_rel_course.id_user AND + user.user_id = session_rel_user_rel_course.user_id AND session_rel_user_rel_course.status<>'2' AND - session_rel_user_rel_course.id_user NOT IN ($user_to_avoid) AND + session_rel_user_rel_course.user_id NOT IN ($user_to_avoid) AND thread_id = ".intval($thread_id)." AND - id_session = ".api_get_session_id()." AND + session_id = ".api_get_session_id()." AND c_id = $course_id AND - course_code = '".$course_code."' $orderby "; + session_rel_user_rel_course.c_id = '".$course_id."' $orderby "; } else { $sql = "SELECT DISTINCT user.user_id, user.lastname, user.firstname, thread_id FROM $t_posts , $t_users user, $t_course_user course_user @@ -1931,7 +1946,7 @@ function get_thread_users_details($thread_id) AND thread_id = ".intval($thread_id)." AND course_user.status NOT IN('1') AND c_id = $course_id AND - course_code = '".$course_code."' $orderby"; + session_rel_user_rel_course.c_id = '".$course_id."' $orderby"; } $result = Database::query($sql); @@ -1974,13 +1989,13 @@ function get_thread_users_qualify($thread_id) FROM $t_posts post , $t_users user, $t_session_rel_user session_rel_user_rel_course, $t_qualify qualify WHERE poster_id = user.user_id AND post.poster_id = qualify.user_id - AND user.user_id = session_rel_user_rel_course.id_user + AND user.user_id = session_rel_user_rel_course.user_id AND session_rel_user_rel_course.status<>'2' - AND session_rel_user_rel_course.id_user NOT IN ($user_to_avoid) + AND session_rel_user_rel_course.user_id NOT IN ($user_to_avoid) AND qualify.thread_id = '".Database::escape_string($thread_id)."' AND post.thread_id = '".Database::escape_string($thread_id)."' - AND id_session = '".api_get_session_id()."' - AND course_code = '".$course_code."' AND + AND session_id = '".api_get_session_id()."' + AND session_rel_user_rel_course.c_id = '".$course_id."' AND qualify.c_id = $course_id AND post.c_id = $course_id $orderby "; @@ -2054,12 +2069,12 @@ function get_thread_users_not_qualify($thread_id) FROM $t_posts post , $t_users user, $t_session_rel_user session_rel_user_rel_course WHERE poster_id = user.user_id AND user.user_id NOT IN (".$cad.") - AND user.user_id = session_rel_user_rel_course.id_user + AND user.user_id = session_rel_user_rel_course.user_id AND session_rel_user_rel_course.status<>'2' - AND session_rel_user_rel_course.id_user NOT IN ($user_to_avoid) + AND session_rel_user_rel_course.user_id NOT IN ($user_to_avoid) AND post.thread_id = '".Database::escape_string($thread_id)."' - AND id_session = '".api_get_session_id()."' - AND course_code = '".$course_code."' AND post.c_id = $course_id $orderby "; + AND session_id = '".api_get_session_id()."' + AND session_rel_user_rel_course.c_id = '".$course_id."' AND post.c_id = $course_id $orderby "; } else { $sql = "SELECT DISTINCT user.user_id, user.lastname, user.firstname, post.thread_id FROM $t_posts post, $t_users user,$t_course_user course_user @@ -2212,10 +2227,10 @@ function store_thread($current_forum, $values) '".Database::escape_string(stripslashes(isset($values['poster_name']) ? $values['poster_name'] : null))."', '".Database::escape_string($post_date)."', '".Database::escape_string(isset($values['thread_sticky']) ? $values['thread_sticky'] : null)."',". - "'".Database::escape_string(stripslashes($values['calification_notebook_title']))."',". - "'".Database::escape_string($values['numeric_calification'])."',". - "'".Database::escape_string($values['weight_calification'])."',". - "'".api_get_session_id()."')"; + "'".Database::escape_string(stripslashes($values['calification_notebook_title']))."',". + "'".Database::escape_string($values['numeric_calification'])."',". + "'".Database::escape_string($values['weight_calification'])."',". + "'".api_get_session_id()."')"; Database::query($sql); $last_thread_id = Database::insert_id(); @@ -2245,6 +2260,10 @@ function store_thread($current_forum, $values) } if ($last_thread_id) { + + $sql = "UPDATE $table_threads SET thread_id = $last_thread_id WHERE iid = $last_thread_id"; + Database::query($sql); + api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id, 'ForumThreadAdded', api_get_user_id()); // If the forum properties tell that the posts have to be approved we have to put the whole thread invisible, // because otherwise the students will see the thread and not the post in the thread. @@ -2275,6 +2294,11 @@ function store_thread($current_forum, $values) Database::query($sql); $last_post_id = Database::insert_id(); + if ($last_post_id) { + $sql = "UPDATE $table_posts SET post_id = $last_post_id WHERE iid = $last_post_id"; + Database::query($sql); + } + // Update attached files if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) { foreach ($_POST['file_ids'] as $key => $id) { @@ -2526,14 +2550,19 @@ function store_theme_qualify($user_id, $thread_id, $thread_qualify = 0, $qualify $course_id = api_get_course_int_id(); - if ($user_id == strval(intval($user_id)) && $thread_id == strval(intval($thread_id)) && $thread_qualify == strval(floatval($thread_qualify))) { + if ($user_id == strval(intval($user_id)) && + $thread_id == strval(intval($thread_id)) && + $thread_qualify == strval(floatval($thread_qualify)) + ) { // Testing - $sql_string = "SELECT thread_qualify_max FROM ".$table_threads." WHERE c_id = $course_id AND thread_id=".$thread_id.";"; + $sql_string = "SELECT thread_qualify_max FROM ".$table_threads." + WHERE c_id = $course_id AND thread_id=".$thread_id.";"; $res_string = Database::query($sql_string); $row_string = Database::fetch_array($res_string); if ($thread_qualify <= $row_string[0]) { - $sql1 = "SELECT COUNT(*) FROM ".$table_threads_qualify." WHERE c_id = $course_id AND user_id=".$user_id." and thread_id=".$thread_id.";"; + $sql1 = "SELECT COUNT(*) FROM ".$table_threads_qualify." + WHERE c_id = $course_id AND user_id=".$user_id." and thread_id=".$thread_id.";"; $res1 = Database::query($sql1); $row = Database::fetch_array($res1); @@ -2542,6 +2571,10 @@ function store_theme_qualify($user_id, $thread_id, $thread_qualify = 0, $qualify VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float) $thread_qualify.", '".$qualify_user_id."','".$qualify_time."','".$session_id."')"; $res = Database::query($sql); + $insertId = Database::insert_id(); + $sql = "UPDATE $table_threads_qualify SET id = iid WHERE iid = $insertId"; + Database::query($sql); + return $res; } else { $sql1 = "SELECT qualify FROM ".$table_threads_qualify." WHERE c_id = $course_id AND user_id=".$user_id." and thread_id=".$thread_id.";"; @@ -2673,6 +2706,10 @@ function store_qualify_historical( VALUES(".$course_id.", '".$user_id."','".$thread_id."',".(float) $row[0].", '".$qualify_user_id."','".$row[1]."','')"; Database::query($sql1); + $insertId = Database::insert_id(); + $sql = "UPDATE $table_threads_qualify_log SET id = iid WHERE iid = $insertId"; + Database::query($sql); + // Update $sql2 = "UPDATE ".$table_threads_qualify." SET qualify=".$current_qualify.",qualify_time='".$current_date."' @@ -3048,7 +3085,9 @@ function store_edit_post($values) function display_user_link($user_id, $name, $origin = '', $in_title = '') { if ($user_id != 0) { - return ''.$name.''; + $userInfo = api_get_user_info($user_id); + + return ''.Security::remove_XSS($userInfo['complete_name']).''; } else { return $name.' ('.get_lang('Anonymous').')'; } @@ -3063,7 +3102,8 @@ function display_user_link($user_id, $name, $origin = '', $in_title = '') */ function display_user_image($user_id, $name, $origin = '') { - $link = ''; + $userInfo = api_get_user_info($user_id); + $link = ''; if ($user_id != 0) { $image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true); $friends_profile = UserManager::get_picture_user($user_id, $image_path['file'], 0, USER_IMAGE_SIZE_MEDIUM, 'width="96" height="96" '); @@ -3839,7 +3879,7 @@ function display_forum_search_results($search_term) AND posts.thread_id = threads.thread_id AND item_property.ref = threads.thread_id AND item_property.visibility = 1 - AND item_property.id_session = $session_id + AND item_property.session_id = $session_id AND posts.visible = 1 AND item_property.tool = '".TOOL_FORUM_THREAD."' AND ".implode(' AND ', $search_restriction)." @@ -4187,7 +4227,7 @@ function get_forums_of_group($group_id) GROUP BY threads.forum_id"; // Course Admin - if (is_allowed_to_edit()) { + if (api_is_allowed_to_edit()) { // Select all the forum information of all forums (that are not deleted). $sql = "SELECT * FROM ".$table_forums." forum , ".$table_item_property." item_properties @@ -4249,7 +4289,7 @@ function get_forums_of_group($group_id) // Finding the last post information (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname). if (!empty($forum_list)) { foreach ($forum_list as $key => $value) { - $last_post_info_of_forum = get_last_post_information($key, is_allowed_to_edit()); + $last_post_info_of_forum = get_last_post_information($key, api_is_allowed_to_edit()); $forum_list[$key]['last_post_id'] = $last_post_info_of_forum['last_post_id']; $forum_list[$key]['last_poster_id'] = $last_post_info_of_forum['last_poster_id']; $forum_list[$key]['last_post_date'] = $last_post_info_of_forum['last_post_date']; diff --git a/main/forum/viewforum.php b/main/forum/viewforum.php index 4d39f048d1..78ebdf1d26 100755 --- a/main/forum/viewforum.php +++ b/main/forum/viewforum.php @@ -22,7 +22,7 @@ * @package chamilo.forum */ -use \ChamiloSession as Session; +use ChamiloSession as Session; // Including the global initialization file. require_once '../inc/global.inc.php'; @@ -165,7 +165,11 @@ if ($my_action == 'notify' AND isset($_GET['content']) AND isset($_GET['id']) && // Student list -if ($my_action == 'liststd' AND isset($_GET['content']) AND isset($_GET['id']) AND (api_is_allowed_to_edit(null, true) || $is_group_tutor)) { +if ($my_action == 'liststd' && + isset($_GET['content']) && + isset($_GET['id']) && + (api_is_allowed_to_edit(null, true) || $is_group_tutor) +) { $active = null; switch ($_GET['list']) { case 'qualify': @@ -223,15 +227,16 @@ if ($my_action == 'liststd' AND isset($_GET['content']) AND isset($_GET['id']) A if (Database::num_rows($student_list) > 0) { while ($row_student_list=Database::fetch_array($student_list)) { + $userInfo = api_get_user_info($row_student_list['user_id']); if ($counter_stdlist % 2 == 0) { $class_stdlist = 'row_odd'; } else { $class_stdlist = 'row_even'; } - $name_user_theme = api_get_person_name($row_student_list['firstname'], $row_student_list['lastname']); - $table_list .= ' - - '.$name_user_theme.''; + $table_list .= ''; + $table_list .= UserManager::getUserProfileLink($userInfo); + + $table_list .= ''; if ($_GET['list'] == 'qualify') { $table_list .= ''.$row_student_list['qualify'].'/'.$max_qualify.''; } @@ -381,7 +386,7 @@ if (is_array($threads)) { echo ''.Display::tag('span', api_get_person_name($row['firstname'], $row['lastname']), array("title"=>api_htmlentities($poster_username, ENT_QUOTES))).''; } - $last_post_info = get_last_post_by_thread($row['c_id'], $row['thread_id'], $row['forum_id'], is_allowed_to_edit()); + $last_post_info = get_last_post_by_thread($row['c_id'], $row['thread_id'], $row['forum_id'], api_is_allowed_to_edit()); $last_post = null; if ($last_post_info) { diff --git a/main/forum/viewthread_flat.inc.php b/main/forum/viewthread_flat.inc.php index 16ec6d71e0..5e0de98e97 100755 --- a/main/forum/viewthread_flat.inc.php +++ b/main/forum/viewthread_flat.inc.php @@ -56,7 +56,11 @@ if (isset($current_thread['thread_id'])) { $id_attach = !empty($attachment_list)?$attachment_list['id']:''; // The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum // The course admin him/herself can do this off course always - if ( GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) OR ($current_forum['allow_edit']==1 AND $row['user_id']==$_user['user_id']) or (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session']))) { + if ( + GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) || + ($current_forum['allow_edit']==1 AND $row['user_id']==$_user['user_id']) || + (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) + ) { if (api_is_allowed_to_session_edit(false,true)) { if ($locked == false) { echo "".Display::return_icon('edit.png',get_lang('Edit'), array(), ICON_SIZE_SMALL).""; @@ -65,7 +69,7 @@ if (isset($current_thread['thread_id'])) { } if ($origin != 'learnpath') { - if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) OR api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) { + if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) || api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) { if ($locked == false) { echo "".Display::return_icon('delete.png', get_lang('Delete'),array(), ICON_SIZE_SMALL).""; } @@ -79,7 +83,7 @@ if (isset($current_thread['thread_id'])) { } } - $user_status = api_get_status_of_user_in_course($row['user_id'], api_get_course_id()); + $user_status = api_get_status_of_user_in_course($row['user_id'], api_get_course_int_id()); $current_qualify_thread = show_qualify('1', $row['poster_id'],$_GET['thread']); if (api_is_allowed_to_edit(null,true) && $origin != 'learnpath') { @@ -94,8 +98,10 @@ if (isset($current_thread['thread_id'])) { } } - if (($current_forum_category && $current_forum_category['locked']==0) AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit(false,true)) { - if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) { + if (($current_forum_category && $current_forum_category['locked']==0) && + $current_forum['locked']==0 && $current_thread['locked']==0 || api_is_allowed_to_edit(false,true) + ) { + if ($_user['user_id'] || ($current_forum['allow_anonymous']==1 && !$_user['user_id'])) { if (!api_is_anonymous() && api_is_allowed_to_session_edit(false,true)) { echo ''.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage')).""; echo ''.Display :: return_icon('quote.gif', get_lang('QuoteMessage')).""; @@ -114,12 +120,12 @@ if (isset($current_thread['thread_id'])) { } echo ""; // prepare the notification icon - if (isset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) and !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) and !empty($whatsnew_post_info[$_GET['forum']][$row['thread_id']])) { + if (isset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) && !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) and !empty($whatsnew_post_info[$_GET['forum']][$row['thread_id']])) { $post_image=Display::return_icon('forumpostnew.gif'); } else { $post_image=Display::return_icon('forumpost.gif'); } - if ($row['post_notification']=='1' AND $row['poster_id']==$_user['user_id']) { + if ($row['post_notification']=='1' && $row['poster_id']==$_user['user_id']) { $post_image.=Display::return_icon('forumnotification.gif',get_lang('YouWillBeNotified')); } // The post title @@ -151,7 +157,9 @@ if (isset($current_thread['thread_id'])) { echo Display::return_icon('attachment.gif',get_lang('Attachment')); echo ' '.$user_filename.' '; - if (($current_forum['allow_edit']==1 AND $row['user_id']==$_user['user_id']) or (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session']))) { + if (($current_forum['allow_edit']==1 && $row['user_id']==$_user['user_id']) || + (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) + ) { echo '  '.Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL).'
'; } echo ''.$attachment['comment'].''; diff --git a/main/forum/viewthread_nested.inc.php b/main/forum/viewthread_nested.inc.php index 2d8d78987d..7368c25560 100755 --- a/main/forum/viewthread_nested.inc.php +++ b/main/forum/viewthread_nested.inc.php @@ -92,7 +92,7 @@ foreach ($rows as $post) { } $userinf = api_get_user_info($post['user_id']); - $user_status = api_get_status_of_user_in_course($post['user_id'],api_get_course_id()); + $user_status = api_get_status_of_user_in_course($post['user_id'], api_get_course_int_id()); if (api_is_allowed_to_edit(null,true)) { //if ($count>0 && $user_status!=1) { if ($count>0) { diff --git a/main/forum/viewthread_threaded.inc.php b/main/forum/viewthread_threaded.inc.php index 3c28796d59..3904d6b712 100755 --- a/main/forum/viewthread_threaded.inc.php +++ b/main/forum/viewthread_threaded.inc.php @@ -313,7 +313,7 @@ if ( $userinf = api_get_user_info($rows[$display_post_id]['user_id']); $user_status = api_get_status_of_user_in_course( $rows[$display_post_id]['user_id'], - api_get_course_id() + api_get_course_int_id() ); if (api_is_allowed_to_edit(null, true)) { if ($post_id > $post_minor) { diff --git a/main/glossary/index.php b/main/glossary/index.php index 6e6f03bed2..fe6b480ef1 100755 --- a/main/glossary/index.php +++ b/main/glossary/index.php @@ -75,7 +75,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'export') { $list[] = array ($line[0], $line[1]); } $filename = 'glossary_course_'.api_get_course_id(); - Export::export_table_csv_utf8($list, $filename); + Export::arrayToCsv($list, $filename); } if (isset($_GET['action']) && $_GET['action'] == 'export_to_pdf') { GlossaryManager::export_to_pdf(); @@ -212,7 +212,7 @@ if (api_is_allowed_to_edit(null, true)) { } } } - //$data = Import::csv_to_array($_FILES['file']['tmp_name']); + //$data = Import::csvToArray($_FILES['file']['tmp_name']); $data = Import::csv_reader($_FILES['file']['tmp_name']); $good = 0; $bad = 0; diff --git a/main/gradebook/gradebook_view_result.php b/main/gradebook/gradebook_view_result.php index 0ebb994897..22a7e1cc2f 100755 --- a/main/gradebook/gradebook_view_result.php +++ b/main/gradebook/gradebook_view_result.php @@ -107,7 +107,7 @@ if (isset($_GET['import'])) { $file_type = $_POST['file_type']; $file_name = $_FILES['import_file']['tmp_name']; if ($file_type == 'csv') { - $results = Import :: csv_to_array($file_name); + $results = Import :: csvToArray($file_name); } else { $results = parse_xml_data($file_name); } @@ -328,11 +328,11 @@ if (isset($_GET['export'])) { switch ($file_type) { case 'xml' : - Export :: export_table_xml($alldata, $filename, 'Result', 'XMLResults'); + Export :: arrayToXml($alldata, $filename, 'Result', 'XMLResults'); exit; break; case 'csv' : - Export :: export_table_csv($alldata, $filename); + Export :: arrayToCsv($alldata, $filename); exit; break; } diff --git a/main/gradebook/lib/GradebookUtils.php b/main/gradebook/lib/GradebookUtils.php index 8330957ac4..da75c3f7d2 100644 --- a/main/gradebook/lib/GradebookUtils.php +++ b/main/gradebook/lib/GradebookUtils.php @@ -942,9 +942,9 @@ class GradebookUtils /** * returns users within a course given by param - * @param int $course_id + * @param string $courseCode */ - public static function get_users_in_course($course_id) + public static function get_users_in_course($courseCode) { $tbl_course_user = Database:: get_main_table(TABLE_MAIN_COURSE_USER); $tbl_session_course_user = Database:: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); @@ -952,16 +952,18 @@ class GradebookUtils $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname ASC' : ' ORDER BY lastname, firstname ASC'; $current_session = api_get_session_id(); - $course_id = Database::escape_string($course_id); + $courseCode = Database::escape_string($courseCode); + $courseInfo = api_get_course_info($courseCode); + $courseId = $courseInfo['real_id']; if (!empty($current_session)) { $sql = "SELECT user.user_id, user.username, lastname, firstname, official_code FROM $tbl_session_course_user as scru, $tbl_user as user WHERE - scru.id_user=user.user_id AND + scru.user_id = user.user_id AND scru.status=0 AND - scru.course_code='$course_id' AND - id_session ='$current_session' + scru.c_id='$courseId' AND + session_id ='$current_session' $order_clause "; } else { @@ -970,8 +972,8 @@ class GradebookUtils WHERE course_rel_user.user_id=user.user_id AND course_rel_user.status='.STUDENT.' AND - course_rel_user.course_code = "'.$course_id.'" '. - $order_clause; + course_rel_user.c_id = "'.$courseId.'" '. + $order_clause; } $result = Database::query($sql); @@ -1082,8 +1084,8 @@ class GradebookUtils if (!api_is_platform_admin()) { $sql .= ' AND user.user_id = cru.user_id AND cru.relation_type <> '.COURSE_RELATION_TYPE_RRHH.' AND - cru.course_code in ( - SELECT course_code FROM '.$tbl_cru . ' + cru.c_id in ( + SELECT c_id FROM '.$tbl_cru . ' WHERE user_id = ' . api_get_user_id() . ' AND status = ' . COURSEMANAGER . ' diff --git a/main/gradebook/lib/be/category.class.php b/main/gradebook/lib/be/category.class.php index e20546304f..00e1af6361 100755 --- a/main/gradebook/lib/be/category.class.php +++ b/main/gradebook/lib/be/category.class.php @@ -775,13 +775,14 @@ class Category implements GradebookItem if (api_is_allowed_to_edit()) { $parent = Category::load($parent); $code = $parent[0]->get_course_code(); + $courseInfo = api_get_course_info($code); + $courseId = $courseInfo['real_id']; if (isset($code) && $code != '0') { $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - $sql .= ' AND user_id IN (' - .' SELECT user_id FROM '.$main_course_user_table - ." WHERE course_code = '".Database::escape_string($code)."'" - .' AND status = '.COURSEMANAGER - .')'; + $sql .= ' AND user_id IN ( + SELECT user_id FROM '.$main_course_user_table.' + WHERE c_id = '.$courseId.' AND status = '.COURSEMANAGER.' + )'; } else { $sql .= ' AND user_id = '.api_get_user_id(); } @@ -994,11 +995,11 @@ class Category implements GradebookItem public function get_root_categories_for_student($stud_id, $course_code = null, $session_id = null) { $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); + $courseTable = Database :: get_main_table(TABLE_MAIN_COURSE); $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); - $sql = 'SELECT *' - .' FROM '.$tbl_grade_categories - .' WHERE parent_id = 0'; + $sql = "SELECT * FROM $tbl_grade_categories WHERE parent_id = 0"; + if (!api_is_allowed_to_edit()) { $sql .= ' AND visible = 1'; //proceed with checks on optional parameters course & session @@ -1008,20 +1009,20 @@ class Category implements GradebookItem // session, we don't check his registration to these, but this // could be an improvement if (!empty($session_id)) { - $sql .= " AND course_code = '".Database::escape_string($course_code)."'" - ." AND session_id = ".(int)$session_id; + $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id = ".(int)$session_id; } else { - $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND - session_id is null OR session_id=0"; + $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id is null OR session_id=0"; } } else { //no optional parameter, proceed as usual - $sql .= ' AND course_code in' - .' (SELECT course_code' - .' FROM '.$main_course_user_table - .' WHERE user_id = '.intval($stud_id) - .' AND status = '.STUDENT - .')'; + $sql .= ' AND course_code in + ( + SELECT c.code + FROM '.$main_course_user_table.' cu INNER JOIN '.$courseTable.' c + ON (cu.c_id = c.id) + WHERE cu.user_id = '.intval($stud_id).' + AND cu.status = '.STUDENT.' + )'; } } elseif (api_is_allowed_to_edit() && !api_is_platform_admin()) { //proceed with checks on optional parameters course & session @@ -1037,12 +1038,15 @@ class Category implements GradebookItem $sql .="AND session_id IS NULL OR session_id=0"; } } else { - $sql .= ' AND course_code in' - .' (SELECT course_code' - .' FROM '.$main_course_user_table - .' WHERE user_id = '.api_get_user_id() - .' AND status = '.COURSEMANAGER - .')'; + $sql .= ' AND course_code IN + ( + SELECT c.code + FROM '.$main_course_user_table.' cu INNER JOIN '.$courseTable.' c + ON (cu.c_id = c.id) + WHERE + cu.user_id = '.api_get_user_id().' AND + cu.status = '.COURSEMANAGER.' + )'; } }elseif (api_is_platform_admin()) { if (isset($session_id) && $session_id!=0) { @@ -1068,29 +1072,32 @@ class Category implements GradebookItem * @param string course code (optional) * @param int session id (optional) */ - public function get_root_categories_for_teacher ($user_id, $course_code = null, $session_id = null) + public function get_root_categories_for_teacher($user_id, $course_code = null, $session_id = null) { if ($user_id == null) { return Category::load(null,null,$course_code,0,null,$session_id); } + $courseTable = Database :: get_main_table(TABLE_MAIN_COURSE); $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); - $sql = 'SELECT *' - .' FROM '.$tbl_grade_categories - .' WHERE parent_id = 0'; + $sql = 'SELECT * FROM '.$tbl_grade_categories.' + WHERE parent_id = 0'; if (!empty($course_code)) { $sql .= " AND course_code = '".Database::escape_string($course_code)."' "; if (!empty($session_id)) { $sql .= " AND session_id = ".(int)$session_id; } } else { - $sql .= ' AND course_code in' - .' (SELECT course_code' - .' FROM '.$main_course_user_table - .' WHERE user_id = '.intval($user_id) - .')'; + $sql .= ' AND course_code in + ( + SELECT c.code + FROM '.$main_course_user_table.' cu + INNER JOIN '.$courseTable.' c + ON (cu.c_id = c.id) + WHERE user_id = '.intval($user_id).' + )'; } $result = Database::query($sql); $cats = Category::create_category_objects_from_sql_result($result); @@ -1099,6 +1106,7 @@ class Category implements GradebookItem $indcats = Category::load(null,$user_id,$course_code,0,null,$session_id); $cats = array_merge($cats, $indcats); } + return $cats; } @@ -1285,17 +1293,20 @@ class Category implements GradebookItem $tbl_main_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); - $sql = 'SELECT DISTINCT(code), title FROM '.$tbl_main_courses.' cc, '.$tbl_main_course_user.' cu' - .' WHERE cc.code = cu.course_code' + $sql = 'SELECT DISTINCT(code), title + FROM '.$tbl_main_courses.' cc, '.$tbl_main_course_user.' cu' + .' WHERE cc.id = cu.c_id ' .' AND cu.status = '.COURSEMANAGER; if (!api_is_platform_admin()) { $sql .= ' AND cu.user_id = '.$user_id; } - $sql .= ' AND cc.code NOT IN' - .' (SELECT course_code FROM '.$tbl_grade_categories - .' WHERE parent_id = 0' -// .' AND user_id = '.$user_id - .' AND course_code IS NOT null)'; + $sql .= ' AND cc.code NOT IN + ( + SELECT course_code FROM '.$tbl_grade_categories.' + WHERE + parent_id = 0 AND + course_code IS NOT NULL + )'; $result = Database::query($sql); $cats=array(); @@ -1314,16 +1325,16 @@ class Category implements GradebookItem { $tbl_main_courses = Database :: get_main_table(TABLE_MAIN_COURSE); $tbl_main_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - $sql = 'SELECT DISTINCT(code), title FROM '.$tbl_main_courses.' cc, '.$tbl_main_course_user.' cu' - .' WHERE cc.code = cu.course_code' - .' AND cu.status = '.COURSEMANAGER; + $sql = 'SELECT DISTINCT(code), title + FROM '.$tbl_main_courses.' cc, '.$tbl_main_course_user.' cu + WHERE cc.id = cu.c_id AND cu.status = '.COURSEMANAGER; if (!api_is_platform_admin()) { $sql .= ' AND cu.user_id = '.intval($user_id); } $result = Database::query($sql); $cats = array(); - while ($data=Database::fetch_array($result)) { + while ($data = Database::fetch_array($result)) { $cats[] = array ($data['code'], $data['title']); } diff --git a/main/gradebook/lib/be/evaluation.class.php b/main/gradebook/lib/be/evaluation.class.php index bb3977dd84..5db1937e2e 100755 --- a/main/gradebook/lib/be/evaluation.class.php +++ b/main/gradebook/lib/be/evaluation.class.php @@ -441,13 +441,17 @@ class Evaluation implements GradebookItem if (api_is_allowed_to_edit()) { $parent = Category::load($parent); $code = $parent[0]->get_course_code(); + $courseInfo = api_get_course_info($code); + $courseId = $courseInfo['real_id']; + if (isset($code) && $code != '0') { $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - $sql .= ' AND user_id IN (' - .' SELECT user_id FROM '.$main_course_user_table - ." WHERE course_code = '".Database::escape_string($code)."'" - .' AND status = '.COURSEMANAGER - .')'; + $sql .= ' AND user_id IN ( + SELECT user_id FROM '.$main_course_user_table.' + WHERE + c_id = '.$courseId.' AND + status = '.COURSEMANAGER.' + )'; } else { $sql .= ' AND user_id = '.api_get_user_id(); } @@ -463,6 +467,7 @@ class Evaluation implements GradebookItem } $result = Database::query($sql); $number=Database::fetch_row($result); + return $number[0] != 0; } diff --git a/main/gradebook/lib/be/exerciselink.class.php b/main/gradebook/lib/be/exerciselink.class.php index 2cba61984a..ff3c0c231d 100755 --- a/main/gradebook/lib/be/exerciselink.class.php +++ b/main/gradebook/lib/be/exerciselink.class.php @@ -198,7 +198,7 @@ class ExerciseLink extends AbstractLink $exercise->read($this->get_ref_id()); if (!$this->is_hp) { - + if ($exercise->exercise_was_added_in_lp == false) { $sql = "SELECT * FROM $tblStats WHERE @@ -304,8 +304,11 @@ class ExerciseLink extends AbstractLink //status student $user_id = api_get_user_id(); $course_code = $this->get_course_code(); - $status_user=api_get_status_of_user_in_course ($user_id, $course_code); - $session_id =api_get_session_id(); + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + + $status_user = api_get_status_of_user_in_course($user_id, $courseId); + $session_id = api_get_session_id(); $url = api_get_path(WEB_CODE_PATH).'gradebook/exercise_jump.php?session_id='.$session_id.'&cidReq='.$this->get_course_code().'&gradebook=view&exerciseId='.$this->get_ref_id().'&type='.$this->get_type(); if ((!api_is_allowed_to_edit() && $this->calc_score(api_get_user_id()) == null) || $status_user!=1) { diff --git a/main/gradebook/lib/be/result.class.php b/main/gradebook/lib/be/result.class.php index 25a656261f..0fae4f85b4 100755 --- a/main/gradebook/lib/be/result.class.php +++ b/main/gradebook/lib/be/result.class.php @@ -98,16 +98,16 @@ class Result $sql_course_rel_user = ''; if ($sessionId) { - $sql = 'SELECT course_code, id_user as user_id, status + $sql = 'SELECT c_id, user_id as user_id, status FROM ' . $tbl_session_rel_course_user . ' WHERE - status=0 AND - course_code="' . api_get_course_id() . '" AND - id_session=' . $sessionId; + status= 0 AND + c_id = "' . api_get_course_int_id() . '" AND + session_id = ' . $sessionId; } else { - $sql = 'SELECT course_code,user_id,status + $sql = 'SELECT c_id, user_id, status FROM ' . $tbl_course_rel_course . ' - WHERE status ="' . STUDENT . '" AND course_code="' . api_get_course_id() . '" '; + WHERE status ="' . STUDENT . '" AND c_id = "' . api_get_course_int_id() . '" '; } $res_course_rel_user = Database::query($sql); @@ -128,7 +128,7 @@ class Result if ($info_verified == 0) { $sql_insert = 'INSERT INTO ' . $tbl_grade_results . '(user_id,evaluation_id,created_at,score) VALUES ("' . intval($list_user_course_list[$i]['user_id']) . '","' . intval($evaluation_id) . '","' . $current_date . '",0);'; - $res_insert = Database::query($sql_insert); + Database::query($sql_insert); } } $list_user_course_list = array(); diff --git a/main/gradebook/lib/fe/displaygradebook.php b/main/gradebook/lib/fe/displaygradebook.php index e98e7481ae..a0620eac59 100755 --- a/main/gradebook/lib/fe/displaygradebook.php +++ b/main/gradebook/lib/fe/displaygradebook.php @@ -303,7 +303,10 @@ class DisplayGradebook $my_category = $catobj->shows_all_information_an_category($catobj->get_id()); $user_id = api_get_user_id(); $course_code = $my_category['course_code']; - $status_user = api_get_status_of_user_in_course($user_id, $course_code); + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + + $status_user = api_get_status_of_user_in_course($user_id, $courseId); //$header .= '' . get_lang('AddGradebook') . ''; @@ -396,6 +399,7 @@ class DisplayGradebook $userId = api_get_user_id(); $courseCode = api_get_course_id(); + $courseId = api_get_course_int_id(); $sessionId = api_get_session_id(); // Student. @@ -404,7 +408,7 @@ class DisplayGradebook if (!empty($sessionId)) { $sessionStatus = SessionManager::get_user_status_in_course_session( $userId, - $courseCode, + $courseId, $sessionId ); } @@ -536,9 +540,6 @@ class DisplayGradebook $user_id = api_get_user_id(); $my_api_cidreq = api_get_cidreq(); - //$course_code = $my_category['course_code']; - //$status_user = api_get_status_of_user_in_course ($user_id,$course_code); - if (api_is_allowed_to_edit(null, true)) { if (empty($grade_model_id) || $grade_model_id == -1) { $header .= '' . diff --git a/main/gradebook/lib/fe/gradebooktable.class.php b/main/gradebook/lib/fe/gradebooktable.class.php index 7935e9fb9c..abd74a6d2d 100755 --- a/main/gradebook/lib/fe/gradebooktable.class.php +++ b/main/gradebook/lib/fe/gradebooktable.class.php @@ -149,7 +149,7 @@ class GradebookTable extends SortableTable $user_id = api_get_user_id(); $course_code = api_get_course_id(); $session_id = api_get_session_id(); - $status_user = api_get_status_of_user_in_course($user_id, $course_code); + $status_user = api_get_status_of_user_in_course($user_id, api_get_course_int_id()); if (empty($session_id)) { $statusToFilter = STUDENT; diff --git a/main/gradebook/lib/gradebook_data_generator.class.php b/main/gradebook/lib/gradebook_data_generator.class.php index a80e27fcea..07ddc3376e 100755 --- a/main/gradebook/lib/gradebook_data_generator.class.php +++ b/main/gradebook/lib/gradebook_data_generator.class.php @@ -115,7 +115,7 @@ class GradebookDataGenerator $userId = api_get_user_id(); $course_code = api_get_course_id(); $sessionId = api_get_session_id(); - $status_user = api_get_status_of_user_in_course($userId, $course_code); + $status_user = api_get_status_of_user_in_course($userId, api_get_course_int_id()); if (empty($sessionId)) { $statusToFilter = STUDENT; diff --git a/main/gradebook/gradebook_result.class.php b/main/gradebook/lib/gradebook_result.class.php old mode 100755 new mode 100644 similarity index 94% rename from main/gradebook/gradebook_result.class.php rename to main/gradebook/lib/gradebook_result.class.php index c525c637c5..b1dfa8ba7a --- a/main/gradebook/gradebook_result.class.php +++ b/main/gradebook/lib/gradebook_result.class.php @@ -14,7 +14,7 @@ class GradeBookResult /** * constructor of the class */ - public function GradeBookResult($get_questions=false,$get_answers=false) + public function __construct($get_questions=false,$get_answers=false) { //nothing to do /* @@ -35,12 +35,13 @@ class GradeBookResult * @param boolean Whether to get only visible exercises (true) or all of them (false). Defaults to false. * @return array A list of exercises available */ - private function _readGradebookList($only_visible = false) { + private function _readGradebookList($only_visible = false) + { $return = array(); - $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); + $TBL_EXERCISES= Database::get_course_table(TABLE_QUIZ_TEST); - $sql="SELECT id,title,type,random,active FROM $TBL_EXERCISES"; - if($only_visible) { + $sql = "SELECT id,title,type,random,active FROM $TBL_EXERCISES"; + if ($only_visible) { $sql.= ' WHERE active=1'; } $sql .= ' ORDER BY title'; @@ -58,7 +59,8 @@ class GradeBookResult * Gets the questions related to one exercise * @param integer Exercise ID */ - private function _readGradeBookQuestionsList($e_id) { + private function _readGradeBookQuestionsList($e_id) + { $return = array(); $TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); @@ -77,14 +79,18 @@ class GradeBookResult while($row=Database::fetch_array($result,'ASSOC')) { $return[] = $row; } + return true; } + /** * Gets the results of all students (or just one student if access is limited) * @param string The document path (for HotPotatoes retrieval) - * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null + * @param integer User ID. Optional. If no user ID is provided, + * we take all the results. Defauts to null */ - function _getGradeBookReporting($document_path,$user_id=null) { + public function _getGradeBookReporting($document_path, $user_id = null) + { $return = array(); $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); $TBL_USER = Database::get_main_table(TABLE_MAIN_USER); @@ -125,12 +131,12 @@ class GradeBookResult ORDER BY c_id ASC, exe_date ASC"; } - $results=StatsUtils::getManyResultsXCol($sql,8); - $hpresults=StatsUtils::getManyResultsXCol($hpsql,7); + $results = StatsUtils::getManyResultsXCol($sql, 8); + $hpresults = StatsUtils::getManyResultsXCol($hpsql, 7); $NoTestRes = 0; $NoHPTestRes = 0; - $j=0; + $j = 0; //Print the results of tests if (is_array($results)) { for ($i = 0; $i < sizeof($results); $i++) { diff --git a/main/group/group_creation.php b/main/group/group_creation.php index 26ca6d156e..c2e98af60d 100755 --- a/main/group/group_creation.php +++ b/main/group/group_creation.php @@ -50,12 +50,6 @@ if (isset($_POST['action'])) { header('Location: group.php?action=show_msg&msg='.$msg); exit; break; - case 'create_virtual_groups': - $ids = GroupManager::create_groups_from_virtual_courses(); - $msg = urlencode(count($ids).' '.get_lang('GroupsAdded')); - header('Location: group.php?action=show_msg&msg='.$msg); - exit; - break; case 'create_subgroups': GroupManager::create_subgroups($_POST['base_group'], $_POST['number_of_groups']); $msg = urlencode($_POST['number_of_groups'].' '.get_lang('GroupsAdded')); diff --git a/main/group/group_overview.php b/main/group/group_overview.php index d8f8576afb..b7849cb35a 100755 --- a/main/group/group_overview.php +++ b/main/group/group_overview.php @@ -34,7 +34,7 @@ if (isset($_GET['action'])) { switch ($_GET['action']) { case 'export_all': $data = GroupManager::exportCategoriesAndGroupsToArray(null, true); - Export::export_table_csv($data); + Export::arrayToCsv($data); exit; break; case 'export_pdf': @@ -53,12 +53,12 @@ if (isset($_GET['action'])) { switch ($_GET['type']) { case 'csv': - Export::export_table_csv($data); + Export::arrayToCsv($data); exit; break; case 'xls': if (!empty($data)) { - Export::export_table_xls($data); + Export::arrayToXls($data); exit; } break; diff --git a/main/group/group_space.php b/main/group/group_space.php index 9a3a51e3e4..d1e11f7155 100755 --- a/main/group/group_space.php +++ b/main/group/group_space.php @@ -335,10 +335,14 @@ if (count($tutors) == 0) { $image_path = UserManager::get_user_picture_path_by_id($tutor['user_id'], 'web', false, true); $image_repository = $image_path['dir']; $existing_image = $image_path['file']; - $completeName = api_get_person_name($tutor['firstname'], $tutor['lastname']); + $completeName = $tab_user_info['complete_name']; $photo = ''.$completeName.''; - $tutor_info .= '
  • '. - $photo.' '.$completeName.'
  • '; + $tutor_info .= '
  • '; + $tutor_info .= Display::url( + $tab_user_info['complete_name'], + $tab_user_info['profile_url'] + ); + $tutor_info .= '
  • '; } $tutor_info .= ''; } @@ -510,13 +514,12 @@ function email_filter($email) */ function user_icon_filter($user_id) { - global $origin; - $userinfo = api_get_user_info($user_id); + $userInfo = api_get_user_info($user_id); $image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true); $image_repository = $image_path['dir']; $existing_image = $image_path['file']; - $photo = '
    '.$userinfo['complete_name'].'
    '; - return ''.$photo; + $photo = '
    '.$userInfo['complete_name'].'
    '; + return Display::url($photo, $userInfo['profile_url']); } /** @@ -531,9 +534,8 @@ function user_icon_filter($user_id) */ function user_name_filter($name, $url_params, $row) { - $tab_user_info = api_get_user_info($row[0]); - $username = api_htmlentities(sprintf(get_lang('LoginX'), $tab_user_info['username']), ENT_QUOTES); - return '
    '.$name.''; + $userInfo = api_get_user_info($row[0]); + return UserManager::getUserProfileLink($userInfo); } // Footer diff --git a/main/inc/ajax/agenda.ajax.php b/main/inc/ajax/agenda.ajax.php index 658eddc8e0..55c07e5c64 100755 --- a/main/inc/ajax/agenda.ajax.php +++ b/main/inc/ajax/agenda.ajax.php @@ -101,7 +101,7 @@ switch ($action) { $start = isset($_REQUEST['start']) ? api_strtotime($_REQUEST['start']) : null; $end = isset($_REQUEST['end']) ? api_strtotime($_REQUEST['end']) : null; - $events = $agenda->get_events( + $events = $agenda->getEvents( $start, $end, api_get_course_int_id(), diff --git a/main/inc/ajax/course.ajax.php b/main/inc/ajax/course.ajax.php index 6612ddc288..278ef93483 100755 --- a/main/inc/ajax/course.ajax.php +++ b/main/inc/ajax/course.ajax.php @@ -84,9 +84,9 @@ switch ($action) { } $results[] = array( - 'id' => $courseInfo['id'], + 'id' => $courseInfo['code'], 'text' => $title - ); + ); } echo json_encode($results); } else { @@ -156,11 +156,11 @@ switch ($action) { $sql = "SELECT u.user_id as id, u.username, u.lastname, u.firstname FROM $user u - INNER JOIN $session_course_user r ON u.user_id = r.id_user - WHERE id_session = %d AND course_code = '%s' + INNER JOIN $session_course_user r ON u.user_id = r.user_id + WHERE session_id = %d AND c_id = '%s' AND (u.firstname LIKE '%s' OR u.username LIKE '%s' OR u.lastname LIKE '%s')"; $needle = '%' . $_GET['q'] . '%'; - $sql_query = sprintf($sql, $_GET['session_id'], $course['code'], $needle, $needle, $needle); + $sql_query = sprintf($sql, $_GET['session_id'], $course['real_id'], $needle, $needle, $needle); $result = Database::query($sql_query); while ($user = Database::fetch_assoc($result)) { @@ -232,7 +232,7 @@ switch ($action) { $courses = array(); foreach ($coursesData as $courseId => $course) { - $coachData = SessionManager::getCoachesByCourseSession($sessionId, $course['code']); + $coachData = SessionManager::getCoachesByCourseSession($sessionId, $courseId); $coachName = ''; diff --git a/main/inc/ajax/exercise.ajax.php b/main/inc/ajax/exercise.ajax.php index de87f5cb33..435ed724a9 100755 --- a/main/inc/ajax/exercise.ajax.php +++ b/main/inc/ajax/exercise.ajax.php @@ -286,11 +286,11 @@ switch ($action) { } else { // We know the user we get the exe_id. - $exe_id = $exercise_stat_info['exe_id']; - $total_score = $exercise_stat_info['exe_result']; + $exe_id = $exercise_stat_info['exe_id']; + $total_score = $exercise_stat_info['exe_result']; //Getting the list of attempts - $attempt_list = Event::getAllExerciseEventByExeId($exe_id); + $attempt_list = Event::getAllExerciseEventByExeId($exe_id); } // Updating Reminder algorythm. diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index 691b26a23c..35bb4036fa 100755 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -1004,7 +1004,7 @@ switch ($action) { 'lastname', ); - $questions = survey_manager::get_questions($surveyId, $courseId); + $questions = SurveyManager::get_questions($surveyId, $courseId); foreach ($questions as $question_id => $question) { @@ -1480,7 +1480,7 @@ if (in_array($action, $allowed_actions)) { default: //TODO add date if exists $file_name = (!empty($action)) ? $action : 'company_report'; - Export::export_table_csv($array, $file_name); + Export::arrayToCsv($array, $file_name); break; } exit; diff --git a/main/inc/ajax/online.ajax.php b/main/inc/ajax/online.ajax.php index 9c110bf1c9..4f0cd0a4cf 100755 --- a/main/inc/ajax/online.ajax.php +++ b/main/inc/ajax/online.ajax.php @@ -19,7 +19,13 @@ switch($action) { if (!empty($max_page) && $page <= $max_page) { if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) { - $user_list = who_is_online_in_this_course($page_rows, $images_to_show, api_get_user_id(), api_get_setting('time_limit_whosonline'), $_GET['cidReq']); + $user_list = who_is_online_in_this_course( + $page_rows, + $images_to_show, + api_get_user_id(), + api_get_setting('time_limit_whosonline'), + $_GET['cidReq'] + ); } else { $user_list = who_is_online($page_rows, $images_to_show); } diff --git a/main/inc/ajax/social.ajax.php b/main/inc/ajax/social.ajax.php index b7ba47a40b..0a58d48b16 100755 --- a/main/inc/ajax/social.ajax.php +++ b/main/inc/ajax/social.ajax.php @@ -125,7 +125,7 @@ switch ($action) { $course_info = api_get_course_info_by_id($course_id); $course_code = $course_info['code']; - if (api_is_user_of_course($course_code, api_get_user_id())) { + if (api_is_user_of_course($course_id, api_get_user_id())) { //------Forum messages $forum_result = get_all_post_from_user($user_id, $course_code); $all_result_data = 0; diff --git a/main/inc/ajax/user_manager.ajax.php b/main/inc/ajax/user_manager.ajax.php index fbff6ae91c..e294fdc9c4 100755 --- a/main/inc/ajax/user_manager.ajax.php +++ b/main/inc/ajax/user_manager.ajax.php @@ -94,9 +94,8 @@ switch ($action) { //$emailbody.=get_lang('Problem'). "\n\n". get_lang('SignatureFormula'); $emailbody.=api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator'); - $plugin = new AppPlugin(); - $additionalParameters = array( - 'smsType' => constant($plugin->getSMSPluginName().'::ACCOUNT_APPROVED_CONNECT'), + $additionalParameters = array( + 'smsType' => SmsPlugin::ACCOUNT_APPROVED_CONNECT, 'userId' => $user_id ); diff --git a/main/inc/global.inc.php b/main/inc/global.inc.php index fde8331309..e9ef85d8a2 100755 --- a/main/inc/global.inc.php +++ b/main/inc/global.inc.php @@ -54,18 +54,6 @@ if (!isset($GLOBALS['_configuration'])) { $GLOBALS['_configuration'] = $_configuration; } -// Code for trnasitional purposes, it can be removed right before the 1.8.7 release. -if (empty($_configuration['system_version'])) { - $_configuration['system_version'] = $_configuration['dokeos_version']; - $_configuration['system_stable'] = $_configuration['dokeos_stable']; - $_configuration['software_url'] = 'http://www.chamilo.org/'; -} - -// For backward compatibility. -$_configuration['dokeos_version'] = $_configuration['system_version']; -$_configuration['dokeos_stable'] = $_configuration['system_stable']; -$userPasswordCrypted = $_configuration['password_encryption']; - // Include the main Chamilo platform library file. require_once $includePath.'/lib/api.lib.php'; @@ -115,13 +103,6 @@ if (!is_dir(_MPDF_TEMP_PATH)) { mkdir(_MPDF_TEMP_PATH, api_get_permissions_for_new_directories(), true); } -/* DATABASE CONNECTION */ - -// @todo: this shouldn't be done here. It should be stored correctly during installation. -if (empty($_configuration['statistics_database']) && $already_installed) { - $_configuration['statistics_database'] = $_configuration['main_database']; -} -global $database_connection; // Connect to the server database and select the main chamilo database. // When $_configuration['db_persistent_connection'] is set, it is expected to be a boolean type. $dbPersistConnection = api_get_configuration_value('db_persistent_connection'); @@ -137,26 +118,8 @@ $params = array( 'client_flags' => $dbFlags, ); -if (!$_configuration['db_host']) { - $global_error_code = 4; - // A configuration option about database server is missing. - require $includePath.'/global_error_message.inc.php'; - die(); -} - -if (!($conn_return = @Database::connect($params))) { - $global_error_code = 3; - // The database server is not available or credentials are invalid. - require $includePath.'/global_error_message.inc.php'; - die(); -} - // Doctrine ORM configuration -use Doctrine\ORM\Tools\Setup; -use Doctrine\ORM\EntityManager; - -// the connection configuration $dbParams = array( 'driver' => 'pdo_mysql', 'host' => $_configuration['db_host'], @@ -165,50 +128,15 @@ $dbParams = array( 'dbname' => $_configuration['main_database'], ); -$config = Database::getDoctrineConfig(); - -$config->setEntityNamespaces( - array( - 'ChamiloUserBundle' => 'Chamilo\UserBundle\Entity', - 'ChamiloCoreBundle' => 'Chamilo\CoreBundle\Entity', - 'ChamiloCourseBundle' => 'Chamilo\CourseBundle\Entity' - ) -); - -$entityManager = EntityManager::create($dbParams, $config); - -// Registering Constraints -use Doctrine\Common\Annotations\AnnotationRegistry; -AnnotationRegistry::registerAutoloadNamespace( - 'Symfony\Component\Validator\Constraint', - api_get_path(SYS_PATH)."vendor/symfony/validator" -); - -AnnotationRegistry::registerFile( - api_get_path(SYS_PATH)."vendor/symfony/doctrine-bridge/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php" -); - -// Registering gedmo extensions -AnnotationRegistry::registerAutoloadNamespace( - 'Gedmo\Mapping\Annotation', - api_get_path(SYS_PATH)."vendor/gedmo/doctrine-extensions/lib" -); - -/*$repo = $entityManager->getRepository('ChamiloCoreBundle:Session'); -$repo = $entityManager->getRepository('ChamiloUserBundle:User'); -$repo = $entityManager->getRepository('ChamiloCoreBundle:Course');*/ - -/*try { - $connect = $entityManager->getConnection()->connect(); +try { + $database = new \Database(); + $database->connect($dbParams); } catch (Exception $e) { $global_error_code = 3; // The database server is not available or credentials are invalid. require $includePath.'/global_error_message.inc.php'; die(); -}*/ - -$database = new \Database(); -$database->setManager($entityManager); +} /* RETRIEVING ALL THE CHAMILO CONFIG SETTINGS FOR MULTIPLE URLs FEATURE*/ if (!empty($_configuration['multiple_access_urls'])) { @@ -253,16 +181,6 @@ if (!empty($_configuration['multiple_access_urls'])) { $_configuration['access_url'] = 1; } -// The system has not been designed to use special SQL modes that were introduced since MySQL 5. -Database::query("set session sql_mode='';"); - -/*if (!Database::select_db($_configuration['main_database'], $database_connection)) { - $global_error_code = 5; - // Connection to the main Chamilo database is impossible, it might be missing or restricted or its configuration option might be incorrect. - require $includePath.'/global_error_message.inc.php'; - die(); -}*/ - /* Initialization of the default encodings */ // The platform's character set must be retrieved at this early moment. $sql = "SELECT selected_value FROM settings_current WHERE variable = 'platform_charset';"; @@ -281,17 +199,6 @@ api_initialize_internationalization(); // Initialization of the default encoding that will be used by the multibyte string routines in the internationalization library. api_set_internationalization_default_encoding($charset); -// Initialization of the database encoding to be used. -Database::query("SET SESSION character_set_server='utf8';"); -Database::query("SET SESSION collation_server='utf8_general_ci';"); - -if (api_is_utf8($charset)) { - // See Bug #1802: For UTF-8 systems we prefer to use "SET NAMES 'utf8'" statement in order to avoid a bizarre problem with Chinese language. - Database::query("SET NAMES 'utf8';"); -} else { - Database::query("SET CHARACTER SET '" . Database::to_db_encoding($charset) . "';"); -} - // Start session after the internationalization library has been initialized. Chamilo::session()->start($already_installed); diff --git a/main/inc/lib/AnnouncementEmail.php b/main/inc/lib/AnnouncementEmail.php index a03d3a8ad1..e76524c56c 100644 --- a/main/inc/lib/AnnouncementEmail.php +++ b/main/inc/lib/AnnouncementEmail.php @@ -126,7 +126,7 @@ class AnnouncementEmail c_id = $course_id AND tool = '$tool' AND ref = $id AND - id_session = {$this->session_id} "; + session_id = {$this->session_id} "; $rs = Database::query($sql); while ($row = Database::fetch_array($rs, 'ASSOC')) { @@ -311,12 +311,15 @@ class AnnouncementEmail } if ($sendToUsersInSession) { - $sessionList = SessionManager::get_session_by_course($this->course['code']); + $sessionList = SessionManager::get_session_by_course($this->course['real_id']); if (!empty($sessionList)) { foreach ($sessionList as $sessionInfo) { $sessionId = $sessionInfo['id']; $message = $this->message(null, $sessionId); - $userList = CourseManager::get_user_list_from_course_code($this->course['code'], $sessionId); + $userList = CourseManager::get_user_list_from_course_code( + $this->course['code'], + $sessionId + ); if (!empty($userList)) { foreach ($userList as $user) { MessageManager::send_message_simple( diff --git a/main/inc/lib/AnnouncementManager.php b/main/inc/lib/AnnouncementManager.php index e964c5b2bf..5b5a39626a 100755 --- a/main/inc/lib/AnnouncementManager.php +++ b/main/inc/lib/AnnouncementManager.php @@ -320,6 +320,8 @@ class AnnouncementManager $sendToUsersInSession = false ) { $_course = api_get_course_info(); + $course_id = api_get_course_int_id(); + $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); // filter data @@ -332,8 +334,6 @@ class AnnouncementManager $end_date = Database::escape_string($end_date); } - $course_id = api_get_course_int_id(); - $order = self::get_last_announcement_order(); // store in the table announcement @@ -348,6 +348,9 @@ class AnnouncementManager $last_id = Database::insert($tbl_announcement, $params); + $sql = "UPDATE $tbl_announcement SET id = iid WHERE iid = $last_id"; + Database::query($sql); + if (empty($last_id)) { return false; } else { @@ -460,50 +463,58 @@ class AnnouncementManager //store the attach file $last_id = Database::insert_id(); - if (!empty($file)) { - self::add_announcement_attachment_file($last_id, $file_comment, $file); - } + if ($last_id) { + $sql = "UPDATE $lp_item_view_table SET id = iid WHERE iid = $last_id"; + Database::query($sql); - // Store in item_property (first the groups, then the users + if (!empty($file)) { + self::add_announcement_attachment_file( + $last_id, + $file_comment, + $file + ); + } - if (!isset($to_users)) { - // when no user is selected we send it to everyone - $send_to = CourseManager::separateUsersGroups($to); - // storing the selected groups - if (is_array($send_to['groups'])) { - foreach ($send_to['groups'] as $group) { - api_item_property_update( - $_course, - TOOL_ANNOUNCEMENT, - $last_id, - "AnnouncementAdded", - api_get_user_id(), - $group - ); + // Store in item_property (first the groups, then the users + + if (!isset($to_users)) { + // when no user is selected we send it to everyone + $send_to = CourseManager::separateUsersGroups($to); + // storing the selected groups + if (is_array($send_to['groups'])) { + foreach ($send_to['groups'] as $group) { + api_item_property_update( + $_course, + TOOL_ANNOUNCEMENT, + $last_id, + "AnnouncementAdded", + api_get_user_id(), + $group + ); + } } - } - } else { - // the message is sent to everyone, so we set the group to 0 - // storing the selected users - if (is_array($to_users)) { - foreach ($to_users as $user) { - api_item_property_update( - $_course, - TOOL_ANNOUNCEMENT, - $last_id, - "AnnouncementAdded", - api_get_user_id(), - '', - $user - ); + } else { + // the message is sent to everyone, so we set the group to 0 + // storing the selected users + if (is_array($to_users)) { + foreach ($to_users as $user) { + api_item_property_update( + $_course, + TOOL_ANNOUNCEMENT, + $last_id, + "AnnouncementAdded", + api_get_user_id(), + '', + $user + ); + } } } - } - if ($sendToUsersInSession) { - self::addAnnouncementToAllUsersInSessions($last_id); + if ($sendToUsersInSession) { + self::addAnnouncementToAllUsersInSessions($last_id); + } } - return $last_id; } @@ -592,7 +603,7 @@ class AnnouncementManager $courseCode = api_get_course_id(); $_course = api_get_course_info(); - $sessionList = SessionManager::get_session_by_course(api_get_course_id()); + $sessionList = SessionManager::get_session_by_course(api_get_course_int_id()); if (!empty($sessionList)) { foreach ($sessionList as $sessionInfo) { @@ -1013,30 +1024,6 @@ class AnnouncementManager "; } - /** - * returns all the javascript that is required for easily - * setting the target people/groups - * this goes into the $htmlHeadXtra[] array - */ - public static function to_javascript() - { - $www = api_get_path(WEB_PATH); - /* - * Do not allow this kind of behaviour. js minifieds should be manage by the template class or assetic or whatever see #4757 for more info - if (api_get_setting('server_type') == 'test') { - $src = $www . 'main/announcements/resources/js/main.js'; - } else { - $src = $www . 'main/announcements/resources/js/main.min.js'; - }*/ - $src = $www . 'main/announcements/resources/js/main.js'; - $result = Javascript::tag($src); - $root = Chamilo::url(); - $code = "var www = '$root';\n"; - $code .= Javascript::get_lang('FieldRequired', 'Send2All', 'AddAnAttachment', 'Everybody'); - $result .= Javascript::tag_code($code); - return $result; - } - /** * constructs the form to display all the groups and users the message has been sent to * input: $sent_to_array is a 2 dimensional array containing the groups and the users @@ -1215,11 +1202,17 @@ class AnnouncementManager $safe_new_file_name = Database::escape_string($new_file_name); // Storing the attachments if any $sql = 'INSERT INTO ' . $tbl_announcement_attachment . ' (c_id, filename, comment, path, announcement_id, size) ' . - "VALUES ($course_id, '$safe_file_name', '$file_comment', '$safe_new_file_name' , '$announcement_id', '" . intval($file['size']) . "' )"; + "VALUES ($course_id, '$safe_file_name', '$file_comment', '$safe_new_file_name' , '$announcement_id', '" . intval($file['size']) . "' )"; $result = Database::query($sql); + + $insertId = Database::insert_id(); + $sql = "UPDATE $tbl_announcement_attachment SET id = iid WHERE iid = $insertId"; + Database::query($sql); + $return = 1; } } + return $return; } @@ -1308,7 +1301,7 @@ class AnnouncementManager $user_id = api_get_user_id(); $group_id = api_get_group_id(); $session_id = api_get_session_id(); - $condition_session = api_get_session_condition($session_id, true, true); + $condition_session = api_get_session_condition($session_id, true, true, 'announcement.session_id'); $course_id = api_get_course_int_id(); $_course = api_get_course_info(); @@ -1630,7 +1623,7 @@ class AnnouncementManager $_course = api_get_course_info(); $session_id = api_get_session_id(); $userId = api_get_user_id(); - $condition_session = api_get_session_condition($session_id, true, true); + $condition_session = api_get_session_condition($session_id, true, true, 'announcement.session_id'); if (api_is_allowed_to_edit(false,true)) { // check teacher status @@ -1643,13 +1636,14 @@ class AnnouncementManager } $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id FROM $tbl_announcement announcement, $tbl_item_property ip - WHERE announcement.c_id = $course_id AND - ip.c_id = $course_id AND - announcement.id = ip.ref AND - ip.tool = 'announcement' AND - ip.visibility <> '2' - $group_condition - $condition_session + WHERE + announcement.c_id = $course_id AND + ip.c_id = $course_id AND + announcement.id = ip.ref AND + ip.tool = 'announcement' AND + ip.visibility <> '2' + $group_condition + $condition_session GROUP BY ip.ref ORDER BY display_order DESC LIMIT 0,$maximum"; @@ -1666,7 +1660,7 @@ class AnnouncementManager "OR ip.to_group_id IN (0, ".implode(", ", $group_memberships)."))) "; } else { $cond_user_id = " AND (ip.lastedit_user_id = '".$userId."' - OR ip.to_group_id IN (0, ".api_get_group_id()."))"; + OR ip.to_group_id IN (0, ".api_get_group_id()."))"; } } else { if (api_get_group_id() == 0) { @@ -1725,24 +1719,25 @@ class AnnouncementManager // the user is not identiefied => show only the general announcements $sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id - FROM $tbl_announcement announcement, $tbl_item_property ip - WHERE - announcement.c_id = $course_id AND - ip.c_id = $course_id AND - announcement.id = ip.ref - AND ip.tool='announcement' - AND ip.visibility='1' - AND ip.to_group_id='0' - $condition_session - GROUP BY ip.ref - ORDER BY display_order DESC - LIMIT 0,$maximum"; + FROM $tbl_announcement announcement, $tbl_item_property ip + WHERE + announcement.c_id = $course_id AND + ip.c_id = $course_id AND + announcement.id = ip.ref + AND ip.tool='announcement' + AND ip.visibility='1' + AND ip.to_group_id='0' + $condition_session + GROUP BY ip.ref + ORDER BY display_order DESC + LIMIT 0,$maximum"; } } } } $result = Database::query($sql); + return Database::num_rows($result); } } diff --git a/main/inc/lib/SmsPlugin.php b/main/inc/lib/SmsPlugin.php new file mode 100644 index 0000000000..b588dd6982 --- /dev/null +++ b/main/inc/lib/SmsPlugin.php @@ -0,0 +1,144 @@ +get_handler_field_info_by_field_variable('mobile_phone_number'); + + if (empty($extraFieldInfo)) { + $extraField->save(array( + 'field_type' => 1, + 'field_variable' => 'mobile_phone_number', + 'field_display_text' => $this->get_lang('mobile_phone_number'), + 'field_default_value' => null, + 'field_order' => 2, + 'field_visible' => 1, + 'field_changeable' => 1, + 'field_filter' => null + )); + } + } + + /** + * install (installs the plugin) + * @return void + */ + public function install() + { + $this->addMobilePhoneNumberField(); + } +} diff --git a/main/inc/lib/SmsPluginLibraryInterface.php b/main/inc/lib/SmsPluginLibraryInterface.php new file mode 100644 index 0000000000..5ad6800575 --- /dev/null +++ b/main/inc/lib/SmsPluginLibraryInterface.php @@ -0,0 +1,43 @@ + ['default' => 0, 'category' => 'work'], + 'email_alert_on_new_doc_dropbox' => ['default' => 0, 'category' => 'dropbox'], + 'allow_user_edit_agenda' => ['default' => 0, 'category' => 'agenda'], + 'allow_user_edit_announcement' => ['default' => 0, 'category' => 'announcement'], + 'email_alert_manager_on_new_quiz' => ['default' => $defaultEmailExerciseAlert, 'category' => 'quiz'], + 'allow_user_image_forum' => ['default' => 1, 'category' => 'forum'], + 'course_theme' => ['default' => '', 'category' => 'theme'], + 'allow_learning_path_theme' => ['default' => 1, 'category' => 'theme'], + 'allow_open_chat_window' => ['default' => 1, 'category' => 'chat'], + 'email_alert_to_teacher_on_new_user_in_course' => ['default' => 0, 'category' =>'registration'], + 'allow_user_view_user_list' => ['default' =>1, 'category' =>'user'], + 'display_info_advance_inside_homecourse' => ['default' => 1, 'category' =>'thematic_advance'], + 'email_alert_students_on_new_homework' => ['default' => 0, 'category' =>'work'], + 'enable_lp_auto_launch' => ['default' => 0, 'category' =>'learning_path'], + 'pdf_export_watermark_text' => ['default' =>'', 'category' =>'learning_path'], + 'allow_public_certificates' => ['default' => '', 'category' =>'certificates'], + 'documents_default_visibility' => ['default' =>'visible', 'category' =>'document'] + ]; + + $counter = 1; + foreach ($settings as $variable => $setting) { + Database::query( + "INSERT INTO $TABLESETTING (id, c_id, variable, value, category) + VALUES ($counter, $course_id, '".$variable."', '".$setting['default']."', '".$setting['category']."')" + ); + $counter++; + } /* Course homepage tools for platform admin only */ /* Group tool */ Database::query( - "INSERT INTO $TABLEGROUPCATEGORIES (c_id, id , title , description , max_student , self_reg_allowed , self_unreg_allowed , groups_per_user , display_order ) - VALUES ($course_id, '2', '" . self::lang2db( - get_lang('DefaultGroupCategory') - ) . "', '', '8', '0', '0', '0', '0');" + "INSERT INTO $TABLEGROUPCATEGORIES (c_id, id, title , description, max_student, self_reg_allowed, self_unreg_allowed, groups_per_user, display_order) + VALUES ($course_id, '2', '" . self::lang2db(get_lang('DefaultGroupCategory')) . "', '', '8', '0', '0', '0', '0');" ); /* Example Material */ @@ -745,27 +717,16 @@ class AddCourse $language_interface = $language; $now = api_get_utc_datetime(); - //Share folder - Database::query( - "INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size) VALUES ($course_id,'/shared_folder','" . get_lang( - 'UserFolders' - ) . "','folder','0')" - ); - $example_doc_id = Database:: insert_id(); - Database::query( - "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ($course_id,'document',1,'$now','$now',$example_doc_id,'DocumentAdded',1,0,NULL,0)" - ); + $files = [ + ['path' => '/shared_folder', 'title' => get_lang('UserFolders'), 'filetype' => 'folder', 'size' => 0], + ['path' => '/chat_files', 'title' => get_lang('ChatFiles'), 'filetype' => 'folder', 'size' => 0], + ]; - //Chat folder - Database::query( - "INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size) VALUES ($course_id,'/chat_files','" . get_lang( - 'ChatFiles' - ) . "','folder','0')" - ); - $example_doc_id = Database:: insert_id(); - Database::query( - "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ($course_id,'document',1,'$now','$now',$example_doc_id,'DocumentAdded',1,0,NULL,0)" - ); + $counter = 1; + foreach ($files as $file) { + self::insertDocument($course_id, $counter, $file); + $counter++; + } $sys_course_path = api_get_path(SYS_COURSE_PATH); $perm = api_get_permissions_for_new_directories(); @@ -780,68 +741,21 @@ class AddCourse /* Documents */ if ($fill_with_exemplary_content) { - Database::query( - "INSERT INTO $TABLETOOLDOCUMENT (c_id,path,title,filetype,size) VALUES ($course_id,'/images','" . get_lang( - 'Images' - ) . "','folder','0')" - ); - $example_doc_id = Database:: insert_id(); - Database::query( - "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ($course_id,'document',1,'$now','$now',$example_doc_id,'DocumentAdded',1,0,NULL,0)" - ); - - Database::query( - "INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size) VALUES ($course_id,'/images/gallery','" . get_lang( - 'DefaultCourseImages' - ) . "','folder','0')" - ); - $example_doc_id = Database:: insert_id(); - Database::query( - "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ($course_id,'document',1,'$now','$now',$example_doc_id,'DocumentAdded',1,0,NULL,0)" - ); - - Database::query( - "INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size) VALUES ($course_id,'/audio','" . get_lang( - 'Audio' - ) . "','folder','0')" - ); - $example_doc_id = Database:: insert_id(); - Database::query( - "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ($course_id,'document',1,'$now','$now',$example_doc_id,'DocumentAdded',1,0,NULL,0)" - ); - - Database::query( - "INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size) VALUES ($course_id,'/flash','" . get_lang( - 'Flash' - ) . "','folder','0')" - ); - $example_doc_id = Database:: insert_id(); - Database::query( - "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ($course_id,'document',1,'$now','$now',$example_doc_id,'DocumentAdded',1,0,NULL,0)" - ); - - Database::query( - "INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size) VALUES ($course_id,'/video','" . get_lang( - 'Video' - ) . "','folder','0')" - ); - $example_doc_id = Database:: insert_id(); - Database::query( - "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ($course_id,'document',1,'$now','$now',$example_doc_id,'DocumentAdded',1,0,NULL,0)" - ); - - Database::query( - "INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size) VALUES ($course_id,'/certificates','" . get_lang( - 'Certificates' - ) . "','folder','0')" - ); - $example_doc_id = Database:: insert_id(); - Database::query( - "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ($course_id,'document',1,'$now','$now',$example_doc_id,'DocumentAdded',1,0,NULL,0)" - ); + $files = [ + ['path' => '/images', 'title' => get_lang('Images'), 'filetype' => 'folder', 'size' => 0], + ['path' => '/images/gallery', 'title' => get_lang('DefaultCourseImages'), 'filetype' => 'folder', 'size' => 0], + ['path' => '/audio', 'title' => get_lang('Audio'), 'filetype' => 'folder', 'size' => 0], + ['path' => '/flash', 'title' => get_lang('Flash'), 'filetype' => 'folder', 'size' => 0], + ['path' => '/video', 'title' => get_lang('Video'), 'filetype' => 'folder', 'size' => 0], + ['path' => '/certificates', 'title' => get_lang('Certificates'), 'filetype' => 'folder', 'size' => 0] + ]; + + foreach ($files as $file) { + self::insertDocument($course_id, $counter, $file); + $counter++; + } // FILL THE COURSE DOCUMENT WITH DEFAULT COURSE PICTURES - $folders_to_copy_from_default_course = array( 'images', 'audio', @@ -921,11 +835,7 @@ class AddCourse if (is_array($array_media) && count($array_media) > 0) { foreach ($array_media as $key => $value) { if (isset($value['dir']) && !empty($value['dir'])) { - - if (!is_dir( - $course_documents_folder . $value['dir'] - ) - ) { + if (!is_dir($course_documents_folder . $value['dir'])) { //Creating folder mkdir( $course_documents_folder . $value['dir'], @@ -1216,6 +1126,41 @@ class AddCourse $language_interface = $language_interface_original; return true; } + + /** + * @param int $course_id + * @param int $counter + * @param array $file + */ + public static function insertDocument($course_id, $counter, $file) + { + $tableItem = Database::get_course_table(TABLE_ITEM_PROPERTY); + $tableDocument = Database::get_course_table(TABLE_DOCUMENT); + + $now = api_get_utc_datetime(); + + $sql = "INSERT INTO $tableDocument (id, c_id, path,title,filetype,size) + VALUES ($counter, $course_id, '".$file['path']."', '".$file['title']."', '".$file['filetype']."', '".$file['size']."')"; + Database::query($sql); + $docId = Database:: insert_id(); + + if ($docId) { + $sql = "UPDATE $tableDocument SET id = iid WHERE iid = $docId"; + Database::query($sql); + + Database::query( + "INSERT INTO $tableItem (id, c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) + VALUES ($counter, $course_id,'document',1,'$now', '$now', $docId, 'DocumentAdded', 1, 0, NULL, 0)" + ); + + $id = Database:: insert_id(); + + $sql = "UPDATE $tableItem SET id = iid WHERE iid = $id"; + Database::query($sql); + } + + } + /** * string2binary converts the string "true" or "false" to the boolean true false (0 or 1) * This is used for the Chamilo Config Settings as these store true or false as string @@ -1351,24 +1296,12 @@ class AddCourse // Here we must add 2 fields. $sql = "INSERT INTO " . $TABLECOURSE . " SET - code = '" . Database:: escape_string( - $code - ) . "', - directory = '" . Database:: escape_string( - $directory - ) . "', - course_language = '" . Database:: escape_string( - $course_language - ) . "', - title = '" . Database:: escape_string( - $title - ) . "', - description = '" . self::lang2db( - get_lang('CourseDescription') - ) . "', - category_code = '" . Database:: escape_string( - $category_code - ) . "', + code = '".Database:: escape_string($code)."', + directory = '".Database:: escape_string($directory)."', + course_language = '".Database:: escape_string($course_language)."', + title = '".Database:: escape_string($title)."', + description = '".self::lang2db(get_lang('CourseDescription'))."', + category_code = '".Database:: escape_string($category_code)."', visibility = '" . $visibility . "', show_score = '1', disk_quota = '" . intval($disk_quota) . "', @@ -1376,20 +1309,12 @@ class AddCourse expiration_date = '" . $expiration_date . "', last_edit = '$time', last_visit = NULL, - tutor_name = '" . Database:: escape_string( - $tutor_name - ) . "', - department_name = '" . Database:: escape_string( - $department_name - ) . "', - department_url = '" . Database:: escape_string( - $department_url - ) . "', - subscribe = '" . intval($subscribe) . "', - unsubscribe = '" . intval($unsubscribe) . "', - visual_code = '" . Database:: escape_string( - $visual_code - ) . "'"; + tutor_name = '" . Database:: escape_string($tutor_name) . "', + department_name = '" . Database:: escape_string($department_name) . "', + department_url = '" . Database:: escape_string($department_url) . "', + subscribe = '" . intval($subscribe) . "', + unsubscribe = '" . intval($unsubscribe) . "', + visual_code = '" . Database:: escape_string($visual_code) . "'"; Database::query($sql); $course_id = Database::insert_id(); @@ -1406,17 +1331,12 @@ class AddCourse if (!empty($user_id)) { $sql = "INSERT INTO " . $TABLECOURSUSER . " SET - course_code = '" . Database:: escape_string( - $code - ) . "', - user_id = '" . intval($user_id) . "', - status = '1', - role = '" . self::lang2db( - get_lang('Professor') - ) . "', - tutor_id = '0', - sort = '" . ($i_course_sort) . "', - user_course_cat = '0'"; + c_id = '" . $course_id . "', + user_id = '" . intval($user_id) . "', + status = '1', + is_tutor = '0', + sort = '" . ($i_course_sort) . "', + user_course_cat = '0'"; Database::query($sql); } } @@ -1434,15 +1354,10 @@ class AddCourse continue; } $sql = "INSERT INTO " . $TABLECOURSUSER . " SET - course_code = '" . Database::escape_string( - $code - ) . "', - user_id = '" . Database::escape_string( - $key - ) . "', + c_id = '" . Database::escape_string($course_id) . "', + user_id = '" . Database::escape_string($key) . "', status = '1', - role = '', - tutor_id = '0', + is_tutor = '0', sort = '" . ($sort + 1) . "', user_course_cat = '0'"; Database::query($sql); @@ -1455,9 +1370,9 @@ class AddCourse if (api_get_current_access_url_id() != -1) { $url_id = api_get_current_access_url_id(); } - UrlManager::add_course_to_url($code, $url_id); + UrlManager::add_course_to_url($course_id, $url_id); } else { - UrlManager::add_course_to_url($code, 1); + UrlManager::add_course_to_url($course_id, 1); } // Add event to the system log. @@ -1500,12 +1415,9 @@ class AddCourse $message .= get_lang('Language') . ' ' . $course_language; $userInfo = api_get_user_info($user_id); - $plugin = new AppPlugin(); + $additionalParameters = array( - 'smsType' => constant( - $plugin->getSMSPluginName( - ) . '::NEW_COURSE_BEEN_CREATED' - ), + 'smsType' => SmsPlugin::NEW_COURSE_BEEN_CREATED, 'userId' => $user_id, 'courseName' => $title, 'creatorUsername' => $userInfo['username'] diff --git a/main/inc/lib/add_courses_to_session_functions.lib.php b/main/inc/lib/add_courses_to_session_functions.lib.php index b65b0623af..86ebb1e71b 100755 --- a/main/inc/lib/add_courses_to_session_functions.lib.php +++ b/main/inc/lib/add_courses_to_session_functions.lib.php @@ -29,8 +29,8 @@ class AddCourseToSession if (!empty($id_session)) { $id_session = intval($id_session); // check course_code from session_rel_course table - $sql = 'SELECT course_code FROM '.$tbl_session_rel_course.' - WHERE id_session = '.$id_session; + $sql = 'SELECT c_id FROM '.$tbl_session_rel_course.' + WHERE session_id = '.$id_session; $res = Database::query($sql); $course_codes = ''; if (Database::num_rows($res) > 0) { @@ -39,17 +39,17 @@ class AddCourseToSession } $course_codes = substr($course_codes,0,(strlen($course_codes)-1)); - $cond_course_code = ' AND course.code NOT IN('.$course_codes.') '; + $cond_course_code = ' AND course.id NOT IN('.$course_codes.') '; } } if ($type=='single') { // search users where username or firstname or lastname begins likes $needle - $sql = 'SELECT course.code, course.visual_code, course.title, session_rel_course.id_session + $sql = 'SELECT course.code, course.visual_code, course.title, session_rel_course.session_id FROM '.$tbl_course.' course LEFT JOIN '.$tbl_session_rel_course.' session_rel_course ON course.code = session_rel_course.course_code - AND session_rel_course.id_session = '.intval($id_session).' + AND session_rel_course.session_id = '.intval($id_session).' WHERE course.visual_code LIKE "'.$needle.'%" OR course.title LIKE "'.$needle.'%"'; @@ -61,19 +61,19 @@ class AddCourseToSession ORDER BY course.code '; } - global $_configuration; - if ($_configuration['multiple_access_urls']) { - $tbl_course_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); + if (api_is_multiple_url_enabled()) { + $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){ if ($type=='single') { - $sql = 'SELECT course.code, course.visual_code, course.title, session_rel_course.id_session + $sql = 'SELECT course.code, course.visual_code, course.title, session_rel_course.session_id FROM '.$tbl_course.' course LEFT JOIN '.$tbl_session_rel_course.' session_rel_course 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) + AND session_rel_course.session_id = '.intval($id_session).' + INNER JOIN '.$tbl_course_rel_access_url.' url_course + ON (url_course.c_id = course.id) WHERE access_url_id = '.$access_url_id.' AND (course.visual_code LIKE "'.$needle.'%" OR @@ -82,7 +82,7 @@ class AddCourseToSession $sql = 'SELECT course.code, course.visual_code, course.title FROM '.$tbl_course.' course, '.$tbl_course_rel_access_url.' url_course WHERE - url_course.course_code=course.code AND + url_course.c_id = course.id AND access_url_id = '.$access_url_id.' AND course.visual_code LIKE "'.$needle.'%" '.$cond_course_code.' ORDER BY course.code '; diff --git a/main/inc/lib/agenda.lib.php b/main/inc/lib/agenda.lib.php index 086941351e..f600dd99c7 100644 --- a/main/inc/lib/agenda.lib.php +++ b/main/inc/lib/agenda.lib.php @@ -181,6 +181,9 @@ class Agenda $id = Database::insert($this->tbl_course_agenda, $attributes); if ($id) { + $sql = "UPDATE ".$this->tbl_course_agenda." SET id = iid WHERE iid = $id"; + Database::query($sql); + $groupId = api_get_group_id(); if (!empty($usersToSend)) { @@ -882,7 +885,7 @@ class Agenda * @param string $format * @return array|string */ - public function get_events( + public function getEvents( $start, $end, $course_id = null, @@ -897,7 +900,7 @@ class Agenda case 'course': $session_id = $this->sessionId; $courseInfo = api_get_course_info_by_id($course_id); - $this->get_course_events( + $this->getCourseEvents( $start, $end, $courseInfo, @@ -929,7 +932,7 @@ class Agenda if (!empty($my_courses)) { foreach ($my_courses as $course_item) { $courseInfo = api_get_course_info($course_item['code']); - $this->get_course_events($start, $end, $courseInfo, 0, $my_session_id); + $this->getCourseEvents($start, $end, $courseInfo, 0, $my_session_id); } } } @@ -939,10 +942,10 @@ class Agenda foreach ($my_course_list as $course_info_item) { if (isset($course_id) && !empty($course_id)) { if ($course_info_item['real_id'] == $course_id) { - $this->get_course_events($start, $end, $course_info_item); + $this->getCourseEvents($start, $end, $course_info_item); } } else { - $this->get_course_events($start, $end, $course_info_item); + $this->getCourseEvents($start, $end, $course_info_item); } } } @@ -1196,7 +1199,7 @@ class Agenda ref = $eventId AND ip.visibility = '1' AND ip.c_id = $courseId AND - ip.id_session = $sessionId + ip.session_id = $sessionId "; $result = Database::query($sql); @@ -1235,7 +1238,7 @@ class Agenda * @param int $user_id * @return array */ - public function get_course_events($start, $end, $courseInfo, $groupId = 0, $session_id = 0, $user_id = 0) + public function getCourseEvents($start, $end, $courseInfo, $groupId = 0, $session_id = 0, $user_id = 0) { $start = isset($start) && !empty($start) ? api_get_utc_datetime(intval($start)) : null; $end = isset($end) && !empty($end) ? api_get_utc_datetime(intval($end)) : null; @@ -1303,11 +1306,11 @@ class Agenda INNER JOIN $tbl_property ip ON (agenda.id = ip.ref AND agenda.c_id = ip.c_id) WHERE - ip.tool ='".TOOL_CALENDAR_EVENT."' AND + ip.tool = '".TOOL_CALENDAR_EVENT."' AND $where_condition AND - ip.visibility = '1' AND - agenda.c_id = $course_id AND - ip.c_id = $course_id + ip.visibility = '1' AND + agenda.c_id = $course_id AND + ip.c_id = $course_id "; } else { $visibilityCondition = " ip.visibility='1' AND"; @@ -1333,19 +1336,30 @@ class Agenda agenda.c_id = $course_id AND ip.c_id = $course_id AND agenda.session_id = $session_id AND - ip.id_session = $session_id + ip.session_id = $session_id "; } $dateCondition = null; - if (!empty($start) && !empty($end)) { + + if (!empty($start) && !empty($end)) { + $date = new DateTime($start); + $month = $date->format('m'); + $dateCondition .= "AND ( - (agenda.start_date >= '".$start."' OR agenda.start_date IS NULL) AND - (agenda.end_date <= '".$end."' OR agenda.end_date IS NULL) + agenda.start_date BETWEEN '".$start."' AND '".$end."' OR + agenda.end_date BETWEEN '".$start."' AND '".$end."' OR + ( + agenda.start_date <> '' AND agenda.end_date <> '' AND + YEAR(agenda.start_date) = YEAR(agenda.end_date) AND + MONTH('$start') BETWEEN MONTH(agenda.start_date) AND MONTH(agenda.end_date) + ) + )"; } $sql .= $dateCondition; + $allowComments = api_get_configuration_value('allow_agenda_event_comment'); $result = Database::query($sql); @@ -1540,7 +1554,7 @@ class Agenda */ private function formatEventDate($utcTime) { - return date('c', api_strtotime(api_get_local_time($utcTime))); + return date(DateTime::ISO8601, api_strtotime(api_get_local_time($utcTime))); } /** @@ -1761,10 +1775,8 @@ class Agenda if ($id) { $form_title = get_lang('ModifyCalendarItem'); - $button = get_lang('ModifyEvent'); } else { $form_title = get_lang('AddCalendarItem'); - $button = get_lang('AgendaAdd'); } $form->addElement('header', $form_title); @@ -1894,7 +1906,13 @@ class Agenda ); } - $form->addElement('button', 'submit', $button); + + if ($id) { + $form->addButtonUpdate(get_lang('ModifyEvent')); + } else { + $form->addButtonSave(get_lang('AgendaAdd')); + } + $form->setDefaults($params); $form->addRule('date_range', get_lang('ThisFieldIsRequired'), 'required'); @@ -2066,13 +2084,18 @@ class Agenda "VALUES ($course_id, '".$file_name."', '".$comment."', '".$new_file_name."' , '".$eventId."', '".$size."' )"; Database::query($sql); $id = Database::insert_id(); - api_item_property_update( - $courseInfo, - 'calendar_event_attachment', - $id, - 'AgendaAttachmentAdded', - api_get_user_id() - ); + if ($id) { + $sql = "UPDATE $agenda_table_attachment SET id = iid WHERE iid = $id"; + Database::query($sql); + + api_item_property_update( + $courseInfo, + 'calendar_event_attachment', + $id, + 'AgendaAttachmentAdded', + api_get_user_id() + ); + } } } } diff --git a/main/inc/lib/ajax_controller.class.php b/main/inc/lib/ajax_controller.class.php deleted file mode 100755 index d2dfa4d320..0000000000 --- a/main/inc/lib/ajax_controller.class.php +++ /dev/null @@ -1,74 +0,0 @@ -run(); - * - * @author Laurent Opprecht for the Univesity of Genevas - * @license /license.txt - */ -class AjaxController extends \Controller -{ - /** - * Returns an HTML error message for forbidden access - * @return bool|void - * @assert () === null - */ - function forbidden() - { - $this->response(false, get_lang('YouAreNotAuthorized')); - } - - /** - * Returns an HTML error message for unknown action - * @return bool|void - * @assert () === null - */ - public function unknown() - { - $this->response(false, get_lang('UnknownAction')); - } - - /** - * Action exists but implementation is missing. - * @return bool|void - * @assert () === null - */ - public function missing() - { - $this->response(false, get_lang('NoImplementation')); - } - - /** - * Display a standard json responce. - * - * @param bool $success - * @param string $message - * @param object $data - * @return bool|void - * @assert () === null - */ - public function response($success = false, $message = '', $data = null) - { - $message = trim($message); - $response = (object) array(); - $response->success = $success; - if ($message) { - $response->message = Display::return_message($message, $success ? 'normal' : 'error'); - } else { - $response->message = ''; - } - $response->data = $data; - $this->render_json($response); - } - -} diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index b3fd57bbbc..ad3f8be5eb 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -19,7 +19,7 @@ define('REQUIRED_MIN_MEMORY_LIMIT', '128'); define('REQUIRED_MIN_UPLOAD_MAX_FILESIZE', '10'); define('REQUIRED_MIN_POST_MAX_SIZE', '10'); -use \ChamiloSession as Session; +use ChamiloSession as Session; // USER STATUS CONSTANTS /** global status of a user: student */ @@ -1296,27 +1296,32 @@ function api_get_user_id() { */ function api_get_user_courses($userid, $fetch_session = true) { + // Get out if not integer if ($userid != strval(intval($userid))) { return array(); - } //get out if not integer + } + $t_course = Database::get_main_table(TABLE_MAIN_COURSE); $t_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); - $sql = "SELECT cc.code code, cc.db_name db, cc.directory dir, cu.status status + $sql = "SELECT cc.code code, cc.directory dir, cu.status status FROM $t_course cc, $t_course_user cu WHERE - cc.code = cu.course_code AND + cc.id = cu.c_id AND cu.user_id = '".$userid."' AND cu.relation_type<>".COURSE_RELATION_TYPE_RRHH." "; $result = Database::query($sql); if ($result === false) { return array(); } + + $courses = array(); while ($row = Database::fetch_array($result)) { // we only need the database name of the course $courses[] = $row; } + return $courses; } @@ -1349,12 +1354,12 @@ function _api_format_user($user, $add_password = false) $result['complete_name_with_username'] = $result['complete_name'].' ('.$user['username'].')'; } - $result['firstname'] = $firstname; - $result['lastname'] = $lastname; + $result['firstname'] = $firstname; + $result['lastname'] = $lastname; // Kept for historical reasons - $result['firstName'] = $firstname; - $result['lastName'] = $lastname; + $result['firstName'] = $firstname; + $result['lastName'] = $lastname; $attributes = array( 'phone', @@ -1408,12 +1413,11 @@ function _api_format_user($user, $add_password = false) $result['lastLogin'] = $last_login; // Getting user avatar. - $picture_filename = trim($result['picture_uri']); - $result['avatar'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg'; - $result['avatar_small'] = api_get_path(WEB_CODE_PATH).'img/unknown_22.jpg'; - $result['avatar_sys_path'] = api_get_path(SYS_CODE_PATH).'img/unknown.jpg'; - $dir = 'upload/users/'.$user_id.'/'; + $result['avatar'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg'; + $result['avatar_small'] = api_get_path(WEB_CODE_PATH).'img/unknown_22.jpg'; + $result['avatar_sys_path'] = api_get_path(SYS_CODE_PATH).'img/unknown.jpg'; + $dir = 'upload/users/'.$user_id.'/'; //if (!empty($picture_filename) && api_is_anonymous() ) { //Why you have to be anonymous? if (!empty($picture_filename)) { @@ -1455,6 +1459,8 @@ function _api_format_user($user, $add_password = false) $result['password'] = $user['password']; } + $result['profile_url'] = api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user_id; + return $result; } @@ -1784,10 +1790,9 @@ function api_format_course_array($course_data) { //@todo should be deprecated // Use as key in db list. - $_course['dbName'] = $course_data['db_name']; - $_course['db_name'] = $course_data['db_name']; + //$_course['dbName'] = $course_data['db_name']; + //$_course['db_name'] = $course_data['db_name']; // Use in all queries. - $_course['dbNameGlu'] = $_configuration['table_prefix'] . $course_data['db_name'] . $_configuration['db_glue']; $_course['titular'] = $course_data['tutor_name']; $_course['language'] = $course_data['course_language']; @@ -2149,7 +2154,7 @@ function api_get_session_info($session_id) { /** * Gets the session visibility by session id * @param int $session_id - * @param string $course_code + * @param int $courseId * @param bool $ignore_visibility_for_admins * @return int * 0 = session still available, @@ -2159,7 +2164,7 @@ function api_get_session_info($session_id) { */ function api_get_session_visibility( $session_id, - $course_code = null, + $courseId = null, $ignore_visibility_for_admins = true ) { // Means that the session is still available. @@ -2261,7 +2266,7 @@ function api_get_session_visibility( /* If I'm a coach the visibility can change in my favor depending in the nb_days_access_after_end and nb_days_access_before_beginning */ - $is_coach = api_is_coach($session_id, $course_code); + $is_coach = api_is_coach($session_id, $courseId); if ($is_coach) { // Test end date. @@ -2360,12 +2365,12 @@ function api_get_session_condition( /** * This function returns information about coaches from a course in session - * @param int - optional, session id - * @param string - optional, course code - * @return array - array containing user_id, lastname, firstname, username + * @param int optional, session id + * @param int $courseId + * @return array array containing user_id, lastname, firstname, username * @deprecated use CourseManager::get_coaches_from_course */ -function api_get_coachs_from_course($session_id=0,$course_code='') +function api_get_coachs_from_course($session_id = 0, $courseId = '') { if (!empty($session_id)) { $session_id = intval($session_id); @@ -2373,22 +2378,26 @@ function api_get_coachs_from_course($session_id=0,$course_code='') $session_id = api_get_session_id(); } - if (!empty($course_code)) { - $course_code = Database::escape_string($course_code); + if (!empty($courseId)) { + $courseId = intval($courseId); } else { - $course_code = api_get_course_id(); + $courseId = api_get_course_int_id(); } $tbl_user = Database:: get_main_table(TABLE_MAIN_USER); $tbl_session_course_user = Database:: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $coaches = array(); - $sql = "SELECT u.user_id,u.lastname,u.firstname,u.username - FROM $tbl_user u,$tbl_session_course_user scu + $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 + u.user_id = scu.user_id AND + scu.session_id = '$session_id' AND + scu.c_id = '$courseId' AND scu.status = 2"; $rs = Database::query($sql); @@ -2396,8 +2405,10 @@ function api_get_coachs_from_course($session_id=0,$course_code='') while ($row = Database::fetch_array($rs)) { $coaches[] = $row; } + return $coaches; } else { + return false; } } @@ -2641,9 +2652,10 @@ function api_get_user_platform_status($user_id = null) { $session_status = array('id' => $session_id, 'course_id' => $course_id); $session_user_status = SessionManager::get_user_status_in_course_session( $user_id, - $course_code, + $course_id, $session_id ); + switch ($session_user_status) { case 0: $session_status['status'] = 'student'; @@ -2689,40 +2701,43 @@ function api_get_user_platform_status($user_id = null) { /** * @param int $user_id - * @param string $course_code + * @param int $courseId * @param int $session_id * @return bool */ -function api_is_course_session_coach($user_id, $course_code, $session_id) +function api_is_course_session_coach($user_id, $courseId, $session_id) { - $session_table = Database::get_main_table(TABLE_MAIN_SESSION); + $session_table = Database::get_main_table(TABLE_MAIN_SESSION); $session_rel_course_rel_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $user_id = intval($user_id); $session_id = intval($session_id); - $course_code = Database::escape_string($course_code); + $courseId = intval($courseId); - $sql = "SELECT DISTINCT id + $sql = "SELECT DISTINCT session.id FROM $session_table INNER JOIN $session_rel_course_rel_user_table session_rc_ru - ON session.id = session_rc_ru.id_session + ON session.id = session_rc_ru.session_id WHERE - session_rc_ru.id_user = '".$user_id."' AND - session_rc_ru.course_code = '$course_code' AND + session_rc_ru.user_id = '".$user_id."' AND + session_rc_ru.c_id = '$courseId' AND session_rc_ru.status = 2 AND - session_rc_ru.id_session = '$session_id'"; + session_rc_ru.session_id = '$session_id'"; $result = Database::query($sql); + return Database::num_rows($result) > 0; } /** * Checks whether the current user is a course or session coach * @param int - optional, session id - * @param string - optional, course code + * @param int $courseId * @return boolean True if current user is a course or session coach */ -function api_is_coach($session_id = 0, $course_code = null, $check_student_view = true) +function api_is_coach($session_id = 0, $courseId = null, $check_student_view = true) { + $userId = api_get_user_id(); + if (!empty($session_id)) { $session_id = intval($session_id); } else { @@ -2736,24 +2751,24 @@ function api_is_coach($session_id = 0, $course_code = null, $check_student_view return false; } - if (!empty($course_code)) { - $course_code = Database::escape_string($course_code); + if (!empty($courseId)) { + $courseId = intval($courseId); } else { - $course_code = api_get_course_id(); + $courseId = api_get_course_int_id(); } $session_table = Database::get_main_table(TABLE_MAIN_SESSION); $session_rel_course_rel_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $sessionIsCoach = null; if (!empty($course_code)) { - $sql = "SELECT DISTINCT id, name, date_start, date_end - FROM $session_table + $sql = "SELECT DISTINCT s.id, name, date_start, date_end + FROM $session_table s INNER JOIN $session_rel_course_rel_user_table session_rc_ru - ON session_rc_ru.id_session = id AND session_rc_ru.id_user = '".api_get_user_id()."' + ON session_rc_ru.session_id = s.id AND session_rc_ru.user_id = '".$userId."' WHERE - session_rc_ru.course_code = '$course_code' AND + session_rc_ru.c_id = '$courseId' AND session_rc_ru.status = 2 AND - session_rc_ru.id_session = '$session_id'"; + session_rc_ru.session_id = '$session_id'"; $result = Database::query($sql); $sessionIsCoach = Database::store_result($result); } @@ -2761,7 +2776,7 @@ function api_is_coach($session_id = 0, $course_code = null, $check_student_view if (!empty($session_id)) { $sql = "SELECT DISTINCT id, name, date_start, date_end FROM $session_table - WHERE session.id_coach = '".api_get_user_id()."' AND id = '$session_id' + WHERE session.id_coach = '".$userId."' AND id = '$session_id' ORDER BY date_start, date_end, name"; $result = Database::query($sql); if (!empty($sessionIsCoach)) { @@ -3278,7 +3293,6 @@ function api_not_allowed($print_headers = false, $message = null) $osso->logout(); } } - Header::response_code(403); $home_url = api_get_path(WEB_PATH); $user_id = api_get_user_id(); $course = api_get_course_id(); @@ -3484,8 +3498,8 @@ function api_get_item_visibility($_course, $tool, $id, $session = 0) c_id = $course_id AND tool = '$tool' AND ref = $id AND - (id_session = $session OR id_session = 0) - ORDER BY id_session DESC, lastedit_date DESC + (session_id = $session OR session_id = 0) + ORDER BY session_id DESC, lastedit_date DESC LIMIT 1"; $res = Database::query($sql); @@ -3546,7 +3560,7 @@ function api_item_property_delete( c_id = $courseId AND tool = '$tool' AND ref = $itemId AND - id_session = $sessionId + session_id = $sessionId $userCondition $groupCondition "; @@ -3607,8 +3621,8 @@ function api_item_property_update( $to_user_id = intval($to_user_id); $start_visible = Database::escape_string($start_visible); $end_visible = Database::escape_string($end_visible); - $start_visible = ($start_visible == 0) ? '0000-00-00 00:00:00' : $start_visible; - $end_visible = ($end_visible == 0) ? '0000-00-00 00:00:00' : $end_visible; + $start_visible = $start_visible == 0 ? '0000-00-00 00:00:00' : $start_visible; + $end_visible = $end_visible == 0 ? '0000-00-00 00:00:00' : $end_visible; $to_filter = ''; $time = api_get_utc_datetime(); @@ -3638,7 +3652,7 @@ function api_item_property_update( // 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' "; + $condition_session = " AND session_id = '$session_id' "; } $filter = " c_id = $course_id AND tool='$tool' AND ref='$item_id' $condition_session "; @@ -3674,12 +3688,12 @@ function api_item_property_update( $visibility = '2'; if (!empty($session_id)) { // Check whether session id already exist into itemp_properties for updating visibility or add it. - $sql = "SELECT id_session FROM $TABLE_ITEMPROPERTY + $sql = "SELECT session_id FROM $TABLE_ITEMPROPERTY WHERE c_id = $course_id AND tool = '$tool' AND ref='$item_id' AND - id_session = '$session_id'"; + session_id = '$session_id'"; $rs = Database::query($sql); if (Database::num_rows($rs) > 0) { $sql = "UPDATE $TABLE_ITEMPROPERTY @@ -3687,11 +3701,17 @@ function api_item_property_update( lastedit_date = '$time', lastedit_user_id = '$user_id', visibility = '$visibility', - id_session = '$session_id' $set_type + session_id = '$session_id' $set_type WHERE $filter"; + $result = Database::query($sql); } else { - $sql = "INSERT INTO $TABLE_ITEMPROPERTY (c_id, tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session) + $sql = "INSERT INTO $TABLE_ITEMPROPERTY (c_id, tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, session_id) VALUES ($course_id, '$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value', '$visibility', '$start_visible','$end_visible', '$session_id')"; + $result = Database::query($sql); + + $id = Database::insert_id(); + $sql = "UPDATE $TABLE_ITEMPROPERTY SET id = iid WHERE iid = $id"; + Database::query($sql); } } else { $sql = "UPDATE $TABLE_ITEMPROPERTY @@ -3701,18 +3721,19 @@ function api_item_property_update( lastedit_user_id = '$user_id', visibility='$visibility' $set_type WHERE $filter"; + $result = Database::query($sql); } break; case 'visible' : // Change item to visible. $visibility = '1'; if (!empty($session_id)) { // Check whether session id already exist into item_properties for updating visibility or add it. - $sql = "SELECT id_session FROM $TABLE_ITEMPROPERTY + $sql = "SELECT session_id FROM $TABLE_ITEMPROPERTY WHERE c_id = $course_id AND tool = '$tool' AND ref = '$item_id' AND - id_session = '$session_id'"; + session_id = '$session_id'"; $rs = Database::query($sql); if (Database::num_rows($rs) > 0) { $sql = "UPDATE $TABLE_ITEMPROPERTY @@ -3721,11 +3742,16 @@ function api_item_property_update( lastedit_date='$time', lastedit_user_id = '$user_id', visibility='$visibility', - id_session = '$session_id' $set_type + session_id = '$session_id' $set_type WHERE $filter"; } else { - $sql = "INSERT INTO $TABLE_ITEMPROPERTY (c_id, tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session) + $sql = "INSERT INTO $TABLE_ITEMPROPERTY (c_id, tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, session_id) VALUES ($course_id, '$tool', '$item_id', '$time', '$user_id', '$time', '$lastedit_type', '$user_id', '$to_value', '$visibility', '$start_visible', '$end_visible', '$session_id')"; + $result = Database::query($sql); + + $id = Database::insert_id(); + $sql = "UPDATE $TABLE_ITEMPROPERTY SET id = iid WHERE iid = $id"; + Database::query($sql); } } else { $sql = "UPDATE $TABLE_ITEMPROPERTY @@ -3735,18 +3761,19 @@ function api_item_property_update( lastedit_user_id='$user_id', visibility='$visibility' $set_type WHERE $filter"; + $result = Database::query($sql); } break; case 'invisible' : // Change item to invisible. $visibility = '0'; if (!empty($session_id)) { // Check whether session id already exist into item_properties for updating visibility or add it - $sql = "SELECT id_session FROM $TABLE_ITEMPROPERTY + $sql = "SELECT session_id FROM $TABLE_ITEMPROPERTY WHERE c_id = $course_id AND tool = '$tool' AND ref='$item_id' AND - id_session = '$session_id'"; + session_id = '$session_id'"; $rs = Database::query($sql); if (Database::num_rows($rs) > 0) { $sql = "UPDATE $TABLE_ITEMPROPERTY @@ -3755,11 +3782,17 @@ function api_item_property_update( lastedit_date = '$time', lastedit_user_id='$user_id', visibility = '$visibility', - id_session = '$session_id' $set_type + session_id = '$session_id' $set_type WHERE $filter"; + $result = Database::query($sql); } else { - $sql = "INSERT INTO $TABLE_ITEMPROPERTY (c_id, tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session) + $sql = "INSERT INTO $TABLE_ITEMPROPERTY (c_id, tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, session_id) VALUES ($course_id, '$tool', '$item_id', '$time', '$user_id', '$time', '$lastedit_type', '$user_id', '$to_value', '$visibility', '$start_visible', '$end_visible', '$session_id')"; + $result = Database::query($sql); + + $id = Database::insert_id(); + $sql = "UPDATE $TABLE_ITEMPROPERTY SET id = iid WHERE iid = $id"; + Database::query($sql); } } else { $sql = "UPDATE $TABLE_ITEMPROPERTY @@ -3769,6 +3802,7 @@ function api_item_property_update( lastedit_user_id = '$user_id', visibility = '$visibility' $set_type WHERE $filter"; + $result = Database::query($sql); } break; default : // The item will be added or updated. @@ -3780,14 +3814,18 @@ function api_item_property_update( lastedit_date = '$time', lastedit_user_id='$user_id' $set_type WHERE $filter"; + $result = Database::query($sql); } - $result = Database::query($sql); + // Insert if no entries are found (can only happen in case of $lastedit_type switch is 'default'). if (Database::affected_rows($result) == 0) { - $sql = "INSERT INTO $TABLE_ITEMPROPERTY (c_id, tool,ref,insert_date,insert_user_id,lastedit_date,lastedit_type, lastedit_user_id, $to_field, visibility, start_visible, end_visible, id_session) + $sql = "INSERT INTO $TABLE_ITEMPROPERTY (c_id, tool,ref,insert_date,insert_user_id,lastedit_date,lastedit_type, lastedit_user_id, $to_field, visibility, start_visible, end_visible, session_id) VALUES ($course_id, '$tool', '$item_id', '$time', '$user_id', '$time', '$lastedit_type', '$user_id', '$to_value', '$visibility', '$start_visible', '$end_visible', '$session_id')"; $res = Database::query($sql); if (!$res) { + $id = Database::insert_id(); + $sql = "UPDATE $TABLE_ITEMPROPERTY SET id = iid WHERE iid = $id"; + Database::query($sql); return false; } } @@ -3808,7 +3846,7 @@ function api_get_item_property_by_tool($tool, $course_code, $session_id = null) // Definition of tables. $item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY); $session_id = intval($session_id); - $session_condition = ' AND id_session = '.$session_id; + $session_condition = ' AND session_id = '.$session_id; $course_id = $course_info['real_id']; $sql = "SELECT * FROM $item_property_table @@ -3847,7 +3885,7 @@ function api_get_item_property_list_by_tool_by_user( // Definition of tables. $item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY); - $session_condition = ' AND id_session = '.$session_id; + $session_condition = ' AND session_id = '.$session_id; $sql = "SELECT * FROM $item_property_table WHERE insert_user_id = $userId AND @@ -3972,7 +4010,7 @@ function api_get_item_property_info($course_id, $tool, $ref, $session_id = 0) c_id = $course_id AND tool = '$tool' AND ref = $ref AND - id_session = $session_id "; + session_id = $session_id "; $rs = Database::query($sql); $row = array(); @@ -4293,7 +4331,7 @@ function api_max_sort_value($user_course_category, $user_id) WHERE user_id='".intval($user_id)."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." AND - user_course_cat='".Database::escape_string($user_course_category)."'"; + user_course_cat='".intval($user_course_category)."'"; $result_max = Database::query($sql); if (Database::num_rows($result_max) == 1) { $row_max = Database::fetch_array($result_max); @@ -4319,14 +4357,6 @@ function api_string_2_boolean($string) { return false; } -/** - * Too keep BC - * @deprecated use api_string_2_boolean - */ -function string_2_boolean($string) { - return api_string_2_boolean($string); -} - /** * Determines the number of plugins installed for a given location */ @@ -4335,21 +4365,6 @@ function api_number_of_plugins($location) { return isset($_plugins[$location]) && is_array($_plugins[$location]) ? count($_plugins[$location]) : 0; } -/** - * Including the necessary plugins. - * @author Patrick Cool , Ghent University - * @deprecated use AppPlugin::get_all_plugin_contents_by_region function - */ -function api_plugin($location) { - global $_plugins; - if (isset($_plugins[$location]) && is_array($_plugins[$location])) { - foreach ($_plugins[$location] as $this_plugin) { - include api_get_path(SYS_PLUGIN_PATH)."$this_plugin/index.php"; - } - } - return false; -} - /** * Checks to see wether a certain plugin is installed. * @return boolean true if the plugin is installed, false otherwise. @@ -4648,7 +4663,22 @@ function copy_folder_course_session( session_id = '$session_id'"; Database::query($sql); $document_id = Database::insert_id(); - api_item_property_update($course_info,TOOL_DOCUMENT,$document_id,'FolderCreated',api_get_user_id(),0,0,null,null,$session_id); + + $sql = "UPDATE $tbl_course_description SET id = iid WHERE iid = $document_id"; + Database::query($sql); + + api_item_property_update( + $course_info, + TOOL_DOCUMENT, + $document_id, + 'FolderCreated', + api_get_user_id(), + 0, + 0, + null, + null, + $session_id + ); } } @@ -4976,14 +5006,9 @@ function api_set_setting($var, $value, $subvar = null, $cat = null, $access_url if (Database::num_rows($res) > 0) { // We have a setting for access_url 1, but none for the current one, so create one. $row = Database::fetch_array($res); - $insert = "INSERT INTO $t_settings " . - "(variable,subkey," . - "type,category," . - "selected_value,title," . - "comment,scope," . - "subkeytext,access_url)" . - " VALUES " . - "('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," . + $insert = "INSERT INTO $t_settings (variable, subkey, type,category, selected_value, title, comment, scope, subkeytext, access_url) + VALUES + ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," . "'".$row['type']."','".$row['category']."'," . "'$value','".$row['title']."'," . "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," . @@ -5005,14 +5030,8 @@ function api_set_setting($var, $value, $subvar = null, $cat = null, $access_url if (Database::num_rows($res) > 0) { // We have a setting for access_url 1, but none for the current one, so create one. $row = Database::fetch_array($res); if ($row['access_url_changeable'] == 1) { - $insert = "INSERT INTO $t_settings " . - "(variable,subkey," . - "type,category," . - "selected_value,title," . - "comment,scope," . - "subkeytext,access_url, access_url_changeable)" . - " VALUES " . - "('".$row['variable']."',". + $insert = "INSERT INTO $t_settings (variable,subkey, type,category, selected_value,title, comment,scope, subkeytext,access_url, access_url_changeable) VALUES + ('".$row['variable']."',". (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," . "'".$row['type']."','".$row['category']."'," . "'$value','".$row['title']."'," . @@ -5064,7 +5083,8 @@ function api_set_settings_category($category, $value = null, $access_url = 1, $f $res = Database::query($sql); return $res !== false; } else { - $sql = "UPDATE $t_s SET selected_value = NULL WHERE category = '$category' AND access_url = $access_url"; + $sql = "UPDATE $t_s SET selected_value = NULL + WHERE category = '$category' AND access_url = $access_url"; if (is_array($fieldtype) && count($fieldtype)>0) { $sql .= " AND ( "; $i = 0; @@ -5161,15 +5181,17 @@ function api_add_access_url($u, $d = '', $a = 1) { * @param int Access URL's ID. Optional. Uses 1 by default, which is the unique URL * @return array Array of database results for the current settings of the current access URL */ -function & api_get_settings($cat = null, $ordering = 'list', $access_url = 1, $url_changeable = 0) { - $t_cs = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); +function & api_get_settings($cat = null, $ordering = 'list', $access_url = 1, $url_changeable = 0) +{ + $table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); $access_url = (int) $access_url; $where_condition = ''; if ($url_changeable == 1) { $where_condition = " AND access_url_changeable= '1' "; } if (empty($access_url) or $access_url == -1) { $access_url = 1; } - $sql = "SELECT * FROM $t_cs WHERE access_url = $access_url $where_condition "; + $sql = "SELECT * FROM $table + WHERE access_url = $access_url $where_condition "; if (!empty($cat)) { $cat = Database::escape_string($cat); @@ -5362,6 +5384,10 @@ function api_is_course_visible_for_user($userid = null, $cid = null) { } } $cid = Database::escape_string($cid); + + $courseInfo = api_get_course_info($cid); + $courseId = $courseInfo['real_id']; + global $is_platformAdmin; $course_table = Database::get_main_table(TABLE_MAIN_COURSE); @@ -5395,14 +5421,12 @@ function api_is_course_visible_for_user($userid = null, $cid = null) { $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $sql = "SELECT - tutor_id, status, role + is_tutor, status FROM $tbl_course_user WHERE - user_id = '$userid' - AND - relation_type <> '".COURSE_RELATION_TYPE_RRHH."' - AND - course_code = '$cid' + user_id = '$userid' AND + relation_type <> '".COURSE_RELATION_TYPE_RRHH."' AND + c_id = $courseId LIMIT 1"; $result = Database::query($sql); @@ -5410,12 +5434,11 @@ function api_is_course_visible_for_user($userid = null, $cid = null) { if (Database::num_rows($result) > 0) { // This user has got a recorded state for this course. $cuData = Database::fetch_array($result); - - $_courseUser['role'] = $cuData['role']; - $is_courseMember = true; - $is_courseTutor = ($cuData['tutor_id' ] == 1); - $is_courseAdmin = ($cuData['status'] == 1); + $is_courseMember = true; + $is_courseTutor = ($cuData['is_tutor'] == 1); + $is_courseAdmin = ($cuData['status'] == 1); } + if (!$is_courseAdmin) { // This user has no status related to this course. // Is it the session coach or the session admin? @@ -5428,24 +5451,21 @@ function api_is_course_visible_for_user($userid = null, $cid = null) { FROM $tbl_session as session INNER JOIN $tbl_session_course - ON session_rel_course.id_session = session.id - AND session_rel_course.course_code = '$cid' + ON session_rel_course.session_id = session.id + AND session_rel_course.c_id = '$courseId' LIMIT 1"; $result = Database::query($sql); $row = Database::store_result($result); if ($row[0]['id_coach'] == $userid) { - $_courseUser['role'] = 'Professor'; $is_courseMember = true; $is_courseTutor = true; $is_courseAdmin = false; $is_courseCoach = true; $is_sessionAdmin = false; - Session::write('_courseUser',$_courseUser); } elseif ($row[0]['session_admin_id'] == $userid) { - $_courseUser['role'] = 'Professor'; $is_courseMember = false; $is_courseTutor = false; $is_courseAdmin = false; @@ -5455,7 +5475,7 @@ function api_is_course_visible_for_user($userid = null, $cid = null) { // Check if the current user is the course coach. $sql = "SELECT 1 FROM $tbl_session_course - WHERE session_rel_course.course_code = '$cid' + WHERE session_rel_course.c_id = '$courseId' AND session_rel_course.id_coach = '$userid' LIMIT 1"; @@ -5463,7 +5483,6 @@ function api_is_course_visible_for_user($userid = null, $cid = null) { //if ($row = Database::fetch_array($result)) { if (Database::num_rows($result) > 0 ) { - $_courseUser['role'] = 'Professor'; $is_courseMember = true; $is_courseTutor = true; $is_courseCoach = true; @@ -5472,7 +5491,8 @@ function api_is_course_visible_for_user($userid = null, $cid = null) { $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); $sql = "SELECT status FROM $tbl_user - WHERE user_id = $userid LIMIT 1"; + WHERE user_id = $userid + LIMIT 1"; $result = Database::query($sql); @@ -5484,18 +5504,19 @@ function api_is_course_visible_for_user($userid = null, $cid = null) { } else { // Check if the user is a student is this session. $sql = "SELECT id - FROM $tbl_session_course_user - WHERE id_user = '$userid' - AND course_code = '$cid' + FROM $tbl_session_course_user + WHERE + user_id = '$userid' AND + c_id = '$courseId' LIMIT 1"; if (Database::num_rows($result) > 0) { // This user haa got a recorded state for this course. while ($row = Database::fetch_array($result)) { - $is_courseMember = true; - $is_courseTutor = false; - $is_courseAdmin = false; - $is_sessionAdmin = false; + $is_courseMember = true; + $is_courseTutor = false; + $is_courseAdmin = false; + $is_sessionAdmin = false; } } } @@ -5513,6 +5534,7 @@ function api_is_course_visible_for_user($userid = null, $cid = null) { case COURSE_VISIBILITY_HIDDEN: return $is_platformAdmin; } + return false; } @@ -5701,17 +5723,18 @@ function api_get_access_url_from_user($user_id) { /** * Gets the status of a user in a course * @param int $user_id - * @param string $course_code + * @param int $courseId * @return int user status */ -function api_get_status_of_user_in_course ($user_id, $course_code) { +function api_get_status_of_user_in_course($user_id, $courseId) +{ $tbl_rel_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - if (!empty($user_id) && !empty($course_code)) { + if (!empty($user_id) && !empty($courseId)) { $user_id = intval($user_id); - $course_code = Database::escape_string($course_code); + $courseId = intval($courseId); $sql = 'SELECT status FROM '.$tbl_rel_course_user.' - WHERE user_id='.$user_id.' AND course_code="'.$course_code.'";'; + WHERE user_id='.$user_id.' AND c_id = '.$courseId; $result = Database::query($sql); $row_status = Database::fetch_array($result, 'ASSOC'); return $row_status['status']; @@ -5797,16 +5820,16 @@ function api_is_valid_secret_key($original_key_secret, $security_key) { /** * Checks whether a user is into course - * @param string $course_id - the course id + * @param int $course_id - the course id * @param int $user_id - the user id */ function api_is_user_of_course($course_id, $user_id) { $tbl_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); $sql = 'SELECT user_id FROM '.$tbl_course_rel_user.' WHERE - course_code="'.Database::escape_string($course_id).'" AND - user_id="'.intval($user_id).'" AND - relation_type<>'.COURSE_RELATION_TYPE_RRHH.' '; + c_id ="'.intval($course_id).'" AND + user_id = "'.intval($user_id).'" AND + relation_type <> '.COURSE_RELATION_TYPE_RRHH.' '; $result = Database::query($sql); return Database::num_rows($result) == 1; } @@ -6002,159 +6025,6 @@ function shorten($input, $length = 15, $encoding = null) { return api_trunc_str($input, $length, '...', false, $encoding); } -/** - * DEPRECATED, use api_get_setting instead - */ -function get_setting($variable, $key = NULL) { - global $_setting; - return api_get_setting($variable, $key); -} - -/** - * deprecated: use api_is_allowed_to_edit() instead - */ -function is_allowed_to_edit() { - return api_is_allowed_to_edit(); -} - -/** - * deprecated: 19-SEP-2009: Use api_get_path(TO_SYS, $url) instead. - */ -function api_url_to_local_path($url) { - return api_get_path(TO_SYS, $url); -} - -/** - * @deprecated 27-SEP-2009: Use Database::store_result($result) instead. - */ -function api_store_result($result) { - return Database::store_result($result); -} - -/** - * @deprecated 28-SEP-2009: Use Database::query($query, $file, $line) instead. - */ -function api_sql_query($query, $file = '', $line = 0) { - return Database::query($query, $file, $line); -} - -/** - * @deprecated 25-JAN-2010: See api_mail() and api_mail_html(), mail.lib.inc.php - * - * Send an email. - * - * Wrapper function for the standard php mail() function. Change this function - * to your needs. The parameters must follow the same rules as the standard php - * mail() function. Please look at the documentation on http://php.net/manual/en/function.mail.php - * @param string $to - * @param string $subject - * @param string $message - * @param string $additional_headers - * @param string $additionalParameters - * @author Ivan Tcholakov, 04-OCT-2009, a reworked version of this function. - * @link http://www.dokeos.com/forum/viewtopic.php?t=15557 - */ -function api_send_mail($to, $subject, $message, $additional_headers = null, $additionalParameters = array()) -{ - if (empty($platform_email['SMTP_FROM_NAME'])) { - $platform_email['SMTP_FROM_NAME'] = api_get_person_name( - api_get_setting('administratorName'), - api_get_setting('administratorSurname'), - null, - PERSON_NAME_EMAIL_ADDRESS - ); - } - - if (empty($platform_email['SMTP_FROM_EMAIL'])) { - $platform_email['SMTP_FROM_EMAIL'] = api_get_setting('emailAdministrator'); - } - - $matches = array(); - if (preg_match('/([^<]*)<(.+)>/si', $to, $matches)) { - $recipient_name = trim($matches[1]); - $recipient_email = trim($matches[2]); - } else { - $recipient_name = ''; - $recipient_email = trim($to); - } - - $sender_name = ''; - $sender_email = ''; - $extra_headers = $additional_headers; - - // Regular expression to test for valid email address. - // This should actually be revised to use the complete RFC3696 description. - // http://tools.ietf.org/html/rfc3696#section-3 - //$regexp = "^[0-9a-z_\.+-]+@(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2,3})$"; // Deprecated, 13-OCT-2010. - - $mail = new PHPMailer(); - $mail->CharSet = $platform_email['SMTP_CHARSET']; - $mail->Mailer = $platform_email['SMTP_MAILER']; - $mail->Host = $platform_email['SMTP_HOST']; - $mail->Port = $platform_email['SMTP_PORT']; - - if ($platform_email['SMTP_AUTH']) { - $mail->SMTPAuth = 1; - $mail->Username = $platform_email['SMTP_USER']; - $mail->Password = $platform_email['SMTP_PASS']; - } - - $mail->Priority = 3; // 5 = low, 1 = high - $mail->AddCustomHeader('Errors-To: '.$platform_email['SMTP_FROM_EMAIL']); - $mail->IsHTML(0); - $mail->SMTPKeepAlive = true; - - // Attachments. - // $mail->AddAttachment($path); - // $mail->AddAttachment($path, $filename); - - if ($sender_email != '') { - $mail->From = $sender_email; - $mail->Sender = $sender_email; - } else { - $mail->From = $platform_email['SMTP_FROM_EMAIL']; - $mail->Sender = $platform_email['SMTP_FROM_EMAIL']; - } - - if ($sender_name != '') { - $mail->FromName = $sender_name; - } else { - $mail->FromName = $platform_email['SMTP_FROM_NAME']; - } - $mail->Subject = $subject; - $mail->Body = $message; - - // Only valid address are to be accepted. - if (api_valid_email($recipient_email)) { - $mail->AddAddress($recipient_email, $recipient_name); - } - - if ($extra_headers != '') { - $mail->AddCustomHeader($extra_headers); - } - - // Send mail. - if (!$mail->Send()) { - return 0; - } - - $plugin = new AppPlugin(); - $installedPluginsList = $plugin->getInstalledPluginListObject(); - foreach ($installedPluginsList as $installedPlugin) { - if ($installedPlugin->isMailPlugin and array_key_exists("smsType", $additionalParameters)) { - $className = str_replace("Plugin", "", get_class($installedPlugin)); - $smsObject = new $className; - $smsObject->send($additionalParameters); - } - } - - // Clear all the addresses. - $mail->ClearAddresses(); - return 1; -} - -/* END OF DEPRECATED FUNCTIONS SECTION */ - /** * Function used to protect a "global" admin script. @@ -6883,7 +6753,8 @@ function api_is_global_chat_enabled() * @todo Fix tool_visible_by_default_at_creation labels * @todo Add sessionId parameter to avoid using context */ -function api_set_default_visibility($item_id, $tool_id, $group_id = null) { +function api_set_default_visibility($item_id, $tool_id, $group_id = null) +{ $original_tool_id = $tool_id; switch ($tool_id) { @@ -6962,10 +6833,19 @@ function api_get_security_key() { return $_configuration['security_key']; } -function api_detect_user_roles($user_id, $course_code, $session_id = 0) { +/** + * @param int $user_id + * @param int $courseId + * @param int $session_id + * @return array + */ +function api_detect_user_roles($user_id, $courseId, $session_id = 0) +{ $user_roles = array(); /*$user_info = api_get_user_info($user_id); $user_roles[] = $user_info['status'];*/ + $courseInfo = api_get_course_info_by_id($courseId); + $course_code = $courseInfo['code']; $url_id = api_get_current_access_url_id(); if (api_is_platform_admin_by_id($user_id, $url_id)) { @@ -6995,7 +6875,11 @@ function api_detect_user_roles($user_id, $course_code, $session_id = 0) { $user_roles[] = COURSE_STUDENT; } } else { - $user_status_in_session = SessionManager::get_user_status_in_course_session($user_id, $course_code, $session_id); + $user_status_in_session = SessionManager::get_user_status_in_course_session( + $user_id, + $courseId, + $session_id + ); if (!empty($user_status_in_session)) { if ($user_status_in_session == 0) { @@ -7044,11 +6928,17 @@ function role_actions() { ); } -function api_coach_can_edit_view_results($course_code = null, $session_id = null) { +/** + * @param int $courseId + * @param int $session_id + * @return bool + */ +function api_coach_can_edit_view_results($courseId = null, $session_id = null) +{ $user_id = api_get_user_id(); - if (empty($course_code)) { - $course_code = api_get_course_id(); + if (empty($courseId)) { + $courseId = api_get_course_int_id(); } if (empty($session_id)) { @@ -7059,7 +6949,7 @@ function api_coach_can_edit_view_results($course_code = null, $session_id = null return true; } - $roles = api_detect_user_roles($user_id, $course_code, $session_id); + $roles = api_detect_user_roles($user_id, $courseId, $session_id); if (in_array(SESSION_COURSE_COACH, $roles)) { //return api_get_setting('session_tutor_reports_visibility') == 'true'; @@ -7318,7 +7208,7 @@ function api_block_account_captcha($username) global $_configuration; $minutesToBlock = isset($_configuration['captcha_time_to_block']) ? $_configuration['captcha_time_to_block'] : 10; $time = time() + $minutesToBlock*60; - Usermanager::update_extra_field_value($userInfo['user_id'], 'captcha_blocked_until_date', api_get_utc_datetime($time)); + UserManager::update_extra_field_value($userInfo['user_id'], 'captcha_blocked_until_date', api_get_utc_datetime($time)); } /** @@ -7331,7 +7221,7 @@ function api_clean_account_captcha($username) return false; } Session::erase('loginFailedCount'); - Usermanager::update_extra_field_value($userInfo['user_id'], 'captcha_blocked_until_date', null); + UserManager::update_extra_field_value($userInfo['user_id'], 'captcha_blocked_until_date', null); } /** @@ -8023,13 +7913,11 @@ function api_mail_html( return 0; } - $plugin = new AppPlugin(); - $installedPluginsList = $plugin->getInstalledPluginListObject(); - foreach ($installedPluginsList as $installedPlugin) { - if ($installedPlugin->isMailPlugin and array_key_exists("smsType", $additionalParameters)) { - $className = str_replace("Plugin", "", get_class($installedPlugin)); - $smsObject = new $className; - $smsObject->send($additionalParameters); + if (!empty($additionalParameters)) { + $plugin = new AppPlugin(); + $smsPlugin = $plugin->getSMSPluginLibrary(); + if ($smsPlugin) { + $smsPlugin->send($additionalParameters); } } diff --git a/main/inc/lib/attendance.lib.php b/main/inc/lib/attendance.lib.php index f87b856e83..d1634c90cf 100755 --- a/main/inc/lib/attendance.lib.php +++ b/main/inc/lib/attendance.lib.php @@ -288,13 +288,13 @@ class Attendance */ public function attendance_add($link_to_gradebook = false) { - global $_course; + $_course = api_get_course_info(); $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); - $table_link = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); - $session_id = api_get_session_id(); - $user_id = api_get_user_id(); - $course_code = api_get_course_id(); - $course_id = api_get_course_int_id(); + $table_link = Database:: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); + $session_id = api_get_session_id(); + $user_id = api_get_user_id(); + $course_code = api_get_course_id(); + $course_id = api_get_course_int_id(); $title_gradebook= Database::escape_string($this->attendance_qualify_title); $value_calification = 0; $weight_calification = floatval($this->attendance_weight); @@ -311,7 +311,19 @@ class Attendance if (!empty($affected_rows)) { // save inside item property table $last_id = Database::insert_id(); - api_item_property_update($_course, TOOL_ATTENDANCE, $last_id,"AttendanceAdded", $user_id); + if ($last_id) { + + $sql = "UPDATE $tbl_attendance SET id = iid WHERE iid = $last_id"; + Database::query($sql); + + api_item_property_update( + $_course, + TOOL_ATTENDANCE, + $last_id, + "AttendanceAdded", + $user_id + ); + } } // add link to gradebook if ($link_to_gradebook && !empty($this->category_id)) { @@ -569,6 +581,7 @@ class Attendance { $current_session_id = api_get_session_id(); $current_course_id = api_get_course_id(); + $currentCourseIntId = api_get_course_int_id(); $studentInGroup = array(); @@ -616,7 +629,7 @@ class Attendance if (api_get_session_id()) { $user_status_in_session = SessionManager::get_user_status_in_course_session( $uid, - $current_course_id, + $currentCourseIntId, $current_session_id ); } else { @@ -709,6 +722,11 @@ class Attendance attendance_calendar_id = '$calendar_id', presence = 1"; $result = Database::query($sql); + + $insertId = Database::insert_id(); + $sql = "UPDATE $tbl_attendance_sheet SET id = iid WHERE iid = $insertId"; + Database::query($sql); + $affected_rows += Database::affected_rows($result); } else { $sql = "UPDATE $tbl_attendance_sheet SET presence = 1 @@ -736,6 +754,11 @@ class Attendance attendance_calendar_id = '$calendar_id', presence = 0"; $result = Database::query($sql); + + $insertId = Database::insert_id(); + $sql = "UPDATE $tbl_attendance_sheet SET id = iid WHERE iid = $insertId"; + Database::query($sql); + $affected_rows += Database::affected_rows($result); } else { $sql = "UPDATE $tbl_attendance_sheet SET presence = 0 @@ -839,6 +862,10 @@ class Attendance attendance_id = '$attendance_id', score = '$count_presences'"; Database::query($sql); + + $insertId = Database::insert_id(); + $sql = "UPDATE $tbl_attendance_result SET id = iid WHERE iid = $insertId"; + Database::query($sql); } } } @@ -886,6 +913,11 @@ class Attendance $result = Database::query($ins); + $insertId = Database::insert_id(); + + $sql = "UPDATE $tbl_attendance_sheet_log SET id = iid WHERE iid = $insertId"; + Database::query($sql); + return Database::affected_rows($result); } @@ -1396,6 +1428,8 @@ class Attendance $id = Database::insert($tbl_attendance_calendar, $params); if ($id) { + $sql = "UPDATE $tbl_attendance_calendar SET id = iid WHERE iid = $id"; + Database::query($sql); $affected_rows++; } $this->addAttendanceCalendarToGroup($id, $course_id, $groupList); @@ -1437,7 +1471,10 @@ class Attendance 'c_id' => $courseId, 'group_id' => $groupId, ); - Database::insert($table, $params); + $insertId = Database::insert($table, $params); + + $sql = "UPDATE $table SET id = iid WHERE iid = $insertId"; + Database::query($sql); } } } diff --git a/main/inc/lib/auth.lib.php b/main/inc/lib/auth.lib.php index 16140df546..39a3437cd9 100755 --- a/main/inc/lib/auth.lib.php +++ b/main/inc/lib/auth.lib.php @@ -54,20 +54,28 @@ class Auth // Secondly we select the courses that are in a category (user_course_cat<>0) and sort these according to the sort of the category $user_id = intval($user_id); - $sql = "SELECT course.code k, course.visual_code vc, course.subscribe subscr, course.unsubscribe unsubscr, - course.title i, course.tutor_name t, course.db_name db, course.directory dir, course_rel_user.status status, - course_rel_user.sort sort, course_rel_user.user_course_cat user_course_cat + $sql = "SELECT + course.code k, + course.visual_code vc, + course.subscribe subscr, + course.unsubscribe unsubscr, + course.title i, + course.tutor_name t, + course.directory dir, + course_rel_user.status status, + course_rel_user.sort sort, + course_rel_user.user_course_cat user_course_cat FROM $TABLECOURS course, $TABLECOURSUSER course_rel_user - WHERE course.code = course_rel_user.course_code - AND course_rel_user.relation_type<>" . COURSE_RELATION_TYPE_RRHH . " - AND course_rel_user.user_id = '" . $user_id . "' $without_special_courses + WHERE + course.id = course_rel_user.c_id AND + course_rel_user.relation_type<>" . COURSE_RELATION_TYPE_RRHH . " AND + course_rel_user.user_id = '" . $user_id . "' $without_special_courses ORDER BY course_rel_user.sort ASC"; $result = Database::query($sql); $courses = array(); while ($row = Database::fetch_array($result)) { //we only need the database name of the course $courses[] = array( - 'db' => $row['db'], 'code' => $row['k'], 'visual_code' => $row['vc'], 'title' => $row['i'], @@ -139,12 +147,12 @@ class Auth $sql = "SELECT course.code, course.visual_code, course.subscribe subscr, course.unsubscribe unsubscr, - course.title title, course.tutor_name tutor, course.db_name, course.directory, course_rel_user.status status, + course.title title, course.tutor_name tutor, course.directory, course_rel_user.status status, course_rel_user.sort sort, course_rel_user.user_course_cat user_course_cat FROM $TABLECOURS course, $TABLECOURSUSER course_rel_user WHERE - course.code = course_rel_user.course_code AND + course.id = course_rel_user.c_id AND course_rel_user.user_id = '" . $user_id . "' AND course_rel_user.relation_type <> " . COURSE_RELATION_TYPE_RRHH . " $without_special_courses @@ -160,21 +168,28 @@ class Auth } /** - * stores the changes in a course category (moving a course to a different course category) - * @param string Course code + * stores the changes in a course category + * (moving a course to a different course category) + * @param int $courseId * @param int Category id * @return bool True if it success */ - public function store_changecoursecategory($course_code, $newcategory) + public function updateCourseCategory($courseId, $newcategory) { - $course_code = Database::escape_string($course_code); + $courseId = intval($courseId); $newcategory = intval($newcategory); $current_user = api_get_user_id(); - $TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER); $max_sort_value = api_max_sort_value($newcategory, $current_user); - $resultQuery = Database::query("UPDATE $TABLECOURSUSER SET user_course_cat='" . $newcategory . "', sort='" . ($max_sort_value + 1) . "' WHERE course_code='" . $course_code . "' AND user_id='" . $current_user . "' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . " "); + $sql = "UPDATE $TABLECOURSUSER SET + user_course_cat='" . $newcategory . "', + sort='" . ($max_sort_value + 1) . "' + WHERE + c_id ='" . $courseId . "' AND + user_id='" . $current_user . "' AND + relation_type<>" . COURSE_RELATION_TYPE_RRHH; + $resultQuery = Database::query($sql); $result = false; if (Database::affected_rows($resultQuery)) { @@ -224,16 +239,29 @@ class Auth } if (count($target_course) > 0 && count($source_course) > 0) { - $sql_update1 = "UPDATE $TABLECOURSUSER SET sort='" . $target_course['sort'] . "' - WHERE course_code='" . $source_course['code'] . "' AND user_id='" . $current_user_id . "' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . " "; - $sql_update2 = "UPDATE $TABLECOURSUSER SET sort='" . $source_course['sort'] . "' - WHERE course_code='" . $target_course['code'] . "' AND user_id='" . $current_user_id . "' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . " "; - $result1 = Database::query($sql_update2); - $result2 = Database::query($sql_update1); + $courseInfo = api_get_course_info($source_course['code']); + $courseId = $courseInfo['real_id']; + + $sql = "UPDATE $TABLECOURSUSER + SET sort='" . $target_course['sort'] . "' + WHERE + c_id = '" . $courseId . "' AND + user_id = '" . $current_user_id . "' AND + relation_type<>" . COURSE_RELATION_TYPE_RRHH; + $result1 = Database::query($sql); + + $sql = "UPDATE $TABLECOURSUSER SET sort='" . $source_course['sort'] . "' + WHERE + c_id ='" . $courseId . "' AND + user_id='" . $current_user_id . "' AND + relation_type<>" . COURSE_RELATION_TYPE_RRHH; + $result2 = Database::query($sql); + if (Database::affected_rows($result1) && Database::affected_rows($result2)) { $result = true; } } + return $result; } @@ -343,7 +371,10 @@ class Auth } $sql = "UPDATE $TABLECOURSUSER SET user_course_cat='0' - WHERE user_course_cat='" . $category_id . "' AND user_id='" . $current_user_id . "' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . " "; + WHERE + user_course_cat='" . $category_id . "' AND + user_id='" . $current_user_id . "' AND + relation_type<>" . COURSE_RELATION_TYPE_RRHH . " "; Database::query($sql); return $result; @@ -363,11 +394,17 @@ class Auth $course_code = Database::escape_string($course_code); $result = true; + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + // we check (once again) if the user is not course administrator // because the course administrator cannot unsubscribe himself // (s)he can only delete the course $sql = "SELECT * FROM $tbl_course_user - WHERE user_id='" . $current_user_id . "' AND course_code='" . $course_code . "' AND status='1' "; + WHERE + user_id='" . $current_user_id . "' AND + c_id ='" . $courseId . "' AND + status='1' "; $result_check = Database::query($sql); $number_of_rows = Database::num_rows($result_check); if ($number_of_rows > 0) { @@ -491,15 +528,14 @@ class Auth $limitFilter "; - global $_configuration; - if ($_configuration['multiple_access_urls']) { + if (api_is_multiple_url_enabled()) { $url_access_id = api_get_current_access_url_id(); if ($url_access_id != -1) { $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $sql_find = "SELECT * FROM $TABLECOURS as course INNER JOIN $tbl_url_rel_course as url_rel_course - ON (url_rel_course.course_code=course.code) + ON (url_rel_course.c_id = course.id) WHERE access_url_id = $url_access_id AND ( code LIKE '%" . $search_term_safe . "%' OR diff --git a/main/inc/lib/banner.lib.php b/main/inc/lib/banner.lib.php index 471866da6b..ee5e7389dd 100755 --- a/main/inc/lib/banner.lib.php +++ b/main/inc/lib/banner.lib.php @@ -378,7 +378,7 @@ function return_menu() { } elseif (!empty($_SESSION['_user']['language'])) { $lang = $_SESSION['_user']['language']; } else { - $lang = get_setting('platformLanguage'); + $lang = api_get_setting('platformLanguage'); } //Preparing home folder for multiple urls diff --git a/main/inc/lib/blog.lib.php b/main/inc/lib/blog.lib.php index 1901c82563..bd963e7a1e 100755 --- a/main/inc/lib/blog.lib.php +++ b/main/inc/lib/blog.lib.php @@ -1,19 +1,15 @@ * @author Julio Montoya - Cleaning code - * - */ -/** - * Class - * @package chamilo.blogs */ class Blog { @@ -21,11 +17,12 @@ class Blog * Get the title of a blog * @author Toon Keppens * - * @param Integer $blog_id + * @param int $blog_id * * @return String Blog Title */ - public static function get_blog_title ($blog_id) { + public static function get_blog_title ($blog_id) + { $course_id = api_get_course_int_id(); if(is_numeric($blog_id)) { @@ -51,11 +48,12 @@ class Blog * * @return String Blog description */ - public static function get_blog_subtitle ($blog_id) { - // init + public static function get_blog_subtitle ($blog_id) + { $tbl_blogs = Database::get_course_table(TABLE_BLOGS); - $course_id = api_get_course_int_id(); - $sql = "SELECT blog_subtitle FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".intval($blog_id)."'"; + $course_id = api_get_course_int_id(); + $sql = "SELECT blog_subtitle FROM $tbl_blogs + WHERE c_id = $course_id AND blog_id ='".intval($blog_id)."'"; $result = Database::query($sql); $blog = Database::fetch_array($result); return stripslashes($blog['blog_subtitle']); @@ -79,7 +77,8 @@ class Blog // Get blog members $sql = "SELECT user.user_id, user.firstname, user.lastname - FROM " . $tbl_blogs_rel_user . " blogs_rel_user INNER JOIN " . $tbl_users . " user ON blogs_rel_user.user_id = user.user_id + FROM " . $tbl_blogs_rel_user . " blogs_rel_user + INNER JOIN " . $tbl_users . " user ON blogs_rel_user.user_id = user.user_id WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '" . (int)$blog_id."'"; $result = Database::query($sql); @@ -112,7 +111,8 @@ class Blog $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); //verified if exist blog - $sql='SELECT COUNT(*) as count FROM '.$tbl_blogs.' WHERE c_id = '.$course_id.' AND blog_name="'.Database::escape_string($title).'" AND blog_subtitle="'.Database::escape_string($subtitle).'";'; + $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.' + WHERE c_id = '.$course_id.' AND blog_name="'.Database::escape_string($title).'" AND blog_subtitle="'.Database::escape_string($subtitle).'";'; $res=Database::query($sql); $info_count=Database::result($res,0,0); @@ -130,12 +130,12 @@ class Blog // Make first post. :) $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) - VALUES ($course_id, '".get_lang("Welcome")."', '" . get_lang('FirstPostText')."','".$current_date."', '".Database::escape_string((int)$this_blog_id)."', '".Database::escape_string((int)$_user['user_id'])."');"; + VALUES ($course_id, '".get_lang("Welcome")."', '" . get_lang('FirstPostText')."','".$current_date."', '".Database::escape_string((int)$this_blog_id)."', '".Database::escape_string((int)$_user['user_id'])."');"; Database::query($sql); // Put it on course homepage $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id) - VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')"; + VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')"; Database::query($sql); // Subscribe the teacher to this blog @@ -150,8 +150,9 @@ class Blog * @param String $title * @param Text $description */ - public static function edit_blog ($blog_id, $title, $subtitle) { - global $_user; + public static function edit_blog($blog_id, $title, $subtitle) + { + $_user = api_get_user_info(); // Table definitions $tbl_blogs = Database::get_course_table(TABLE_BLOGS); @@ -178,7 +179,8 @@ class Blog * @author Toon Keppens * @param Integer $blog_id */ - public static function delete_blog ($blog_id) { + public static function delete_blog ($blog_id) + { // Init $tbl_blogs = Database::get_course_table(TABLE_BLOGS); $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); @@ -279,7 +281,6 @@ class Blog $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; Database::query($sql); - //Display::display_confirmation_message(get_lang('AttachmentUpload')); } } } @@ -296,7 +297,8 @@ class Blog * @param String $full_text * @param Integer $blog_id */ - public static function edit_post ($post_id, $title, $full_text, $blog_id) { + public static function edit_post ($post_id, $title, $full_text, $blog_id) + { // Init $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); $course_id = api_get_course_int_id(); @@ -310,11 +312,11 @@ class Blog /** * Deletes an article and it's comments * @author Toon Keppens - * @param Integer $blog_id - * @param Integer $post_id + * @param int $blog_id + * @param int $post_id */ - public static function delete_post($blog_id, $post_id) { - // Init + public static function delete_post($blog_id, $post_id) + { $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); @@ -322,15 +324,18 @@ class Blog $course_id = api_get_course_int_id(); // Delete ratings on this comment - $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'"; + $sql = "DELETE FROM $tbl_blogs_rating + WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'"; Database::query($sql); // Delete the post - $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND post_id = '".(int)$post_id."'"; + $sql = "DELETE FROM $tbl_blogs_posts + WHERE c_id = $course_id AND post_id = '".(int)$post_id."'"; Database::query($sql); // Delete the comments - $sql = "DELETE FROM $tbl_blogs_comments WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'"; + $sql = "DELETE FROM $tbl_blogs_comments + WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'"; Database::query($sql); // Delete posts and attachments @@ -401,7 +406,6 @@ class Blog $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; Database::query($sql); - //$message.=' / '.get_lang('AttachmentUpload'); } } } @@ -570,7 +574,8 @@ class Blog * @param Integer $blog_id * @param Integer $task_id */ - public static function delete_task ($blog_id, $task_id) { + public static function delete_task($blog_id, $task_id) + { $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); $course_id = api_get_course_int_id(); @@ -585,7 +590,7 @@ class Blog * @param Integer $blog_id * @param Integer $assignment_id */ - public static function delete_assigned_task ($blog_id, $task_id, $user_id) + public static function delete_assigned_task($blog_id, $task_id, $user_id) { $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); $course_id = api_get_course_int_id(); @@ -601,8 +606,9 @@ class Blog * @author Toon Keppens * @return Returns an unsorted list () with the users' tasks */ - public static function get_personal_task_list () { - global $_user; + public static function get_personal_task_list() + { + $_user = api_get_user_info(); // Init $tbl_blogs = Database::get_course_table(TABLE_BLOGS); @@ -611,8 +617,9 @@ class Blog $course_id = api_get_course_int_id(); - if($_user['user_id']) { - $sql = "SELECT task_rel_user.*, task.title, blog.blog_name FROM $tbl_blogs_tasks_rel_user task_rel_user + if ($_user['user_id']) { + $sql = "SELECT task_rel_user.*, task.title, blog.blog_name + FROM $tbl_blogs_tasks_rel_user task_rel_user INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id AND blog.blog_id = ".intval($_GET['blog_id'])." @@ -646,7 +653,6 @@ class Blog */ public static function change_blog_visibility($blog_id) { - // Init $tbl_blogs = Database::get_course_table(TABLE_BLOGS); $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); $course_id = api_get_course_int_id(); @@ -662,16 +668,19 @@ class Blog if($visibility == 1) { // Change visibility state, remove from course home. - $sql = "UPDATE $tbl_blogs SET visibility = '0' WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; + $sql = "UPDATE $tbl_blogs SET visibility = '0' + WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; $result = Database::query($sql); - $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND name = '".Database::escape_string($title)."' LIMIT 1"; + $sql = "DELETE FROM $tbl_tool + WHERE c_id = $course_id AND name = '".Database::escape_string($title)."' LIMIT 1"; $result = Database::query($sql); } else { // Change visibility state, add to course home. - $sql = "UPDATE $tbl_blogs SET visibility = '1' WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; + $sql = "UPDATE $tbl_blogs SET visibility = '1' + WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; Database::query($sql); $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) @@ -680,14 +689,13 @@ class Blog } } - /** * Shows the posts of a blog * @author Toon Keppens * * @param Integer $blog_id */ - public static function display_blog_posts ($blog_id, $filter = '1=1', $max_number_of_posts = 20) { + public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20) { // Init $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); @@ -710,7 +718,9 @@ class Blog $limit = 200; while($blog_post = Database::fetch_array($result)) { // Get number of comments - $sql = "SELECT COUNT(1) as number_of_comments FROM $tbl_blogs_comments WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '" . (int)$blog_post['post_id']."'"; + $sql = "SELECT COUNT(1) as number_of_comments + FROM $tbl_blogs_comments + WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '" . (int)$blog_post['post_id']."'"; $tmp = Database::query($sql); $blog_post_comments = Database::fetch_array($tmp); @@ -769,7 +779,8 @@ class Blog * @param Integer $blog_id * @param String $query_string */ - public static function display_search_results ($blog_id, $query_string) { + public static function display_search_results ($blog_id, $query_string) + { // Init $query_string = Database::escape_string($query_string); $query_string_parts = explode(' ',$query_string); @@ -790,7 +801,8 @@ class Blog * @param Integer $blog_id * @param String $query_string */ - public static function display_day_results ($blog_id, $query_string) { + public static function display_day_results($blog_id, $query_string) + { // Init $date_output = $query_string; $date = explode('-',$query_string); @@ -810,13 +822,14 @@ class Blog * @param Integer $blog_id * @param Integer $post_id */ - public static function display_post ($blog_id, $post_id) { + public static function display_post($blog_id, $post_id) + { // Init $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); $tbl_users = Database::get_main_table(TABLE_MAIN_USER); - global $charset,$dateFormatLong; + global $charset, $dateFormatLong; $course_id = api_get_course_int_id(); @@ -833,7 +846,8 @@ class Blog $blog_post = Database::fetch_array($result); // Get number of comments - $sql = "SELECT COUNT(1) as number_of_comments FROM $tbl_blogs_comments WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'"; + $sql = "SELECT COUNT(1) as number_of_comments FROM $tbl_blogs_comments + WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'"; $result = Database::query($sql); $blog_post_comments = Database::fetch_array($result); @@ -882,8 +896,7 @@ class Blog echo ''; // Display comments if there are any - if($blog_post_comments['number_of_comments'] > 0) - { + if($blog_post_comments['number_of_comments'] > 0) { echo '
    '; echo '' . get_lang('Comments') . '
    '; Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); @@ -908,8 +921,9 @@ class Blog * * @return Boolean success */ - public static function add_rating ($type, $blog_id, $item_id, $rating) { - global $_user; + public static function add_rating($type, $blog_id, $item_id, $rating) + { + $_user = api_get_user_info(); // Init $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); @@ -946,12 +960,14 @@ class Blog * * @return array() */ - public static function display_rating ($type, $blog_id, $item_id) { + public static function display_rating ($type, $blog_id, $item_id) + { $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); $course_id = api_get_course_int_id(); // Calculate rating - $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$item_id."' AND rating_type = '".Database::escape_string($type)."' "; + $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating + WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$item_id."' AND rating_type = '".Database::escape_string($type)."' "; $result = Database::query($sql); $result = Database::fetch_array($result); return round($result['rating'], 2); @@ -967,8 +983,9 @@ class Blog * *@return String */ - public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) { - global $_user; + public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) + { + $_user = api_get_user_info(); $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); $course_id = api_get_course_int_id(); @@ -1021,7 +1038,8 @@ class Blog * @param Integer $blog_id * @param Integer $post_id */ - public static function get_threaded_comments ($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) { + public static function get_threaded_comments ($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) + { // Init $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); $tbl_users = Database::get_main_table(TABLE_MAIN_USER); @@ -1332,7 +1350,8 @@ class Blog * @author Toon Keppens * */ - public static function display_new_task_form ($blog_id) { + public static function display_new_task_form ($blog_id) + { // Init $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); @@ -1508,37 +1527,30 @@ class Blog } /** - * Displays assign task form - * @author Toon Keppens - * + * @param $blog_id + * @return FormValidator */ - public static function display_assign_task_form ($blog_id) { + public static function getTaskForm($blog_id) + { // Init $tbl_users = Database::get_main_table(TABLE_MAIN_USER); $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); - $day = date("d"); - $month = date("m"); - $year = date("Y"); - global $MonthsLong; - $course_id = api_get_course_int_id(); // Get users in this blog / make select list of it - $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username FROM $tbl_users user + $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username + FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user ON user.user_id = blogs_rel_user.user_id WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; $result = Database::query($sql); - $select_user_list = ''; - // Get tasks in this blog / make select list of it $sql = " @@ -1554,109 +1566,50 @@ class Blog WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " ORDER BY system_task, title"; $result = Database::query($sql); - $select_task_list = ''; - - // form - echo '
    '; - // form title - echo ''.get_lang('AssignTask').''; - - // user - echo '
    - -
    - '.$select_user_list.' -
    -
    '; - - // task - echo '
    - -
    - '.$select_task_list.' -
    -
    '; - - // date - echo '
    - -
    '; - echo ' - - - - - '; - echo '
    -
    '; - - // submit - echo '
    -
    -
    - - - -
    -
    '; + $form = new FormValidator( + 'assign_task', + 'post', + api_get_path( + WEB_CODE_PATH + ).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id + ); + $form->addHeader(get_lang('AssignTask')); + $form->addSelect('task_user_id', get_lang('SelectUser'), $options); + $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions); + $form->addDatePicker('task_day', get_lang('SelectTargetDate')); + $form->addHidden('action', ''); + $form->addButtonSave(get_lang('Ok')); + return $form; + } - echo ''; + /** + * Displays assign task form + * @author Toon Keppens + * + */ + public static function display_assign_task_form($blog_id) + { + $form = self::getTaskForm($blog_id); + $form->addHidden('assign_task_submit', 'true'); + $form->display(); echo '
    '; } - /** + /** * Displays assign task form * @author Toon Keppens * */ - public static function display_edit_assigned_task_form ($blog_id, $task_id, $user_id) { + public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) + { $tbl_users = Database::get_main_table(TABLE_MAIN_USER); $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); @@ -1664,9 +1617,6 @@ class Blog $course_id = api_get_course_int_id(); - $year = date("Y"); - global $MonthsLong; - // Get assignd date; $sql = " SELECT target_date @@ -1678,116 +1628,20 @@ class Blog $result = Database::query($sql); $row = Database::fetch_assoc($result); - $old_date = $row['target_date']; - $date = explode('-', $row['target_date']); - - // Get users in this blog / make select list of it - $sql = " - SELECT user.user_id, user.firstname, user.lastname, user.username - FROM $tbl_users user - INNER JOIN $tbl_blogs_rel_user blogs_rel_user ON user.user_id = blogs_rel_user.user_id - WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; - $result = Database::query($sql); - - $select_user_list = ''; - - // Get tasks in this blog / make select list of it - $sql = " - SELECT - blog_id, - task_id, - title, - description, - color, - system_task - FROM " . $tbl_blogs_tasks . " - WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " - ORDER BY system_task, title"; - $result = Database::query($sql); - - $select_task_list = ''; - - // Display - echo '
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ' . get_lang('AssignTask') . '

    ' . get_lang('SelectUser') . ':  ' . $select_user_list . '
    ' . get_lang('SelectTask') . ':  ' . $select_task_list . '
    ' . get_lang('SelectTargetDate') . ':   - - - - - - -
     
    -
    '; + $date = $row['target_date']; + + $defaults = [ + 'task_user_id' => $user_id, + 'task_task_id' => $task_id, + 'task_day' => $date + ]; + $form = self::getTaskForm($blog_id); + $form->addHidden('old_task_id', $task_id); + $form->addHidden('old_user_id', $user_id); + $form->addHidden('old_target_date', $date); + $form->addHidden('assign_task_edit_submit', 'true'); + $form->setDefaults($defaults); + $form->display(); } /** @@ -1798,8 +1652,8 @@ class Blog * @param Integer $task_id * @param Date $target_date */ - public static function assign_task ($blog_id, $user_id, $task_id, $target_date) { - // Init + public static function assign_task($blog_id, $user_id, $task_id, $target_date) + { $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); $course_id = api_get_course_int_id(); @@ -1812,10 +1666,10 @@ class Blog AND task_id = " . (int)$task_id . " "; - $result = @Database::query($sql); + $result = Database::query($sql); $row = Database::fetch_assoc($result); - if($row['number'] == 0) { + if ($row['number'] == 0) { $sql = " INSERT INTO " . $tbl_blogs_tasks_rel_user . " ( c_id, @@ -1831,12 +1685,13 @@ class Blog '" . Database::escape_string($target_date) . "' )"; - $result = @Database::query($sql); + $result = Database::query($sql); } } - public static function edit_assigned_task ($blog_id, $user_id, $task_id, $target_date, $old_user_id, $old_task_id, $old_target_date) { - // Init + public static function edit_assigned_task ($blog_id, $user_id, $task_id, $target_date, $old_user_id, $old_task_id, $old_target_date) + { + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); $course_id = api_get_course_int_id(); @@ -1968,17 +1823,19 @@ class Blog * * @return Html Form with sortable table with users to subcribe in a blog, in a course. */ - public static function display_form_user_subscribe ($blog_id) { - // Init - global $_course; + public static function display_form_user_subscribe($blog_id) + { + $_course = api_get_course_info(); $is_western_name_order = api_is_western_name_order(); - $currentCourse = $_course['sysCode']; + $session_id = api_get_session_id(); + $course_id = api_get_course_int_id(); + + $currentCourse = $_course['code']; $tbl_users = Database::get_main_table(TABLE_MAIN_USER); $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); - $table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); echo ''.get_lang('SubscribeMembers').''; - $course_id = api_get_course_int_id(); + $properties["width"] = "100%"; // Get blog members' id. @@ -1989,8 +1846,7 @@ class Blog $result = Database::query($sql); $blog_member_ids = array(); - while($user = Database::fetch_array($result)) - { + while($user = Database::fetch_array($result)) { $blog_member_ids[] = $user['user_id']; } @@ -2006,25 +1862,18 @@ class Blog $column_header[] = array (get_lang('Email'), false, ''); $column_header[] = array (get_lang('Register'), false, ''); - if(isset($_SESSION['session_id'])){ - $session_id = intval($_SESSION['session_id']); - } - else{ - $session_id = 0; - } - $student_list = CourseManager :: get_student_list_from_course_code($currentCourse, false, $session_id); - $user_data = array (); + $user_data = array(); // Add users that are not in this blog to the list. - foreach($student_list as $key=>$user) { + foreach ($student_list as $key=>$user) { if(isset($user['id_user'])) { $user['user_id'] = $user['id_user']; } if(!in_array($user['user_id'],$blog_member_ids)) { $a_infosUser = UserManager :: get_user_info_by_id($user['user_id']); $row = array (); - $row[] = ''; + $row[] = ''; $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); if ($is_western_name_order) { $row[] = $a_infosUser["firstname"]; @@ -2036,12 +1885,9 @@ class Blog $row[] = Display::icon_mailto_link($a_infosUser["email"]); //Link to register users - if($a_infosUser["user_id"] != $_SESSION['_user']['user_id']) - { + if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){ $row[] = "" . get_lang('Register').""; - } - else - { + } else { $row[] = ''; } $user_data[] = $row; @@ -2068,7 +1914,6 @@ class Blog echo ''; } - /** * Displays the form to register users in a blog (in a course) * The listed users are users subcribed in the course. @@ -2078,8 +1923,9 @@ class Blog * * @return Html Form with sortable table with users to unsubcribe from a blog. */ - public static function display_form_user_unsubscribe ($blog_id) { - global $_user; + public static function display_form_user_unsubscribe ($blog_id) + { + $_user = api_get_user_info(); $is_western_name_order = api_is_western_name_order(); // Init @@ -2117,7 +1963,7 @@ class Blog while($myrow = Database::fetch_array($sql_result)) { $row = array (); - $row[] = ''; + $row[] = ''; $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); if ($is_western_name_order) { $row[] = $myrow["firstname"]; @@ -2129,16 +1975,14 @@ class Blog $row[] = Display::icon_mailto_link($myrow["email"]); $sql = "SELECT bt.title task - FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu - INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt ON btu.task_id = bt.task_id - WHERE btu.c_id = $course_id AND - bt.c_id = $course_id AND - btu.blog_id = $blog_id AND - btu.user_id = " . $myrow['user_id']; - - if (!($sql_res = Database::query($sql))) { - die(Database::error()); - } + FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu + INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt + ON btu.task_id = bt.task_id + WHERE btu.c_id = $course_id AND + bt.c_id = $course_id AND + btu.blog_id = $blog_id AND + btu.user_id = " . $myrow['user_id']; + $sql_res = Database::query($sql); $task = ''; @@ -2151,7 +1995,7 @@ class Blog //Link to register users if($myrow["user_id"] != $_user['user_id']) { - $row[] = "" . get_lang('UnRegister').""; + $row[] = "" . get_lang('UnRegister').""; } else { $row[] = ''; } @@ -2256,10 +2100,10 @@ class Blog * * @return html code */ - public static function display_minimonthcalendar ($month, $year, $blog_id) + public static function display_minimonthcalendar($month, $year, $blog_id) { // Init - global $_user; + $_user = api_get_user_info(); global $DaysShort; global $MonthsLong; @@ -2308,38 +2152,34 @@ class Blog if( Database::num_rows($result) > 0) { while($blog_post = Database::fetch_array($result)) { // If the day of this post is not yet in the array, add it. - if(!in_array($blog_post['post_day'], $posts)) + if (!in_array($blog_post['post_day'], $posts)) $posts[] = $blog_post['post_day']; } } // Get tasks for this month - if($_user['user_id']) { + if ($_user['user_id']) { $sql = " SELECT task_rel_user.*, DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name FROM $tbl_blogs_tasks_rel_user task_rel_user INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id WHERE - task_rel_user.c_id = $course_id AND - task.c_id = $course_id AND - blog.c_id = $course_id AND - task_rel_user.user_id = '".(int)$_user['user_id']."' - AND MONTH(target_date) = '".(int)$month."' - AND YEAR(target_date) = '".(int)$year."' + task_rel_user.c_id = $course_id AND + task.c_id = $course_id AND + blog.c_id = $course_id AND + task_rel_user.user_id = '".(int)$_user['user_id']."' AND + MONTH(target_date) = '".(int)$month."' AND + YEAR(target_date) = '".(int)$year."' ORDER BY target_date ASC"; $result = Database::query($sql); - if (Database::num_rows($result) > 0) - { - while($mytask = Database::fetch_array($result)) - { - + if (Database::num_rows($result) > 0) { + while ($mytask = Database::fetch_array($result)) { $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id']; $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title']; $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id']; $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name']; $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day']; - //echo '
  • '.stripslashes($mytask['title']) . '
  • '; } } } @@ -2348,38 +2188,34 @@ class Blog "\n", "«\n", "", $monthName, " ", $year, "\n", - "»\n", "\n"; + "»\n", ""; echo "\n"; for($ii = 1; $ii < 8; $ii ++) - echo "", $DaysShort[$ii % 7], "\n"; + echo "", $DaysShort[$ii % 7], ""; - echo "\n"; + echo ""; $curday = -1; $today = getdate(); - while($curday <= $numberofdays[$month]) - { - echo "\n"; - - for($ii = 0; $ii < 7; $ii ++) - { - if(($curday == -1) && ($ii == $startdayofweek)) + while ($curday <= $numberofdays[$month]) { + echo ""; + for ($ii = 0; $ii < 7; $ii ++) { + if (($curday == -1) && ($ii == $startdayofweek)) $curday = 1; - if(($curday > 0) && ($curday <= $numberofdays[$month])) { + if (($curday > 0) && ($curday <= $numberofdays[$month])) { $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; $dayheader = "$curday"; - if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) - { + if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { $dayheader = "$curday"; $class = "class=\"days_today\""; } - echo "\t"; + echo ""; // If there are posts on this day, create a filter link. if(in_array($curday, $posts)) @@ -2387,30 +2223,24 @@ class Blog else echo $dayheader; - if (count($tasks) > 0) - { - if (is_array($tasks[$curday])) - { + if (count($tasks) > 0) { + if (isset($tasks[$curday]) && is_array($tasks[$curday])) { // Add tasks to calendar - foreach ($tasks[$curday] as $task) - { - echo 'Task'; + foreach ($tasks[$curday] as $task) { + echo ' + Task'; } } } - echo "\n"; - + echo ""; $curday ++; - } - else - echo " \n"; + } else + echo " "; } - - echo "\n"; + echo ""; } - - echo "\n"; + echo ""; } /** @@ -2475,7 +2305,8 @@ class Blog * Blog admin | Returns table with blogs in this course */ public static function display_blog_list () { - global $charset, $_user; + global $charset; + $_user = api_get_user_info(); $course_id = api_get_course_int_id(); // Init $counter = 0; @@ -2543,7 +2374,6 @@ class Blog $table->display(); } } - } /** @@ -2603,14 +2433,14 @@ function get_blog_attachment($blog_id, $post_id=null,$comment_id=null) function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null) { - - global $_course; + $_course = api_get_course_info(); $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); $blog_id = intval($blog_id); $comment_id = intval($comment_id); $post_id = intval($post_id); $course_id = api_get_course_int_id(); + $where = null; // delete files in DB if (!empty ($post_id) && is_numeric($post_id) ) @@ -2646,38 +2476,40 @@ function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null) $sql = 'DELETE FROM '. $blog_table_attachment.' WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; Database::query($sql); } + /** * Gets all the post from a given user id * @param string db course name * @param int user id */ -function get_blog_post_from_user($course_code, $user_id) { - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); - $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); - $course_info = api_get_course_info($course_code); - $course_id = $course_info['real_id']; - - $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation - FROM $tbl_blogs blog INNER JOIN $tbl_blog_post post - ON (blog.blog_id = post.blog_id) - WHERE - blog.c_id = $course_id AND - post.c_id = $course_id AND - author_id = $user_id AND visibility = 1 - ORDER BY post.date_creation DESC "; - $result = Database::query($sql); - $return_data = ''; - - if (Database::num_rows($result)!=0) { - while ($row=Database::fetch_array($result)) { - $return_data.= '

    '; - $return_data.= '
    '.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].'        
    '.get_lang('SeeBlog').'
    '; - $return_data.= '
    '; - $return_data.= $row['full_text']; - $return_data.= '

    '; - } +function get_blog_post_from_user($course_code, $user_id) +{ + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); + $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); + $course_info = api_get_course_info($course_code); + $course_id = $course_info['real_id']; + + $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation + FROM $tbl_blogs blog INNER JOIN $tbl_blog_post post + ON (blog.blog_id = post.blog_id) + WHERE + blog.c_id = $course_id AND + post.c_id = $course_id AND + author_id = $user_id AND visibility = 1 + ORDER BY post.date_creation DESC "; + $result = Database::query($sql); + $return_data = ''; + + if (Database::num_rows($result)!=0) { + while ($row=Database::fetch_array($result)) { + $return_data.= '

    '; + $return_data.= '
    '.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].'        
    '.get_lang('SeeBlog').'
    '; + $return_data.= '
    '; + $return_data.= $row['full_text']; + $return_data.= '

    '; } - return $return_data; + } + return $return_data; } /** @@ -2686,34 +2518,33 @@ function get_blog_post_from_user($course_code, $user_id) { * @param int user id */ function get_blog_comment_from_user($course_code, $user_id) { - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); - $tbl_blog_comment = Database::get_course_table(TABLE_BLOGS_COMMENTS); - $user_id = intval($user_id); - - $course_info = api_get_course_info($course_code); - $course_id = $course_info['real_id']; - - $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation - FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment - ON (blog.blog_id = comment.blog_id) - WHERE blog.c_id = $course_id AND - comment.c_id = $course_id AND - author_id = $user_id AND - visibility = 1 - ORDER BY blog_name"; - $result = Database::query($sql); - $return_data = ''; - if (Database::num_rows($result)!=0) { - while ($row=Database::fetch_array($result)) { - $return_data.= '

    '; - $return_data.= '
    '.$row['title'].'        
    '.get_lang('SeeBlog').'
    '; - $return_data.= '
    '; - //$return_data.= ''.$row['title'].''; echo '
    ';*/ - $return_data.= $row['comment']; - $return_data.= '
    '; - } + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); + $tbl_blog_comment = Database::get_course_table(TABLE_BLOGS_COMMENTS); + $user_id = intval($user_id); + + $course_info = api_get_course_info($course_code); + $course_id = $course_info['real_id']; + + $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation + FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment + ON (blog.blog_id = comment.blog_id) + WHERE blog.c_id = $course_id AND + comment.c_id = $course_id AND + author_id = $user_id AND + visibility = 1 + ORDER BY blog_name"; + $result = Database::query($sql); + $return_data = ''; + if (Database::num_rows($result)!=0) { + while ($row=Database::fetch_array($result)) { + $return_data.= '

    '; + $return_data.= '
    '.$row['title'].'        
    '.get_lang('SeeBlog').'
    '; + $return_data.= '
    '; + //$return_data.= ''.$row['title'].''; echo '
    ';*/ + $return_data.= $row['comment']; + $return_data.= '
    '; } - return $return_data; + } + return $return_data; } -?> diff --git a/main/inc/lib/cache.class.php b/main/inc/lib/cache.class.php deleted file mode 100755 index 5fa00e3dff..0000000000 --- a/main/inc/lib/cache.class.php +++ /dev/null @@ -1,128 +0,0 @@ - for the Univesity of Geneva - */ -class Cache -{ - - /** - * Retrieve an item from the cache if item creation date is greater than limit. - * If item does not exists or is stale returns false. - * - * @param any Identifier for the variable stored - * @param int If this limit is greater than last mod time of value, stale - * @return false|object Value kept in cache - */ - static function get($key, $limit = 0) - { - if (!self::has($key, $limit)) - { - return false; - } - $path = self::path($key); - return file_get_contents($path); - } - - /** - * Returnsn true if the cache has the item and it is not staled. - * - * @param any Identifier for the variable stored - * @param int If this limit is greater than last mod time of value, stale - * @return boolean - */ - static function has($key, $limit = 0) - { - $path = self::path($key); - if (!is_readable($path)) - { - return false; - } - if ($limit) - { - $mtime = filemtime($path); - if ($mtime < $limit) - { - return false; - } - } - return true; - } - - /** - * Put something in cache. - * - * @param any Identifier for the variable to be stored - * @param string Value to be stored - */ - static function put($key, $value) - { - $path = self::path($key); - file_put_contents($path, $value); - } - - /** - * Remove an item from the cache. - * - * @param any Identifier for the variable to remove - */ - static function remove($key) - { - $path = self::path($key); - if (is_readable($path)) - { - unlink($path); - } - } - - /** - * Clear the cache. Remove all entries. - */ - static function clear() - { - $dir = self::path(); - $files = scandir($dir); - $files = array_diff($files, array('.', '..')); - foreach ($files as $file) - { - $path = $dir . $file; - unlink($path); - } - } - - /** - * Returns the file path based on the key. - * - * @param any Identifier for the variable - * @return string Path of the file where this - * variable is/should-be stored - */ - static function path($key = '') - { - return Chamilo::path('archive/temp/cache/' . self::key($key)); - } - - /** - * Returns the internal string key from the external key. - * For internal use. - * - * @param any Identifier for the variable - * @return string Unique ID generated to identify the variable - */ - static function key($item) - { - if (is_object($item)) - { - $f = array($item, 'get_unique_id'); - if (is_callable($f)) - { - return call_user_func($f); - } - } - $result = (string)$item; - } - -} diff --git a/main/inc/lib/chamilo.class.php b/main/inc/lib/chamilo.class.php index a6bdef5d0a..10ab8bfcc5 100755 --- a/main/inc/lib/chamilo.class.php +++ b/main/inc/lib/chamilo.class.php @@ -17,23 +17,6 @@ function session() */ class Chamilo { - - public static function name() - { - //@todo: add version - return 'chamilo'; - } - - static function is_test_server() - { - return api_get_setting('server_type') == 'test'; - } - - static function is_production_server() - { - return api_get_setting('server_type') == 'production'; - } - /** * * @return ChamiloSession @@ -42,103 +25,4 @@ class Chamilo { return ChamiloSession::instance(); } - - /** - * - * @return CurrentUser - */ - static function user() - { - return ChamiloSession::instance()->user(); - } - - /** - * Returns a full url from local/absolute path and parameters. - * Append the root as required for relative urls. - * - * @param string $path - * @param array $params - * @return string - */ - public static function url($path = '', $params = array(), $html = true) - { - return Uri::url($path, $params, $html); - } - - public static function here($params = array(), $html = true) - { - return Uri::here($params, $html); - } - - /** - * Application web root - */ - public static function www() - { - return Uri::www(); - } - - /** - * File system root for Chamilo - * - * @return string - */ - public static function root() - { - return api_get_path(SYS_PATH); - } - - public static function root_courses() - { - return api_get_path(SYS_COURSE_PATH); - } - - /** - * Returns a temporary file - one that is automatically deleted at the end - * of the script. - * - * @param string $ext - * @return Temp - */ - public static function temp_file($ext = '') - { - $ext = $ext ? '.' . $ext : ''; - Temp::set_temp_root(api_get_path(SYS_ARCHIVE_PATH) . 'temp'); - $path = Temp::get_temporary_name() . $ext; - return Temp::create($path); - } - - /** - * Returns a temporary directory - one that is automatically deleted at the end - * of the script. - * - * @param string $ext - * @return Temp - */ - public static function temp_dir() - { - $ext = $ext ? '.' . $ext : ''; - Temp::set_temp_root(api_get_path(SYS_ARCHIVE_PATH) . 'temp'); - $path = Temp::get_temporary_name() . $ext; - return Temp::dir($path); - } - - /** - * - * @return Zip - */ - public static function temp_zip() - { - return Zip::create(self::temp_file('zip')); - } - - public static function path($path = '') - { - $root = self::root(); - if (empty($path)) { - return $root; - } - return $root . $path; - } - -} \ No newline at end of file +} diff --git a/main/inc/lib/chamilo_session.class.php b/main/inc/lib/chamilo_session.class.php index 3ea4738c2d..5f26fffc12 100755 --- a/main/inc/lib/chamilo_session.class.php +++ b/main/inc/lib/chamilo_session.class.php @@ -1,16 +1,16 @@ ... * session()->... * @@ -27,7 +27,7 @@ class ChamiloSession extends System\Session /** * Generate new session instance - * @return ChamiloSession + * @return ChamiloSession */ static function instance() { @@ -74,54 +74,8 @@ class ChamiloSession extends System\Session { global $_configuration; - /* Causes too many problems and is not configurable dynamically. - if ($already_installed) { - $session_lifetime = 360000; - if (isset($_configuration['session_lifetime'])) { - $session_lifetime = $_configuration['session_lifetime']; - } - //session_set_cookie_params($session_lifetime,api_get_path(REL_PATH)); - } - */ - - if (isset($_configuration['session_stored_in_db']) && - $_configuration['session_stored_in_db'] && - function_exists('session_set_save_handler') - ) { - $handler = new SessionHandlerDatabase(); - @session_set_save_handler( - array($handler, 'open'), - array($handler, 'close'), - array($handler, 'read'), - array($handler, 'write'), - array($handler, 'destroy'), - array($handler, 'garbage') - ); - } - - // An alternative session handler, storing the session in memcache, - // and in the DB as backup for memcache server failure, can be used - // by defining specific configuration settings. - // This requires memcache or memcached and the php5-memcache module - // to be installed. - // See configuration.dist.php for greater details - if (isset($_configuration['session_stored_in_db_as_backup']) && - $_configuration['session_stored_in_db_as_backup'] && - function_exists('session_set_save_handler') - ) { - $handler = new SessionHandlerMemcache(); - session_set_save_handler( - array(&$handler, 'open'), - array(&$handler, 'close'), - array(&$handler, 'read'), - array(&$handler, 'write'), - array(&$handler, 'destroy'), - array(&$handler, 'gc') - ); - } - /* - * Prevent Session fixation bug fixes + * Prevent Session fixation bug fixes * See http://support.chamilo.org/issues/3600 * http://php.net/manual/en/session.configuration.php * @todo use session_set_cookie_params with some custom admin parameters @@ -131,12 +85,12 @@ class ChamiloSession extends System\Session //the session ID is only accepted from a cookie ini_set('session.use_only_cookies', 1); - //HTTPS only if possible + //HTTPS only if possible //ini_set('session.cookie_secure', 1); - //session ID in the cookie is only readable by the server + //session ID in the cookie is only readable by the server ini_set('session.cookie_httponly', 1); - //Use entropy file + //Use entropy file //session.entropy_file //ini_set('session.entropy_length', 128); //Do not include the identifier in the URL, and not to read the URL for @@ -198,39 +152,4 @@ class ChamiloSession extends System\Session { return $this->end_time() < time(); } - - /** - * The current (logged in) user. - * @return CurrentUser The current user instance - */ - public function user() - { - static $result = null; - if (empty($result)) { - $result = CurrentUser::instance(); - } - return $result; - } - - /** - * Returns the current (active) course - * @return CurrentCourse The current course instance - */ - public function course() - { - static $result = null; - if (empty($result)) { - $result = CurrentCourse::instance(); - } - return $result; - } - - /** - * The current group for the current (logged in) user. - * @return int the current group id - */ - public function group_id() - { - return Session::read('_gid'); - } } diff --git a/main/inc/lib/classmanager.lib.php b/main/inc/lib/classmanager.lib.php index c1eb0e4f75..6e645f235a 100755 --- a/main/inc/lib/classmanager.lib.php +++ b/main/inc/lib/classmanager.lib.php @@ -153,10 +153,10 @@ class ClassManager * @param int $class_id The class id * @param string $course_code The course code */ - public static function subscribe_to_course($class_id, $course_code) { + public static function subscribe_to_course($class_id, $course_code) + { $tbl_course_class = Database :: get_main_table(TABLE_MAIN_COURSE_CLASS); $tbl_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER); - $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $sql = "INSERT IGNORE INTO $tbl_course_class SET course_code = '".Database::escape_string($course_code)."', class_id = '".Database::escape_string($class_id)."'"; Database::query($sql); $sql = "SELECT user_id FROM $tbl_class_user WHERE class_id = '".intval($class_id)."'"; diff --git a/main/inc/lib/controller.class.php b/main/inc/lib/controller.class.php deleted file mode 100755 index 95817e210e..0000000000 --- a/main/inc/lib/controller.class.php +++ /dev/null @@ -1,198 +0,0 @@ - for the Univesity of Genevas - * @license see /license.txt - */ -class Controller -{ - - const PARAM_ACTION = 'action'; - - protected $access; - - protected function __construct($access = null) - { - $access = $access ? $access : Access::all(); - $this->access = $access; - } - - /** - * - * @return \Access - */ - public function access() - { - return $this->access; - } - - /** - * List of actions accepted by the controller. - * - * @return array - */ - public function get_actions() - { - $reflector = new ReflectionClass($this); - $constants = $reflector->getConstants(); - $result = array(); - foreach ($constants as $key => $value) { - if (strpos($key, 'ACTION') !== false) { - $result[$key] = $value; - } - } - return $result; - } - - /** - * Action to perform. - * Returns the request parameter. - * - * @return string - */ - public function get_action() - { - $result = Request::get(self::PARAM_ACTION); - $actions = $this->get_actions(); - $result = in_array($result, $actions) ? $result : ''; - return $result; - } - - /** - * Set up the environment. Set up breadcrumps, raise tracking event, etc. - */ - protected function prolog() - { - - } - - /** - * Whether the call is authorized or not. - * - * @return boolean - */ - public function authorize() - { - return $this->access()->authorize(); - } - - /** - * Returns a string containing dynamic javascript to be included in the template. - * This requires a {{javascript}} tag in a twigg template to appear. - * - * Note: - * - * A better approach to this method is to create a twigg "javascript" - * template and to include it where required. - * - * @return string - */ - public function javascript() - { - return ''; - } - -// public function check_token() -// { -// return (bool) Security::check_token('get'); -// } - - /** - * Run the controller. Dispatch action and execute requested tasks. - */ - public function run() - { - if (!$this->authorize()) { - $this->forbidden(); - return false; - } - - $this->prolog(); - $action = $this->get_action(); - if (empty($action)) { - $this->unknown(); - return; - } - $f = array($this, $action); - if (is_callable($f)) { - call_user_func($f); - } else { - $this->missing(); - } - } - - /** - * Unknown action. I.e. the action has not been registered. - * Possibly missing action declaration: - * - * const ACTION_XXX = 'XXX'; - * - * @return boolean - */ - public function unknown() - { - return false; - } - - /** - * - * @return boolean - */ - public function forbidden() - { - api_not_allowed(); - return false; - } - - /** - * Action exists but implementation is missing. - */ - public function missing() - { - echo 'No implementation'; - return false; - } - - /** - * Render a template using data. Adds a few common parameters to data. - * - * @see /main/template/default/course_description/ - * @param string $template - * @param array $data - */ - protected function render($template_name, $data) - { - $data = (object) $data; - $data->www = \Chamilo::url(); - $data->messages = isset($data->messages) ? $data->messages : array(); - $javascript = $this->javascript(); - if ($javascript) { - $data->javascript = $javascript; - } - - $tpl = new Template(); - foreach ($data as $key => $value) { - $tpl->assign($key, $value); - } - $template = $tpl->get_template($template_name); - $content = $tpl->fetch($template); - $tpl->assign('content', $content); - $tpl->display_one_col_template(); - } - - /** - * Render data as JSON - * - * @param any $data - */ - protected function render_json($data) - { - Header::content_type_json(); - echo json_encode($data); - } - -} \ No newline at end of file diff --git a/main/inc/lib/course.class.php b/main/inc/lib/course.class.php deleted file mode 100755 index d7ec305d02..0000000000 --- a/main/inc/lib/course.class.php +++ /dev/null @@ -1,145 +0,0 @@ - for the Univesity of Geneva - */ -class Course -{ - - /** - * - * @param string $where - * @return \ResultSet - */ - public static function query($where) - { - $table = Database::get_main_table(TABLE_MAIN_COURSE); - $sql = "SELECT * FROM $table "; - $sql .= $where ? "WHERE $where" : ''; - $result = new ResultSet($sql); - return $result->return_type(__CLASS__); - } - - /** - * - * @param string $code - * @return \Model\Course|null - */ - public static function get_by_code($code) - { - $current = self::current(); - if ($current && $current->get_code() == $code) { - return $current; - } - return self::query("code = '$code'")->first(); - } - - /** - * - * @param int $id - * @return \Model\Course|null - */ - public static function get_by_id($id) - { - $id = (int) $id; - $current = self::current(); - if ($current && $current->get_id() == $id) { - return $current; - } - return self::query("id = $id")->first(); - } - - /** - * - * @return \Model\Course|null - */ - public static function current() - { - global $_course; - /** - * Note that $_course = -1 when not set. - */ - if (empty($_course) || !is_array($_course)) { - return null; - } - - static $result = null; - if (empty($result)) { - $id = $_course['real_id']; - $result = self::query("id = $id")->first(); - } - return $result; - } - - protected $id = 0; - protected $code = 0; - protected $directory = ''; - protected $show_score = ''; - - public function __construct($data) - { - $data = (object) $data; - $this->id = $data->id; - $this->code = $data->code; - $this->directory = $data->directory; - $this->show_score = $data->show_score; - } - - public function get_id() - { - return $this->id; - } - - public function set_id($value) - { - $this->id = (int) $value; - } - - public function get_code() - { - return $this->code; - } - - public function set_code($value) - { - $this->code = (int) $value; - } - - public function get_directory() - { - return $this->directory; - } - - public function set_directory($value) - { - $this->directory = (int) $value; - } - - public function get_show_score() - { - return $this->show_score; - } - - public function set_show_score($value) - { - $this->show_score = (int) $value; - } - - public function get_path() - { - $dir = $this->directory; - if (empty($dir)) { - return ''; - } - return api_get_path(SYS_COURSE_PATH) . $dir . '/'; - } - -} \ No newline at end of file diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 7fba776465..80e671ff50 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -213,7 +213,7 @@ class CourseManager if (!empty($urlId)) { $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); - $sql .= " INNER JOIN $table url ON (url.course_code = course.code) "; + $sql .= " INNER JOIN $table url ON (url.c_id = course.id) "; } if (!empty($startwith)) { @@ -322,16 +322,69 @@ class CourseManager */ public static function get_user_in_course_status($user_id, $course_code) { + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + $result = Database::fetch_array( Database::query( "SELECT status FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " - WHERE course_code = '" . Database::escape_string($course_code) . "' AND user_id = " . intval($user_id) + WHERE + c_id = '" . $courseId. "' AND + user_id = " . intval($user_id) ) ); return $result['status']; } + /** + * @param int $userId + * @param int $courseId + * + * @return mixed + */ + public static function getUserCourseInfo($userId, $courseId) + { + + $result = Database::fetch_array( + Database::query( + "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " + WHERE + c_id = '" . intval($courseId). "' AND + user_id = " . intval($userId) + ) + ); + + return $result; + } + + /** + * @param int $userId + * @param int $courseId + * @param bool $isTutor + * @return bool + */ + public static function updateUserCourseTutor($userId, $courseId, $isTutor) + { + $table = Database::escape_string(TABLE_MAIN_COURSE_USER); + + $courseId = intval($courseId); + $isTutor = intval($isTutor); + + $sql = "UPDATE $table SET is_tutor = '".$isTutor."' + WHERE + user_id = '".$userId."' AND + c_id = '".$courseId."'"; + + $result = Database::query($sql); + + if (Database::affected_rows($result) > 0) { + return true; + } else { + return false; + } + } + /** * @param int $user_id * @param string $course_code @@ -341,12 +394,12 @@ class CourseManager { $result = Database::fetch_array( Database::query( - "SELECT tutor_id FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " + "SELECT is_tutor FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " WHERE course_code = '" . Database::escape_string($course_code) . "' AND user_id = " . intval($user_id) ) ); - return $result['tutor_id']; + return $result['is_tutor']; } /** @@ -440,23 +493,24 @@ class CourseManager // Delete in table session_rel_course_rel_user $sql = "DELETE FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " - WHERE id_session ='" . $session_id . "' AND - course_code = '" . Database::escape_string($course_info['code']) . "' AND - id_user IN ($user_ids)"; + WHERE + session_id ='" . $session_id . "' AND + c_id = '" . $course_id . "' AND + user_id IN ($user_ids)"; Database::query($sql); foreach ($user_list as $uid) { // check if a user is register in the session with other course - $sql = "SELECT id_user FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " - WHERE id_session='$session_id' AND id_user='$uid'"; + $sql = "SELECT user_id FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " + WHERE session_id='$session_id' AND user_id='$uid'"; $rs = Database::query($sql); if (Database::num_rows($rs) == 0) { // Delete in table session_rel_user $sql = "DELETE FROM " . Database::get_main_table(TABLE_MAIN_SESSION_USER) . " WHERE - id_session ='" . $session_id . "' AND - id_user='$uid' AND + session_id ='" . $session_id . "' AND + user_id = '$uid' AND relation_type<>" . SESSION_RELATION_TYPE_RRHH . ""; Database::query($sql); } @@ -464,7 +518,7 @@ class CourseManager // Update the table session $sql = "SELECT COUNT(*) FROM " . Database::get_main_table(TABLE_MAIN_SESSION_USER) . " - WHERE id_session = '" . $session_id . "' AND relation_type <> " . SESSION_RELATION_TYPE_RRHH; + WHERE session_id = '" . $session_id . "' AND relation_type <> " . SESSION_RELATION_TYPE_RRHH; $row = Database::fetch_array(Database::query($sql)); $count = $row[0]; // number of users by session @@ -474,14 +528,14 @@ class CourseManager // Update the table session_rel_course $sql = "SELECT COUNT(*) FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " - WHERE id_session = '$session_id' AND course_code = '$course_code' AND status<>2"; + WHERE session_id = '$session_id' AND c_id = '$course_id' AND status<>2"; $row = Database::fetch_array(@Database::query($sql)); $count = $row[0]; // number of users by session and course $sql = "UPDATE " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE) . " SET nbr_users = '$count' - WHERE id_session = '$session_id' AND course_code = '$course_code'"; + WHERE session_id = '$session_id' AND c_id = '$course_id'"; Database::query($sql); } else { @@ -489,11 +543,12 @@ class CourseManager WHERE user_id IN (" . $user_ids . ") AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . " AND - course_code = '" . $course_code . "'"; + c_id = '" . $course_id . "'"; Database::query($sql); // add event to system log $user_id = api_get_user_id(); + Event::addEvent( LOG_UNSUBSCRIBE_USER_FROM_COURSE, LOG_COURSE_CODE, @@ -537,6 +592,10 @@ class CourseManager } $course_code = Database::escape_string($course_code); + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + $courseCode = $courseInfo['code']; + $userCourseCategoryId = intval($userCourseCategoryId); if (empty($user_id) || empty ($course_code)) { @@ -553,7 +612,7 @@ class CourseManager //$role_id = ($status == COURSEMANAGER) ? COURSE_ADMIN : NORMAL_COURSE_MEMBER; // A preliminary check whether the user has bben already registered on the platform. - if (Database::num_rows(@Database::query( + if (Database::num_rows(Database::query( "SELECT status FROM " . Database::get_main_table(TABLE_MAIN_USER) . " WHERE user_id = '$user_id' ")) == 0 ) { @@ -561,77 +620,21 @@ class CourseManager } // Check whether the user has not been already subscribed to the course. + if (empty($session_id)) { - if (Database::num_rows(@Database::query(" + if (Database::num_rows(Database::query(" SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " - WHERE user_id = '$user_id' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . " AND course_code = '$course_code'")) > 0 + WHERE user_id = '$user_id' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . " AND c_id = '$courseId'")) > 0 ) { - return false; // The user has been already subscribed to the course. + // The user has been already subscribed to the course. + return false; } } if (!empty($session_id)) { - - // Check whether the user has not already been stored in the session_rel_course_user table - if (Database::num_rows(@Database::query(" - SELECT * FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " - WHERE - course_code = '" . $course_code . "' AND - id_session ='" . $session_id . "' AND - id_user = '" . $user_id . "'")) > 0 - ) { - return false; - } - - // check if the user is registered in the session with other course - $sql = "SELECT id_user FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " - WHERE id_session='" . $session_id . "' AND id_user='$user_id'"; - $rs = Database::query($sql); - if (Database::num_rows($rs) == 0) { - // Check whether the user has not already been stored in the session_rel_user table - if (Database::num_rows(@Database::query("SELECT * FROM " . Database::get_main_table(TABLE_MAIN_SESSION_USER) . " - WHERE id_session ='" . $session_id . "' - AND id_user = '" . $user_id . "' AND relation_type<>" . SESSION_RELATION_TYPE_RRHH . " ")) > 0 - ) { - return false; - } - } - - // Add him/her in the table session_rel_course_rel_user - @Database::query( - "INSERT INTO " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " - SET id_session ='" . $session_id . "', - course_code = '" . $course_code . "', - id_user = '" . $user_id . "'" - ); - - // Add him/her in the table session_rel_user - @Database::query( - "INSERT INTO " . Database::get_main_table(TABLE_MAIN_SESSION_USER) . " - SET id_session ='" . $session_id . "', - id_user = '" . $user_id . "'" - ); - - // Update the table session - $row = Database::fetch_array(@Database::query("SELECT COUNT(*) FROM " . Database::get_main_table(TABLE_MAIN_SESSION_USER) . " WHERE id_session = '" . $session_id . "' AND relation_type<>" . SESSION_RELATION_TYPE_RRHH . "")); - $count = $row[0]; // number of users by session - $result = @Database::query("UPDATE " . Database::get_main_table(TABLE_MAIN_SESSION) . " SET nbr_users = '$count' WHERE id = '" . $session_id . "'"); - - // Update the table session_rel_course - $row = Database::fetch_array(@Database::query("SELECT COUNT(*) FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " WHERE id_session = '" . $session_id . "' AND course_code = '$course_code' AND status<>2")); - $count = $row[0]; // number of users by session - $result = @Database::query("UPDATE " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE) . " SET nbr_users = '$count' WHERE id_session = '" . $session_id . "' AND course_code = '$course_code' "); - + SessionManager::subscribe_users_to_session_course(array($user_id), $session_id, $courseCode); } else { - $course_sort = self::userCourseSort($user_id, $course_code); - $sql = "INSERT INTO " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " - SET course_code = '$course_code', - user_id = '$user_id', - status = '" . $status . "', - sort = '" . ($course_sort) . "', - user_course_cat = $userCourseCategoryId - "; - $result = @Database::query($sql); + CourseManager::add_user_to_course($user_id, $courseCode, $status); // Add event to the system log Event::addEvent( @@ -651,7 +654,8 @@ class CourseManager api_get_user_id() ); } - return (bool)$result; + + return true; } /** @@ -713,7 +717,7 @@ class CourseManager * @return boolean true if subscription succeeds, boolean false otherwise. * @assert ('', '') === false */ - public static function add_user_to_course($user_id, $course_code, $status = STUDENT) + public static function add_user_to_course($user_id, $course_code, $status = STUDENT, $userCourseCategoryId = 0) { $debug = false; $user_table = Database::get_main_table(TABLE_MAIN_USER); @@ -724,7 +728,10 @@ class CourseManager if (empty($user_id) || empty($course_code) || ($user_id != strval(intval($user_id)))) { return false; } + $course_code = Database::escape_string($course_code); + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; // Check in advance whether the user has already been registered on the platform. $sql = "SELECT status FROM " . $user_table . " WHERE user_id = '$user_id' "; @@ -740,7 +747,7 @@ class CourseManager WHERE user_id = '$user_id' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . " AND - course_code = '$course_code'"; + c_id = '$courseId'"; if (Database::num_rows(Database::query($sql)) > 0) { if ($debug) { error_log('The user has been already subscribed to the course'); @@ -760,13 +767,16 @@ class CourseManager // Ok, subscribe the user. $max_sort = api_max_sort_value('0', $user_id); - return (bool)Database::query( - "INSERT INTO " . $course_user_table . " - SET course_code = '$course_code', - user_id = '$user_id', - status = '" . $status . "', - sort = '" . ($max_sort + 1) . "'" - ); + $params = [ + 'c_id' => $courseId, + 'user_id' => $user_id, + 'status' => $status, + 'sort' => $max_sort + 1, + 'user_course_cat' => $userCourseCategoryId + ]; + $insertId = Database::insert($course_user_table, $params); + + return $insertId; } /** @@ -811,6 +821,7 @@ class CourseManager /** * @return an array with the course info of all real courses on the platform + *@deprecate don't use this function */ public static function get_real_course_list() { @@ -825,36 +836,6 @@ class CourseManager return $real_course_list; } - /** - * Returns an array with the course info of the real courses of which - * the current user is course admin - * @return array A list of courses details for courses to which the user is subscribed as course admin (status = 1) - */ - public static function get_real_course_list_of_user_as_course_admin($user_id) - { - $result_array = array(); - if ($user_id != strval(intval($user_id))) { - return $result_array; - } - $sql_result = Database::query( - "SELECT * - FROM " . Database::get_main_table(TABLE_MAIN_COURSE) . " course - LEFT JOIN " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " course_user - ON course.code = course_user.course_code - WHERE course.target_course_code IS NULL - AND course_user.user_id = '$user_id' - AND course_user.status = '1'" - ); - if ($sql_result === false) { - return $result_array; - } - while ($result = Database::fetch_array($sql_result)) { - $result_array[] = $result; - } - - return $result_array; - } - /** * Get course list as coach * @@ -871,7 +852,7 @@ class CourseManager if (!empty($courses_temp)) { foreach ($courses_temp as $course_item) { - $courseList[0][$course_item['course_code']] = $course_item['course_code']; + $courseList[0][$course_item['code']] = $course_item['code']; } } @@ -966,14 +947,13 @@ class CourseManager $data = array(); $sql = "SELECT - course_rel_user.course_code, + course.code, course.title, course.id, - course.db_name, course.id as real_id FROM $tbl_course_user as course_rel_user INNER JOIN $tbl_course as course - ON course.code = course_rel_user.course_code + ON course.id = course_rel_user.c_id WHERE course_rel_user.user_id='$user_id' AND course_rel_user.status='1' @@ -985,20 +965,19 @@ class CourseManager if ($access_url_id != -1) { $sql = " SELECT - course_rel_user.course_code, + course.code, course.title, course.id, - course.db_name, course.id as real_id FROM $tbl_course_user as course_rel_user INNER JOIN $tbl_course as course - ON course.code = course_rel_user.course_code + ON course.id = course_rel_user.c_id INNER JOIN $tbl_course_rel_access_url course_rel_url - ON (course_rel_url.course_code= course.code) + ON (course_rel_url.c_id = course.id) WHERE - access_url_id = $access_url_id AND - course_rel_user.user_id='$user_id' AND - course_rel_user.status='1' + access_url_id = $access_url_id AND + course_rel_user.user_id = '$user_id' AND + course_rel_user.status = '1' ORDER BY course.title"; } } @@ -1006,7 +985,7 @@ class CourseManager $result_nb_cours = Database::query($sql); if (Database::num_rows($result_nb_cours) > 0) { while ($row = Database::fetch_array($result_nb_cours, 'ASSOC')) { - $data[$row['course_code']] = $row; + $data[$row['id']] = $row; } } @@ -1050,14 +1029,15 @@ class CourseManager if (empty($courseInfo) || empty($userId)) { return false; } - $courseCode = Database::escape_string($courseInfo['code']); + + $courseId = intval($courseInfo['real_id']); $table = Database::get_main_table(TABLE_MAIN_COURSE_USER); $sql = "SELECT * FROM $table WHERE user_id = $userId AND relation_type = " . COURSE_RELATION_TYPE_RRHH . " AND - course_code = '$courseCode'"; + c_id = $courseId"; $result = Database::fetch_array(Database::query($sql)); @@ -1090,12 +1070,19 @@ class CourseManager $condition_course = ''; if (isset($course_code)) { - $course_code = Database::escape_string($course_code); - $condition_course = ' AND course_code = "' . $course_code . '" '; + $courseInfo = api_get_course_info($course_code); + if (empty($courseInfo)) { + return false; + } + $courseId = $courseInfo['real_id']; + $condition_course = ' AND c_id = ' . $courseId; } $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " - WHERE user_id = $user_id AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . " $condition_course "; + WHERE + user_id = $user_id AND + relation_type<>" . COURSE_RELATION_TYPE_RRHH . " + $condition_course "; $result = Database::fetch_array(Database::query($sql)); @@ -1111,19 +1098,19 @@ class CourseManager $tableSessionCourseUser = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $sql = 'SELECT 1 FROM ' . $tableSessionCourseUser . - ' WHERE id_user = ' . $user_id . ' ' . $condition_course; + ' WHERE user_id = ' . $user_id . ' ' . $condition_course; if (Database::num_rows(Database::query($sql)) > 0) { return true; } $sql = 'SELECT 1 FROM ' . $tableSessionCourseUser . - ' WHERE id_user = ' . $user_id . ' AND status=2 ' . $condition_course; + ' WHERE user_id = ' . $user_id . ' AND status=2 ' . $condition_course; if (Database::num_rows(Database::query($sql)) > 0) { return true; } $sql = 'SELECT 1 FROM ' . Database::get_main_table(TABLE_MAIN_SESSION) . - ' WHERE id=' . $session_id . ' AND id_coach=' . $user_id; + ' WHERE id = ' . $session_id . ' AND id_coach=' . $user_id; if (Database::num_rows(Database::query($sql)) > 0) { return true; @@ -1145,13 +1132,19 @@ class CourseManager if ($user_id != strval(intval($user_id))) { return false; } - $sql_result = Database::query( + + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + + $result = Database::query( 'SELECT status FROM ' . Database::get_main_table(TABLE_MAIN_COURSE_USER) . - ' WHERE course_code="' . Database::escape_string($course_code) . '" and user_id="' . $user_id . '"' + ' WHERE c_id="' . $courseId . '" and user_id="' . $user_id . '"' ); - if (Database::num_rows($sql_result) > 0) { - return Database::result($sql_result, 0, 'status') == 1; + + if (Database::num_rows($result) > 0) { + return Database::result($result, 0, 'status') == 1; } + return false; } @@ -1177,7 +1170,7 @@ class CourseManager "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE) . " course LEFT JOIN " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " course_user - ON course.code = course_user.course_code + ON course.id = course_user.c_id WHERE course_user.user_id = '$user_id' AND course_user.relation_type<>" . COURSE_RELATION_TYPE_RRHH . " AND @@ -1193,29 +1186,29 @@ class CourseManager // Is he/she subscribed to the session's course? // A user? - if (Database::num_rows(Database::query("SELECT id_user - FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " - WHERE id_session='" . $session_id . "' - AND id_user='$user_id'")) + if (Database::num_rows(Database::query("SELECT user_id + FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " + WHERE session_id='" . $session_id . "' + AND user_id ='$user_id'")) ) { return true; } // A course coach? - if (Database::num_rows(Database::query("SELECT id_user - FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " - WHERE id_session='" . $session_id . "' - AND id_user = '$user_id' AND status = 2 - AND course_code='$course_code'")) + if (Database::num_rows(Database::query("SELECT user_id + FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " + WHERE session_id='" . $session_id . "' + AND user_id = '$user_id' AND status = 2 + AND course_code='$course_code'")) ) { return true; } // A session coach? if (Database::num_rows(Database::query("SELECT id_coach - FROM " . Database::get_main_table(TABLE_MAIN_SESSION) . " AS session - WHERE session.id='" . $session_id . "' - AND id_coach='$user_id'")) + FROM " . Database::get_main_table(TABLE_MAIN_SESSION) . " AS session + WHERE session.id='" . $session_id . "' + AND id_coach='$user_id'")) ) { return true; } @@ -1293,7 +1286,7 @@ class CourseManager $sql = 'SELECT DISTINCT user.user_id, session_course_user.status as status_session, - id_session, + session_id, user.*, course.*, session.name as session_name @@ -1302,29 +1295,29 @@ class CourseManager $sql = " SELECT COUNT(user.user_id) as count"; } - $sessionCondition = " session_course_user.id_session = $session_id"; + $sessionCondition = " session_course_user.session_id = $session_id"; if (!empty($sessionIdList)) { $sessionIdListTostring = implode("','", array_map('intval', $sessionIdList)); - $sessionCondition = " session_course_user.id_session IN ('$sessionIdListTostring') "; + $sessionCondition = " session_course_user.session_id IN ('$sessionIdListTostring') "; } - $courseCondition = " session_course_user.course_code = '".$course_code."' AND "; + $courseCondition = " course.code = '".$course_code."' "; if (!empty($courseCodeList)) { $courseCodeListForSession = array_map(array('Database', 'escape_string'), $courseCodeList); $courseCodeListForSession = implode('","', $courseCodeListForSession); - $courseCondition = ' session_course_user.course_code IN ("' . $courseCodeListForSession . '") AND '; + $courseCondition = ' course.code IN ("' . $courseCodeListForSession . '") '; } $sql .= ' FROM ' . Database::get_main_table(TABLE_MAIN_USER) . ' as user '; $sql .= " LEFT JOIN ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " as session_course_user ON - user.user_id = session_course_user.id_user AND - $courseCondition + user.user_id = session_course_user.user_id AND $sessionCondition - INNER JOIN $course_table course ON session_course_user.course_code = course.code - INNER JOIN $sessionTable session ON session_course_user.id_session = session.id + INNER JOIN $course_table course ON session_course_user.c_id = course.id AND + $courseCondition + INNER JOIN $sessionTable session ON session_course_user.session_id = session.id "; - $where[] = ' session_course_user.course_code IS NOT NULL '; + $where[] = ' session_course_user.c_id IS NOT NULL '; // 2 = coach // 0 = student @@ -1332,7 +1325,6 @@ class CourseManager $filter_by_status = intval($filter_by_status); $filter_by_status_condition = " session_course_user.status = $filter_by_status AND "; } - } else { if ($return_count) { $sql = " SELECT COUNT(*) as count"; @@ -1346,15 +1338,13 @@ class CourseManager course.code, course_rel_user.status as status_rel, user.user_id, - course_rel_user.role, - course_rel_user.tutor_id, + course_rel_user.is_tutor, user.* '; } else { $sql = 'SELECT DISTINCT course_rel_user.status as status_rel, user.user_id, - course_rel_user.role, - course_rel_user.tutor_id, + course_rel_user.is_tutor, user.* '; } } @@ -1363,12 +1353,12 @@ class CourseManager $sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_COURSE_USER) . ' as course_rel_user ON user.user_id = course_rel_user.user_id AND course_rel_user.relation_type <> ' . COURSE_RELATION_TYPE_RRHH . ' '; + $sql .= " INNER JOIN $course_table course ON course_rel_user.c_id = course.id "; + if (!empty($course_code)) { - $sql .= ' AND course_rel_user.course_code="' . $course_code . '"'; - } else { - $sql .= " INNER JOIN $course_table course ON course_rel_user.course_code = course.code "; + $sql .= ' AND course_rel_user.c_id="' . $courseId . '"'; } - $where[] = ' course_rel_user.course_code IS NOT NULL '; + $where[] = ' course_rel_user.c_id IS NOT NULL '; if (isset($filter_by_status) && is_numeric($filter_by_status)) { $filter_by_status = intval($filter_by_status); @@ -1378,7 +1368,7 @@ class CourseManager $multiple_access_url = api_get_multiple_access_url(); if ($multiple_access_url) { - $sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER) . ' au ON (au.user_id = user.user_id) '; + $sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER) . ' au ON (au.user_id = user.user_id) '; } $extraFieldWasAdded = false; @@ -1452,18 +1442,15 @@ class CourseManager $user_info = $user; $user_info['status'] = $user['status']; - if (isset($user['role'])) { - $user_info['role'] = $user['role']; - } - if (isset($user['tutor_id'])) { - $user_info['tutor_id'] = $user['tutor_id']; + if (isset($user['is_tutor'])) { + $user_info['is_tutor'] = $user['is_tutor']; } if (!empty($session_id)) { $user_info['status_session'] = $user['status_session']; } - $sessionId = isset($user['id_session']) ? $user['id_session'] : 0; + $sessionId = isset($user['session_id']) ? $user['session_id'] : 0; $course_code = isset($user['code']) ? $user['code'] : null; if ($add_reports) { @@ -1648,20 +1635,26 @@ class CourseManager $session_id = intval($session_id); $course_code = Database::escape_string($course_code); + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + $sql = 'SELECT DISTINCT count(*) as count FROM ' . Database::get_main_table(TABLE_MAIN_USER) . ' as user '; $where = array(); if (!empty($session_id)) { $sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . ' as session_course_user - ON user.user_id = session_course_user.id_user - AND session_course_user.course_code = "' . $course_code . '" - AND session_course_user.id_session = ' . $session_id; + ON + user.user_id = session_course_user.user_id AND + session_course_user.c_id = "' . $courseId . '" AND + session_course_user.session_id = ' . $session_id; - $where[] = ' session_course_user.course_code IS NOT NULL '; + $where[] = ' session_course_user.c_id IS NOT NULL '; } else { $sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_COURSE_USER) . ' as course_rel_user - ON user.user_id = course_rel_user.user_id AND course_rel_user.relation_type<>' . COURSE_RELATION_TYPE_RRHH . ' - AND course_rel_user.course_code="' . $course_code . '"'; - $where[] = ' course_rel_user.course_code IS NOT NULL '; + ON + user.user_id = course_rel_user.user_id AND + course_rel_user.relation_type<>' . COURSE_RELATION_TYPE_RRHH . ' AND + course_rel_user.c_id = ' . $courseId ; + $where[] = ' course_rel_user.c_id IS NOT NULL '; } $multiple_access_url = api_get_multiple_access_url(); @@ -1681,6 +1674,7 @@ class CourseManager $user = Database::fetch_array($rs); $count = $user['count']; } + return $count; } @@ -1697,20 +1691,22 @@ class CourseManager } $course_code = Database::escape_string($course_code); + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + $session_id = intval($session_id); $users = array(); // We get the coach for the given course in a given session. - $sql = 'SELECT id_user FROM ' . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . - ' WHERE id_session="' . $session_id . '" AND course_code="' . $course_code . '" AND status = 2'; + $sql = 'SELECT user_id FROM ' . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . + ' WHERE session_id ="' . $session_id . '" AND c_id="' . $courseId . '" AND status = 2'; $rs = Database::query($sql); while ($user = Database::fetch_array($rs)) { - $user_info = api_get_user_info($user['id_user']); + $user_info = api_get_user_info($user['user_id']); $user_info['status'] = $user['status']; - $user_info['role'] = $user['role']; - $user_info['tutor_id'] = $user['tutor_id']; + //$user_info['tutor_id'] = $user['tutor_id']; $user_info['email'] = $user['email']; - $users[$user['id_user']] = $user_info; + $users[$user['user_id']] = $user_info; } $table = Database::get_main_table(TABLE_MAIN_SESSION); @@ -1720,8 +1716,7 @@ class CourseManager $session_id_coach = Database::result($rs, 0, 'id_coach'); $user_info = api_get_user_info($session_id_coach); $user_info['status'] = $user['status']; - $user_info['role'] = $user['role']; - $user_info['tutor_id'] = $user['tutor_id']; + //$user_info['tutor_id'] = $user['tutor_id']; $user_info['email'] = $user['email']; $users[$session_id_coach] = $user_info; @@ -1748,17 +1743,21 @@ class CourseManager $date_to = null, $includeInvitedUsers = true ) { + + $userTable = Database::get_main_table(TABLE_MAIN_USER); $session_id = intval($session_id); $course_code = Database::escape_string($course_code); - $userTable = Database::get_main_table(TABLE_MAIN_USER); + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; $students = array(); if ($session_id == 0) { // students directly subscribed to the course $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " cu - INNER JOIN $userTable u ON cu.user_id = u.user_id - WHERE course_code = '$course_code' AND cu.status = " . STUDENT; + INNER JOIN $userTable u + ON cu.user_id = u.user_id + WHERE c_id = '$courseId' AND cu.status = " . STUDENT; if (!$includeInvitedUsers) { $sql .= " AND u.status != " . INVITEE; @@ -1782,8 +1781,8 @@ class CourseManager $sql_query = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " scu $joinSession - INNER JOIN $userTable u ON scu.id_user = u.user_id - WHERE scu.course_code = '$course_code' AND scu.status <> 2"; + INNER JOIN $userTable u ON scu.user_id = u.user_id + WHERE scu.c_id = '$courseId' AND scu.status <> 2"; if (!empty($date_from) && !empty($date_to)) { $date_from = Database::escape_string($date_from); @@ -1792,16 +1791,16 @@ class CourseManager } if ($session_id != 0) { - $sql_query .= ' AND scu.id_session = ' . $session_id; + $sql_query .= ' AND scu.session_id = ' . $session_id; } if (!$includeInvitedUsers) { - $sql .= " AND u.status != " . INVITEE; + $sql_query .= " AND u.status != " . INVITEE; } $rs = Database::query($sql_query); while ($student = Database::fetch_array($rs)) { - $students[$student['id_user']] = $student; + $students[$student['user_id']] = $student; } } @@ -1817,18 +1816,28 @@ class CourseManager */ public static function get_teacher_list_from_course_code($course_code) { - $course_code = Database::escape_string($course_code); - $teachers = array(); - $sql = "SELECT DISTINCT u.id, u.lastname, u.firstname, u.email, u.username, u.status + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + + $sql = "SELECT DISTINCT + u.id as user_id, + u.lastname, + u.firstname, + u.email, + u.username, + u.status FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " cu INNER JOIN " . Database::get_main_table(TABLE_MAIN_USER) . " u ON (cu.user_id = u.id) - WHERE cu.course_code = '$course_code' AND - cu.status = 1 "; + WHERE + cu.c_id = $courseId AND + cu.status = 1 "; $rs = Database::query($sql); + $teachers = array(); while ($teacher = Database::fetch_array($rs)) { - $teachers[$teacher['id']] = $teacher; + $teachers[$teacher['user_id']] = $teacher; } + return $teachers; } @@ -1845,6 +1854,7 @@ class CourseManager $add_link_to_profile = false ) { $teacher_list = self::get_teacher_list_from_course_code($course_code); + $teacher_string = ''; $list = array(); if (!empty($teacher_list)) { @@ -1872,12 +1882,12 @@ class CourseManager /** * This function returns information about coachs from a course in session - * @param int - optional, session id - * @param string - optional, course code + * @param int $session_id + * @param int $courseId * @return array - array containing user_id, lastname, firstname, username * */ - public static function get_coachs_from_course($session_id = 0, $course_code = '') + public static function get_coachs_from_course($session_id = 0, $courseId = '') { if (!empty($session_id)) { $session_id = intval($session_id); @@ -1885,44 +1895,51 @@ class CourseManager $session_id = api_get_session_id(); } - if (!empty($course_code)) { - $course_code = Database::escape_string($course_code); + if (!empty($courseId)) { + $courseId = intval($courseId); } else { - $course_code = api_get_course_id(); + $courseId = api_get_course_int_id(); } $tbl_user = Database:: get_main_table(TABLE_MAIN_USER); $tbl_session_course_user = Database:: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $coaches = array(); - $sql = "SELECT DISTINCT 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"; + $sql = "SELECT DISTINCT u.user_id,u.lastname,u.firstname,u.username + FROM $tbl_user u, $tbl_session_course_user scu + WHERE + u.user_id = scu.user_id AND + scu.session_id = '$session_id' AND + scu.c_id = '$courseId' AND + scu.status = 2"; $rs = Database::query($sql); if (Database::num_rows($rs) > 0) { while ($row = Database::fetch_array($rs)) { $coaches[] = $row; } + return $coaches; } else { + return false; } } /** * @param int $session_id - * @param string $course_code + * @param int $courseId * @param string $separator * @param bool $add_link_to_profile * @return null|string */ public static function get_coachs_from_course_to_string( $session_id = 0, - $course_code = null, + $courseId = null, $separator = self::USER_SEPARATOR, $add_link_to_profile = false ) { - $coachs_course = self::get_coachs_from_course($session_id, $course_code); + $coachs_course = self::get_coachs_from_course($session_id, $courseId); $course_coachs = array(); if (is_array($coachs_course)) { @@ -1943,15 +1960,16 @@ class CourseManager } /** - * @param string $course_code + * @param int $courseId * @param int $session_id * @return string + * @deprecated seem not to be use */ - public static function get_coach_list_from_course_code_to_string($course_code, $session_id) + public static function get_coach_list_from_course_code_to_string($courseId, $session_id) { $tutor_data = ''; if ($session_id != 0) { - $coaches = self::get_email_of_tutor_to_session($session_id, $course_code); + $coaches = self::get_email_of_tutor_to_session($session_id, $courseId); $coach_list = array(); foreach ($coaches as $coach) { $coach_list[] = $coach['complete_name']; @@ -2018,7 +2036,7 @@ class CourseManager $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE) . " course LEFT JOIN " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " course_user - ON course.code = course_user.course_code + ON course.id = course_user.c_id WHERE course.target_course_code = '$course_code' AND course_user.user_id = '$user_id' AND @@ -2122,26 +2140,32 @@ class CourseManager $codeFiltered = Database::escape_string($code); $sql = "SELECT * FROM $table_course WHERE code='" . $codeFiltered . "'"; $res = Database::query($sql); + if (Database::num_rows($res) == 0) { return; } + + + $sql = "SELECT * FROM $table_course WHERE code = '" . $codeFiltered . "'"; + $res = Database::query($sql); + $course = Database::fetch_array($res); + $courseId = $course['id']; + $count = 0; if (api_is_multiple_url_enabled()) { $url_id = 1; if (api_get_current_access_url_id() != -1) { $url_id = api_get_current_access_url_id(); } - UrlManager::delete_url_rel_course($code, $url_id); - $count = UrlManager::getcountUrlRelCourse($code); + UrlManager::delete_url_rel_course($courseId, $url_id); + $count = UrlManager::getcountUrlRelCourse($courseId); } + if ($count == 0) { self::create_database_dump($code); - $sql = "SELECT * FROM $table_course WHERE code = '" . $codeFiltered . "'"; - $res = Database::query($sql); - $course = Database::fetch_array($res); $course_tables = AddCourse::get_course_tables(); - $courseId = $course['id']; + // Cleaning c_x tables if (!empty($courseId)) { @@ -2162,16 +2186,16 @@ class CourseManager /*$sql = "DELETE FROM $table_course_class WHERE course_code='".$code."'"; Database::query($sql);*/ // Unsubscribe all users from the course - $sql = "DELETE FROM $table_course_user WHERE course_code='" . $codeFiltered . "'"; + $sql = "DELETE FROM $table_course_user WHERE c_id='" . $courseId . "'"; Database::query($sql); // Delete the course from the sessions tables - $sql = "DELETE FROM $table_session_course WHERE course_code='" . $codeFiltered . "'"; + $sql = "DELETE FROM $table_session_course WHERE c_id='" . $courseId . "'"; Database::query($sql); - $sql = "DELETE FROM $table_session_course_user WHERE course_code='" . $codeFiltered . "'"; + $sql = "DELETE FROM $table_session_course_user WHERE c_id='" . $courseId . "'"; Database::query($sql); // Delete from Course - URL - $sql = "DELETE FROM $table_course_rel_url WHERE course_code = '" . $codeFiltered . "'"; + $sql = "DELETE FROM $table_course_rel_url WHERE c_id = '" . $courseId. "'"; Database::query($sql); $sql = 'SELECT survey_id FROM ' . $table_course_survey . ' WHERE course_code="' . $codeFiltered . '"'; @@ -2274,11 +2298,6 @@ class CourseManager */ public static function create_database_dump($course_code) { - global $_configuration; - - if ($_configuration['single_database']) { - return; - } $sql_dump = ''; $course_code = Database::escape_string($course_code); $table_course = Database::get_main_table(TABLE_MAIN_COURSE); @@ -2326,7 +2345,6 @@ class CourseManager */ public static function userCourseSort($user_id, $course_code) { - if ($user_id != strval(intval($user_id))) { return false; } @@ -2338,8 +2356,9 @@ class CourseManager $course_title = Database::result(Database::query('SELECT title FROM ' . $TABLECOURSE . ' WHERE code="' . $course_code . '"'), 0, 0); - $sql = 'SELECT course.code as code, course.title as title, cu.sort as sort FROM ' . $TABLECOURSUSER . ' as cu, ' . $TABLECOURSE . ' as course - WHERE course.code = cu.course_code AND user_id = "' . $user_id . '" AND + $sql = 'SELECT course.code as code, course.title as title, cu.sort as sort + FROM ' . $TABLECOURSUSER . ' as cu, ' . $TABLECOURSE . ' as course + WHERE course.id = cu.c_id AND user_id = "' . $user_id . '" AND cu.relation_type<>' . COURSE_RELATION_TYPE_RRHH . ' AND user_course_cat = 0 ORDER BY cu.sort'; @@ -2359,12 +2378,21 @@ class CourseManager $course_found = true; $course_sort = $courses['sort']; if ($counter == 0) { - $sql = 'UPDATE ' . $TABLECOURSUSER . ' SET sort = sort+1 - WHERE user_id= "' . $user_id . '" AND relation_type<>' . COURSE_RELATION_TYPE_RRHH . ' AND user_course_cat="0" AND sort > "' . $course_sort . '"'; + $sql = 'UPDATE ' . $TABLECOURSUSER . ' + SET sort = sort+1 + WHERE + user_id= "' . $user_id . '" AND + relation_type<>' . COURSE_RELATION_TYPE_RRHH . ' + AND user_course_cat="0" + AND sort > "' . $course_sort . '"'; $course_sort++; } else { $sql = 'UPDATE ' . $TABLECOURSUSER . ' SET sort = sort+1 - WHERE user_id= "' . $user_id . '" AND relation_type<>' . COURSE_RELATION_TYPE_RRHH . ' AND user_course_cat="0" AND sort >= "' . $course_sort . '"'; + WHERE + user_id= "' . $user_id . '" AND + relation_type<>' . COURSE_RELATION_TYPE_RRHH . ' AND + user_course_cat="0" AND + sort >= "' . $course_sort . '"'; } Database::query($sql); break; @@ -2427,34 +2455,33 @@ class CourseManager * @param bool $send_to_tutor_also * @return string we return the message that is displayed when the action is successful */ - public static function email_to_tutor($user_id, $course_code, $send_to_tutor_also = false) + public static function email_to_tutor($user_id, $courseId, $send_to_tutor_also = false) { - if ($user_id != strval(intval($user_id))) { return false; } $course_code = Database::escape_string($course_code); - - $student = Database::fetch_array(Database::query("SELECT * FROM " . Database::get_main_table(TABLE_MAIN_USER) . " - WHERE user_id='" . $user_id . "'")); $information = self::get_course_information($course_code); + $courseId = $information['id']; + + $student = api_get_user_info($user_id); + $name_course = $information['title']; - $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " WHERE course_code='" . $course_code . "'"; + $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " WHERE c_id ='" . $courseId . "'"; // TODO: Ivan: This is a mistake, please, have a look at it. Intention here is diffcult to be guessed. //if ($send_to_tutor_also = true) // Proposed change: if ($send_to_tutor_also) { - $sql .= " AND tutor_id=1"; + $sql .= " AND is_tutor=1"; } else { $sql .= " AND status=1"; } $result = Database::query($sql); while ($row = Database::fetch_array($result)) { - $tutor = Database::fetch_array(Database::query("SELECT * FROM " . Database::get_main_table(TABLE_MAIN_USER) . " - WHERE user_id='" . $row['user_id'] . "'")); + $tutor = api_get_user_info($row['user_id']); $emailto = $tutor['email']; $emailsubject = get_lang('NewUserInTheCourse') . ': ' . $name_course; $emailbody = get_lang('Dear') . ': ' . api_get_person_name($tutor['firstname'], $tutor['lastname']) . "\n"; @@ -2474,9 +2501,8 @@ class CourseManager api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); $email_admin = api_get_setting('emailAdministrator'); - $plugin = new AppPlugin(); $additionalParameters = array( - 'smsType' => constant($plugin->getSMSPluginName() . '::NEW_USER_SUBSCRIBED_COURSE'), + 'smsType' => SmsPlugin::NEW_USER_SUBSCRIBED_COURSE, 'userId' => $tutor['user_id'], 'userUsername' => $student['username'], 'courseCode' => $course_code @@ -2502,6 +2528,7 @@ class CourseManager */ public static function get_special_course_list() { + $courseTable = Database:: get_main_table(TABLE_MAIN_COURSE); $tbl_course_field = Database:: get_main_table(TABLE_MAIN_COURSE_FIELD); $tbl_course_field_value = Database:: get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES); @@ -2511,16 +2538,18 @@ class CourseManager $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); - $join_access_url = "LEFT JOIN $tbl_url_course url_rel_course ON url_rel_course.course_code= tcfv.course_code "; + $join_access_url = "LEFT JOIN $tbl_url_course url_rel_course ON url_rel_course.c_id = tcfv.c_id "; $where_access_url = " AND access_url_id = $access_url_id "; } } // get course list auto-register - $sql = "SELECT DISTINCT(tcfv.course_code) + $sql = "SELECT DISTINCT(c.code) FROM $tbl_course_field_value tcfv INNER JOIN $tbl_course_field tcf ON tcfv.field_id = tcf.id $join_access_url + INNER JOIN $courseTable c + ON (c.id = tcfv.c_id) WHERE tcf.field_variable = 'special_course' AND tcfv.field_value = 1 $where_access_url"; @@ -2563,14 +2592,14 @@ class CourseManager if (!empty($with_special_courses)) { $sql = "SELECT DISTINCT(course.code), course.id as real_id - FROM " . $tbl_course_user . " course_rel_user - LEFT JOIN " . $tbl_course . " course - ON course.code = course_rel_user.course_code - LEFT JOIN " . $tbl_user_course_category . " user_course_category - ON course_rel_user.user_course_cat = user_course_category.id - WHERE $with_special_courses - GROUP BY course.code - ORDER BY user_course_category.sort,course.title,course_rel_user.sort ASC"; + FROM " . $tbl_course_user . " course_rel_user + LEFT JOIN " . $tbl_course . " course + ON course.id = course_rel_user.c_id + LEFT JOIN " . $tbl_user_course_category . " user_course_category + ON course_rel_user.user_course_cat = user_course_category.id + WHERE $with_special_courses + GROUP BY course.code + ORDER BY user_course_category.sort,course.title,course_rel_user.sort ASC"; $rs_special_course = Database::query($sql); if (Database::num_rows($rs_special_course) > 0) { while ($result_row = Database::fetch_array($rs_special_course)) { @@ -2585,7 +2614,7 @@ class CourseManager // entries when a course is assigned to a HRD (DRH) as watcher $sql = "SELECT DISTINCT(course.code), course.id as real_id FROM $tbl_course course - INNER JOIN $tbl_course_user cru ON course.code=cru.course_code + INNER JOIN $tbl_course_user cru ON course.id = cru.c_id WHERE cru.user_id='$user_id' $without_special_courses"; $result = Database::query($sql); @@ -2600,7 +2629,7 @@ class CourseManager if ($include_sessions === true) { $sql = "SELECT DISTINCT(c.code), c.id as real_id FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " s, " . Database::get_main_table(TABLE_MAIN_COURSE) . " c - WHERE id_user = $user_id AND s.course_code=c.code"; + WHERE user_id = $user_id AND s.c_id = c.id"; $r = Database::query($sql); while ($row = Database::fetch_array($r, 'ASSOC')) { if (!in_array($row['real_id'], $codes)) { @@ -2655,11 +2684,11 @@ class CourseManager * @return array List of emails of tutors to course * @author @author Carlos Vargas , Dokeos Latino * */ - public static function get_emails_of_tutors_to_course($code) + public static function get_emails_of_tutors_to_course($courseId) { $list = array(); $res = Database::query("SELECT user_id FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " - WHERE course_code='" . Database::escape_string($code) . "' AND status=1"); + WHERE c_id ='" . intval($courseId) . "' AND status=1"); while ($list_users = Database::fetch_array($res)) { $result = Database::query("SELECT * FROM " . Database::get_main_table(TABLE_MAIN_USER) . " WHERE user_id=" . $list_users['user_id']); @@ -2674,28 +2703,33 @@ class CourseManager /** * Get coaches emails by session * @param int session id - * @param string course code + * @param int $courseId * @return array array(email => name_tutor) by coach * @author Carlos Vargas */ - public static function get_email_of_tutor_to_session($session_id, $course_code) + public static function get_email_of_tutor_to_session($session_id, $courseId) { $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $coachs_emails = array(); - $course_code = Database::escape_string($course_code); + $courseId = intval($courseId); $session_id = intval($session_id); - $sql = "SELECT id_user FROM $tbl_session_course_user - WHERE id_session='$session_id' AND course_code='$course_code' AND status = 2"; + $sql = "SELECT user_id + FROM $tbl_session_course_user + WHERE + session_id = '$session_id' AND + c_id = '$courseId' AND + status = 2 + "; $rs = Database::query($sql); if (Database::num_rows($rs) > 0) { $user_ids = array(); while ($row = Database::fetch_array($rs)) { - $user_ids[] = $row['id_user']; + $user_ids[] = $row['user_id']; } $sql = "SELECT firstname, lastname, email FROM $tbl_user @@ -3035,51 +3069,6 @@ class CourseManager return Database::fetch_array(Database::query($sql)); } - /** - * This code creates a select form element to let the user - * choose a real course to link to. - * - * A good non-display library should not use echo statements, but just return text/html - * so users of the library can choose when to display. - * - * We display the course code, but internally store the course id. - * - * @param boolean $has_size , true the select tag gets a size element, false it stays a dropdownmenu - * @param boolean $only_current_user_courses , true only the real courses of which the - * current user is course admin are displayed, false all real courses are shown. - * @param string $element_name the name of the select element - * @return a string containing html code for a form select element. - * @deprecated Function not in use - */ - public static function get_real_course_code_select_html( - $element_name, - $has_size = true, - $only_current_user_courses = true, - $user_id - ) { - if ($only_current_user_courses) { - $real_course_list = self::get_real_course_list_of_user_as_course_admin($user_id); - } else { - $real_course_list = self::get_real_course_list(); - } - - if ($has_size) { - $size_element = "size=\"" . SELECT_BOX_SIZE . "\""; - } else { - $size_element = ""; - } - $html_code = "\n"; - - return $html_code; - } - /** * Get count rows of a table inside a course database * @param string $table The table of which the rows should be counted @@ -3113,12 +3102,8 @@ class CourseManager * @param array $courses_list Courses code * @return int **/ - public static function suscribe_courses_to_hr_manager($hr_manager_id, $courses_list) + public static function subscribeCoursesToDrhManager($hr_manager_id, $courses_list) { - global $_configuration; - - // Database Table Definitions - $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); $tbl_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); @@ -3126,10 +3111,14 @@ class CourseManager $affected_rows = 0; //Deleting assigned courses to hrm_id - if ($_configuration['multiple_access_urls']) { - $sql = "SELECT s.course_code FROM $tbl_course_rel_user s - INNER JOIN $tbl_course_rel_access_url a ON (a.course_code = s.course_code) - WHERE user_id = $hr_manager_id AND relation_type=" . COURSE_RELATION_TYPE_RRHH . " AND access_url_id = " . api_get_current_access_url_id() . ""; + if (api_is_multiple_url_enabled()) { + $sql = "SELECT s.c_id FROM $tbl_course_rel_user s + INNER JOIN $tbl_course_rel_access_url a + ON (a.c_id = s.c_id) + WHERE + user_id = $hr_manager_id AND + relation_type=" . COURSE_RELATION_TYPE_RRHH . " AND + access_url_id = " . api_get_current_access_url_id() . ""; } else { $sql = "SELECT course_code FROM $tbl_course_rel_user WHERE user_id = $hr_manager_id AND relation_type=" . COURSE_RELATION_TYPE_RRHH . " "; @@ -3138,7 +3127,10 @@ class CourseManager if (Database::num_rows($result) > 0) { while ($row = Database::fetch_array($result)) { $sql = "DELETE FROM $tbl_course_rel_user - WHERE course_code = '{$row['course_code']}' AND user_id = $hr_manager_id AND relation_type=" . COURSE_RELATION_TYPE_RRHH . " "; + WHERE + c_id = '{$row['c_id']}' AND + user_id = $hr_manager_id AND + relation_type=" . COURSE_RELATION_TYPE_RRHH . " "; Database::query($sql); } } @@ -3146,9 +3138,10 @@ class CourseManager // inserting new courses list if (is_array($courses_list)) { foreach ($courses_list as $course_code) { - $course_code = Database::escape_string($course_code); - $sql = "INSERT IGNORE INTO $tbl_course_rel_user(course_code, user_id, status, relation_type) - VALUES('$course_code', $hr_manager_id, '" . DRH . "', '" . COURSE_RELATION_TYPE_RRHH . "')"; + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + $sql = "INSERT IGNORE INTO $tbl_course_rel_user(c_id, user_id, status, relation_type) + VALUES('$courseId', $hr_manager_id, '" . DRH . "', '" . COURSE_RELATION_TYPE_RRHH . "')"; $result = Database::query($sql); if (Database::affected_rows($result)) { $affected_rows++; @@ -3220,10 +3213,10 @@ class CourseManager $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $sessionId = intval($sessionId); $user_id = intval($user_id); - $select = "SELECT DISTINCT *, id as real_id "; + $select = "SELECT DISTINCT *, c.id as real_id "; if ($getCount) { - $select = "SELECT COUNT(DISTINCT id) as count"; + $select = "SELECT COUNT(DISTINCT c.id) as count"; } $whereConditions = null; @@ -3266,15 +3259,15 @@ class CourseManager $tableSessionRelCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $orderBy = ' ORDER BY position'; $extraInnerJoin = " INNER JOIN $tableSessionRelCourse src - ON (c.code = src.course_code AND id_session = $sessionId) "; + ON (c.code = src.course_code AND session_id = $sessionId) "; } } $whereConditions .= $keywordCondition; $sql = "$select FROM $tbl_course c - INNER JOIN $tbl_course_rel_user cru ON (cru.course_code = c.code) - INNER JOIN $tbl_course_rel_access_url a ON (a.course_code = c.code) + INNER JOIN $tbl_course_rel_user cru ON (cru.c_id = c.id) + INNER JOIN $tbl_course_rel_access_url a ON (a.c_id = c.id) $extraInnerJoin WHERE access_url_id = " . api_get_current_access_url_id() . " @@ -3601,7 +3594,7 @@ class CourseManager course_rel_user.user_id FROM $tbl_course course LEFT JOIN $tbl_course_user course_rel_user - ON course.code = course_rel_user.course_code AND course_rel_user.user_id = '$user_id' + ON course.id = course_rel_user.c_id AND course_rel_user.user_id = '$user_id' WHERE $with_special_courses group by course.code"; $rs_special_course = Database::query($sql); @@ -3720,8 +3713,10 @@ class CourseManager while ($row = Database::fetch_array($result)) { // We simply display the title of the category. $params = array( - 'icon' => Display::return_icon('folder_yellow.png', api_htmlentities($row['title']), array(), - ICON_SIZE_LARGE), + 'icon' => Display::return_icon( + 'folder_yellow.png', + api_htmlentities($row['title']), array(), ICON_SIZE_LARGE + ), 'title' => $row['title'], 'class' => 'table_user_course_category' ); @@ -3736,6 +3731,7 @@ class CourseManager // Step 2: We display the course without a user category. $courseInCategory = self:: display_courses_in_category(0, $load_dirs); + $html .= $courseInCategory['html']; $courseCount += $courseInCategory['course_count']; @@ -3783,16 +3779,16 @@ class CourseManager $TABLECOURSUSER course_rel_user, $TABLE_ACCESS_URL_REL_COURSE url WHERE - course.code = course_rel_user.course_code AND - url.course_code = course.code AND + course.id = course_rel_user.c_id AND + url.c_id = course.id AND course_rel_user.user_id = '" . $user_id . "' AND - course_rel_user.user_course_cat='" . $user_category_id . "' + course_rel_user.user_course_cat = '" . $user_category_id . "' $without_special_courses "; // If multiple URL access mode is enabled, only fetch courses // corresponding to the current URL. if (api_get_multiple_access_url() && $current_url_id != -1) { - $sql .= " AND url.course_code = course.code AND access_url_id='" . $current_url_id . "'"; + $sql .= " AND url.c_id = course.id AND access_url_id='" . $current_url_id . "'"; } // Use user's classification for courses (if any). $sql .= " ORDER BY course_rel_user.user_course_cat, course_rel_user.sort ASC"; @@ -4006,7 +4002,8 @@ class CourseManager ) { global $nosession; $user_id = api_get_user_id(); - $course_info = api_get_course_info($course['code']); + + $course_info = api_get_course_info_by_id($course['real_id']); $status_course = CourseManager::get_user_in_course_status($user_id, $course_info['code']); $course_info['status'] = empty($session_id) ? $status_course : STUDENT; $course_info['id_session'] = $session_id; @@ -4043,7 +4040,7 @@ class CourseManager $course_info['code'] ); - $is_coach = api_is_coach($course_info['id_session'], $course['code']); + $is_coach = api_is_coach($course_info['id_session'], $course_info['real_id']); // Display course entry. // Show a hyperlink to the course, unless the course is closed and user is not course admin. @@ -4072,7 +4069,7 @@ class CourseManager } $sessionCourseAvailable = false; - $sessionCourseStatus = api_get_session_visibility($session_id, $course_info['code']); + $sessionCourseStatus = api_get_session_visibility($session_id, $course_info['id']); if (in_array($sessionCourseStatus, array(SESSION_VISIBLE_READ_ONLY, SESSION_VISIBLE, SESSION_AVAILABLE))) { $sessionCourseAvailable = true; @@ -4138,7 +4135,7 @@ class CourseManager ); $course_coachs = CourseManager::get_coachs_from_course_to_string( $course_info['id_session'], - $course['code'], + $course_info['real_id'], self::USER_SEPARATOR, true ); @@ -4332,6 +4329,9 @@ class CourseManager $course_code = Database::escape_string($course_code); $session_id = intval($session_id); + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + // Course legal $enabled = api_get_plugin_setting('courselegal', 'tool_enable'); @@ -4344,7 +4344,7 @@ class CourseManager if (empty($session_id)) { $table = Database::get_main_table(TABLE_MAIN_COURSE_USER); $sql = "SELECT legal_agreement FROM $table - WHERE user_id = $user_id AND course_code ='$course_code' "; + WHERE user_id = $user_id AND c_id = '$courseId' "; $result = Database::query($sql); if (Database::num_rows($result) > 0) { $result = Database::fetch_array($result); @@ -4356,7 +4356,7 @@ class CourseManager } else { $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $sql = "SELECT legal_agreement FROM $table - WHERE id_user = $user_id AND course_code ='$course_code' AND id_session = $session_id"; + WHERE user_id = $user_id AND c_id ='$courseId' AND session_id = $session_id"; $result = Database::query($sql); if (Database::num_rows($result) > 0) { $result = Database::fetch_array($result); @@ -4390,15 +4390,18 @@ class CourseManager $course_code = Database::escape_string($course_code); $session_id = intval($session_id); + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + if (empty($session_id)) { $table = Database::get_main_table(TABLE_MAIN_COURSE_USER); $sql = "UPDATE $table SET legal_agreement = '1' - WHERE user_id = $user_id AND course_code ='$course_code' "; + WHERE user_id = $user_id AND c_id = '$courseId' "; Database::query($sql); } else { $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $sql = "UPDATE $table SET legal_agreement = '1' - WHERE id_user = $user_id AND course_code = '$course_code' AND id_session = $session_id"; + WHERE user_id = $user_id AND c_id = '$courseId' AND session_id = $session_id"; Database::query($sql); } } @@ -4722,8 +4725,11 @@ class CourseManager //$table_course_access table uses the now() and interval ... $now = api_get_utc_datetime(time()); $sql = "SELECT COUNT(course_access_id) course_count, a.c_id, visibility - FROM $table_course c INNER JOIN $table_course_access a - ON (c.id = a.c_id) INNER JOIN $table_course_url u ON u.course_code = c.code + FROM $table_course c + INNER JOIN $table_course_access a + ON (c.id = a.c_id) + INNER JOIN $table_course_url u + ON u.c_id = c.id WHERE u.access_url_id = " . api_get_current_access_url_id() . " AND login_course_date <= '$now' AND @@ -4826,34 +4832,6 @@ class CourseManager return $result; } - /** - * @deprecated seems not to be used - */ - static function list_inactive_courses($ceiling, $visibility_level = COURSE_VISIBILITY_REGISTERED) - { - $ceiling = is_numeric($ceiling) ? (int)$ceiling : strtotime($ceiling); - $ceiling = date('Y-m-d H:i:s', $ceiling); - $visibility_level = $visibility_level ? $visibility_level : '0'; - - $table_course = Database::get_main_table(TABLE_MAIN_COURSE); - $table_category = Database::get_main_table(TABLE_MAIN_CATEGORY); - $sql = "SELECT - c.*, - cat.name AS category - FROM - $table_course AS c - LEFT JOIN - $table_category AS cat - ON - c.category_code = cat.code - WHERE - c.visibility >= $visibility_level AND - c.last_visit<='$ceiling' - "; - - return ResultSet::create($sql); - } - /** * Get courses count * @param int Access URL ID (optional) @@ -4868,7 +4846,7 @@ class CourseManager $sql = "SELECT count(id) FROM $table_course c"; if (!empty($access_url_id) && $access_url_id == intval($access_url_id)) { $sql .= ", $table_course_rel_access_url u - WHERE c.code = u.course_code AND u.access_url_id = $access_url_id"; + WHERE c.id = u.c_id AND u.access_url_id = $access_url_id"; if (!empty($visibility)) { $visibility = intval($visibility); $sql .= " AND visibility = $visibility "; @@ -4900,7 +4878,7 @@ class CourseManager if (!empty($urlId) && $urlId == intval($urlId)) { $sql .= ", $table_course_rel_access_url u WHERE - c.code = u.course_code AND + c.id = u.c_id AND u.access_url_id = $urlId AND visibility <> " . COURSE_VISIBILITY_HIDDEN; } else { @@ -4938,9 +4916,9 @@ class CourseManager } } if (!empty($accessUrlId) && $accessUrlId == intval($accessUrlId)) { - $sql = "SELECT count(id) FROM $tableCourse c, $tableCourseRelAccessUrl u + $sql = "SELECT count(c.id) FROM $tableCourse c, $tableCourseRelAccessUrl u WHERE - c.code = u.course_code AND + c.id = u.c_id AND u.access_url_id = $accessUrlId AND c.visibility != 0 AND c.visibility != 4 @@ -5045,7 +5023,7 @@ class CourseManager if (!is_array($teachers)) { $teachers = array($teachers); } - + $courseId = intval($courseId); $courseInfo = api_get_course_info_by_id($courseId); $course_code = $courseInfo['code']; @@ -5064,7 +5042,7 @@ class CourseManager } $sql = 'DELETE FROM ' . $course_user_table . ' - WHERE course_code="' . Database::escape_string($course_code) . '" AND status="1"' . $cond; + WHERE c_id ="' . $courseId . '" AND status="1"' . $cond; Database::query($sql); } @@ -5073,18 +5051,17 @@ class CourseManager $userId = intval($userId); // We check if the teacher is already subscribed in this course $sql = 'SELECT 1 FROM ' . $course_user_table . ' - WHERE user_id = "' . $userId . '" AND course_code = "' . $course_code . '" '; + WHERE user_id = "' . $userId . '" AND c_id = "' . $courseId . '" '; $result = Database::query($sql); if (Database::num_rows($result)) { $sql = 'UPDATE ' . $course_user_table . ' SET status = "1" - WHERE course_code = "' . $course_code . '" AND user_id = "' . $userId . '" '; + WHERE c_id = "' . $courseId . '" AND user_id = "' . $userId . '" '; } else { $sql = "INSERT INTO " . $course_user_table . " SET - course_code = '" . Database::escape_string($course_code) . "', + c_id = '" . $courseId . "', user_id = '" . $userId . "', status = '1', - role = '', - tutor_id = '0', + is_tutor = '0', sort = '0', user_course_cat='0'"; } @@ -5093,14 +5070,14 @@ class CourseManager } if ($editTeacherInSessions) { - $sessions = SessionManager::get_session_by_course($course_code); + $sessions = SessionManager::get_session_by_course($courseId); if (!empty($sessions)) { foreach ($sessions as $session) { // Remove old and add new if ($deleteSessionTeacherNotInList) { foreach ($teachers as $userId) { - SessionManager::set_coach_to_course_session($userId, $session['id'], $course_code); + SessionManager::set_coach_to_course_session($userId, $session['id'], $courseId); } $teachersToDelete = array(); @@ -5110,14 +5087,14 @@ class CourseManager if (!empty($teachersToDelete)) { foreach ($teachersToDelete as $userId) { - SessionManager::set_coach_to_course_session($userId, $session['id'], $course_code, + SessionManager::set_coach_to_course_session($userId, $session['id'], $courseId, true); } } } else { // Add new teachers only foreach ($teachers as $userId) { - SessionManager::set_coach_to_course_session($userId, $session['id'], $course_code); + SessionManager::set_coach_to_course_session($userId, $session['id'], $courseId); } } } @@ -5531,20 +5508,25 @@ class CourseManager { $grouplist = array(); $userlist = array(); + foreach ($to as $to_item) { - list($type, $id) = explode(':', $to_item); - switch ($type) { - case 'GROUP': - $grouplist[] = intval($id); - break; - case 'USER': - $userlist[] = intval($id); - break; + if (!empty($to_item)) { + list($type, $id) = explode(':', $to_item); + + switch ($type) { + case 'GROUP': + $grouplist[] = intval($id); + break; + case 'USER': + $userlist[] = intval($id); + break; + } } } $send_to['groups'] = $grouplist; $send_to['users'] = $userlist; + return $send_to; } @@ -5636,7 +5618,7 @@ class CourseManager public static function get_course_list() { $table = Database::get_main_table(TABLE_MAIN_COURSE); - return Database::store_result(self::query("SELECT *, id as real_id FROM $table")); + return Database::store_result(Database::query("SELECT *, id as real_id FROM $table")); } /** @@ -5664,16 +5646,16 @@ class CourseManager public static function getCoursesWithoutSession($startDate = null, $endDate = null, $includeClosed = false) { $dateConditional = ($startDate && $endDate) ? - " WHERE id_session IN (SELECT id FROM " . Database::get_main_table(TABLE_MAIN_SESSION) . + " WHERE session_id IN (SELECT id FROM " . Database::get_main_table(TABLE_MAIN_SESSION) . " WHERE date_start = '$startDate' AND date_end = '$endDate')" : null; $visibility = ($includeClosed ? '' : 'visibility NOT IN (0, 4) AND '); - $query = "SELECT id, code, title FROM " . Database::get_main_table(TABLE_MAIN_COURSE) - . " WHERE $visibility - code NOT IN - (SELECT DISTINCT course_code FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE) . $dateConditional . ") - ORDER BY id"; + $query = "SELECT id, code, title + FROM " . Database::get_main_table(TABLE_MAIN_COURSE). " + WHERE $visibility code NOT IN ( + SELECT DISTINCT course_code FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE) . $dateConditional . ") + ORDER BY id"; $result = Database::query($query); $courses = array(); @@ -5701,28 +5683,28 @@ class CourseManager return []; } - $sql = "SELECT DISTINCT(c.id), c.title " - . "FROM $courseTable c " - . "INNER JOIN $courseUserTable cru ON c.code = cru.course_code " - . "WHERE ( " - . "cru.user_id IN(" . implode(', ', $userIdList) . ") " - . "AND cru.relation_type = 0 " - . ")"; + $sql = "SELECT DISTINCT(c.id), c.title + FROM $courseTable c + INNER JOIN $courseUserTable cru ON c.id = cru.c_id + WHERE ( + cru.user_id IN (" . implode(', ', $userIdList) . ") + AND cru.relation_type = 0 + )"; if (api_is_multiple_url_enabled()) { $courseAccessUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $accessUrlId = api_get_current_access_url_id(); if ($accessUrlId != -1) { - $sql = "SELECT DISTINCT(c.id), c.title " - . "FROM $courseTable c " - . "INNER JOIN $courseUserTable cru ON c.code = cru.course_code " - . "INNER JOIN $courseAccessUrlTable crau ON c.code = crau.course_code " - . "WHERE crau.access_url_id = $accessUrlId " - . "AND ( " - . "cru.id_user IN (" . implode(', ', $userIdList) . ") " - . "AND cru.relation_type = 0 " - . ")"; + $sql = "SELECT DISTINCT(c.id), c.title + FROM $courseTable c + INNER JOIN $courseUserTable cru ON c.id = cru.c_id + INNER JOIN $courseAccessUrlTable crau ON c.id = crau.c_id + WHERE crau.access_url_id = $accessUrlId + AND ( + cru.id_user IN (" . implode(', ', $userIdList) . ") AND + cru.relation_type = 0 + )"; } } diff --git a/main/inc/lib/course_category.lib.php b/main/inc/lib/course_category.lib.php index ac85d1680b..29c567fc91 100755 --- a/main/inc/lib/course_category.lib.php +++ b/main/inc/lib/course_category.lib.php @@ -597,7 +597,7 @@ function countCoursesInCategory($category_code="", $searchTerm = '') $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $sql = "SELECT * FROM $tbl_course as course INNER JOIN $tbl_url_rel_course as url_rel_course - ON (url_rel_course.course_code=course.code) + ON (url_rel_course.c_id = course.id) WHERE access_url_id = $url_access_id AND course.visibility != '0' AND @@ -666,21 +666,26 @@ function browseCoursesInCategory($category_code, $random_value = null, $limit = $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $sql = "SELECT COUNT(*) FROM $tbl_course course - INNER JOIN $tbl_url_rel_course as url_rel_course ON (url_rel_course.course_code=course.code) + INNER JOIN $tbl_url_rel_course as url_rel_course + ON (url_rel_course.c_id = course.id) WHERE access_url_id = $url_access_id "; $result = Database::query($sql); list($num_records) = Database::fetch_row($result); - $sql = "SELECT course.id FROM $tbl_course course INNER JOIN $tbl_url_rel_course as url_rel_course - ON (url_rel_course.course_code=course.code) - WHERE access_url_id = $url_access_id AND - RAND()*$num_records< $random_value - $without_special_courses $visibilityCondition - ORDER BY RAND() LIMIT 0, $random_value"; + $sql = "SELECT course.id FROM $tbl_course course + INNER JOIN $tbl_url_rel_course as url_rel_course + ON (url_rel_course.c_id = course.id) + WHERE + access_url_id = $url_access_id AND + RAND()*$num_records< $random_value + $without_special_courses $visibilityCondition + ORDER BY RAND() + LIMIT 0, $random_value"; } else { $sql = "SELECT id FROM $tbl_course course WHERE RAND()*$num_records< $random_value $without_special_courses $visibilityCondition - ORDER BY RAND() LIMIT 0, $random_value"; + ORDER BY RAND() + LIMIT 0, $random_value"; } $result = Database::query($sql); @@ -716,15 +721,15 @@ function browseCoursesInCategory($category_code, $random_value = null, $limit = if ($category_code != "ALL") { $sql = "SELECT * FROM $tbl_course as course INNER JOIN $tbl_url_rel_course as url_rel_course - ON (url_rel_course.course_code=course.code) + ON (url_rel_course.c_id = course.id) WHERE access_url_id = $url_access_id AND category_code='$category_code' $without_special_courses $visibilityCondition ORDER BY title $limitFilter"; } else { $sql = "SELECT * FROM $tbl_course as course - INNER JOIN $tbl_url_rel_course as url_rel_course - ON (url_rel_course.course_code=course.code) - WHERE access_url_id = $url_access_id $without_special_courses $visibilityCondition - ORDER BY title $limitFilter"; + INNER JOIN $tbl_url_rel_course as url_rel_course + ON (url_rel_course.c_id = course.id) + WHERE access_url_id = $url_access_id $without_special_courses $visibilityCondition + ORDER BY title $limitFilter"; } } diff --git a/main/inc/lib/course_description.lib.php b/main/inc/lib/course_description.lib.php index 7b77fc5bb5..95c6178b66 100755 --- a/main/inc/lib/course_description.lib.php +++ b/main/inc/lib/course_description.lib.php @@ -31,12 +31,14 @@ class CourseDescription } /** - * Returns an array of objects of type CourseDescription corresponding to a specific course, without session ids (session id = 0) + * Returns an array of objects of type CourseDescription corresponding to + * a specific course, without session ids (session id = 0) * * @param int Course id * @return array Array of CourseDescriptions */ - public static function get_descriptions($course_id) { + public static function get_descriptions($course_id) + { // Get course code $course_info = api_get_course_info_by_id($course_id); if (!empty($course_info)) { @@ -45,7 +47,8 @@ class CourseDescription return array(); } $t_course_desc = Database::get_course_table(TABLE_COURSE_DESCRIPTION); - $sql = "SELECT * FROM $t_course_desc WHERE c_id = $course_id AND session_id = '0';"; + $sql = "SELECT * FROM $t_course_desc + WHERE c_id = $course_id AND session_id = '0'"; $sql_result = Database::query($sql); $results = array(); while($row = Database::fetch_array($sql_result)) { @@ -72,7 +75,9 @@ class CourseDescription $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION); $condition_session = api_get_session_condition($this->session_id, true, true); $course_id = api_get_course_int_id(); - $sql = "SELECT * FROM $tbl_course_description WHERE c_id = $course_id $condition_session ORDER BY id "; + $sql = "SELECT * FROM $tbl_course_description + WHERE c_id = $course_id $condition_session + ORDER BY id "; $rs = Database::query($sql); $data = array(); while ($description = Database::fetch_array($rs)) { @@ -86,9 +91,11 @@ class CourseDescription /** * Get all data of course description by session id, * first you must set session_id property with the object CourseDescription + * @deprecated * @return array */ - public function get_description_history($description_type) { + public function get_description_history($description_type) + { $tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY); $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); @@ -119,7 +126,8 @@ class CourseDescription * @param int session id (optional) * @return array */ - public function get_data_by_description_type($description_type, $course_code = '', $session_id = null) { + public function get_data_by_description_type($description_type, $course_code = '', $session_id = null) + { $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION); $course_id = api_get_course_int_id(); @@ -132,7 +140,8 @@ class CourseDescription $course_id = $course_info['real_id']; } $description_type = intval($description_type); - $sql = "SELECT * FROM $tbl_course_description WHERE c_id = $course_id AND description_type='$description_type' $condition_session "; + $sql = "SELECT * FROM $tbl_course_description + WHERE c_id = $course_id AND description_type='$description_type' $condition_session "; $rs = Database::query($sql); $data = array(); if ($description = Database::fetch_array($rs)) { @@ -143,7 +152,14 @@ class CourseDescription return $data; } - public function get_data_by_id($id, $course_code = '', $session_id = null) { + /** + * @param int $id + * @param string $course_code + * @param int $session_id + * @return array + */ + public function get_data_by_id($id, $course_code = '', $session_id = null) + { $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION); $course_id = api_get_course_int_id(); @@ -156,7 +172,8 @@ class CourseDescription $course_id = $course_info['real_id']; } $id = intval($id); - $sql = "SELECT * FROM $tbl_course_description WHERE c_id = $course_id AND id='$id' $condition_session "; + $sql = "SELECT * FROM $tbl_course_description + WHERE c_id = $course_id AND id='$id' $condition_session "; $rs = Database::query($sql); $data = array(); if ($description = Database::fetch_array($rs)) { @@ -165,19 +182,23 @@ class CourseDescription $data['description_content'] = $description['content']; $data['progress'] = $description['progress']; } + return $data; } /** - * Get maximum description type by session id, first you must set session_id properties with the object CourseDescription + * Get maximum description type by session id, + * first you must set session_id properties with the object CourseDescription * @return int maximum description time adding one */ - public function get_max_description_type() { + public function get_max_description_type() + { $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION); $course_id = api_get_course_int_id(); - $sql = "SELECT MAX(description_type) as MAX FROM $tbl_course_description WHERE c_id = $course_id AND session_id='".$this->session_id."'"; + $sql = "SELECT MAX(description_type) as MAX FROM $tbl_course_description + WHERE c_id = $course_id AND session_id='".$this->session_id."'"; $rs = Database::query($sql); $max = Database::fetch_array($rs); $description_type = $max['MAX']+1; @@ -189,7 +210,8 @@ class CourseDescription /** * Insert a description to the course_description table, - * first you must set description_type, title, content, progress and session_id properties with the object CourseDescription + * first you must set description_type, title, content, progress and + * session_id properties with the object CourseDescription * @return int affected rows */ public function insert() @@ -211,16 +233,26 @@ class CourseDescription $last_id = Database::insert_id(); $affected_rows = Database::affected_rows($result); if ($last_id > 0) { + $sql = "UPDATE $tbl_course_description SET id = iid WHERE iid = $last_id"; + Database::query($sql); + //insert into item_property - api_item_property_update(api_get_course_info(), TOOL_COURSE_DESCRIPTION, $last_id, 'CourseDescriptionAdded', api_get_user_id()); + api_item_property_update( + api_get_course_info(), + TOOL_COURSE_DESCRIPTION, + $last_id, + 'CourseDescriptionAdded', + api_get_user_id() + ); } - return $affected_rows; + return $affected_rows; } /** * Insert a row like history inside track_e_item_property table - * first you must set description_type, title, content, progress and session_id properties with the object CourseDescription + * first you must set description_type, title, content, progress and + * session_id properties with the object CourseDescription * @param int description type * @return int affected rows */ @@ -243,6 +275,10 @@ class CourseDescription session_id = '".intval($this->session_id)."'"; $result = Database::query($sql); $affected_rows = Database::affected_rows($result); + + $sql = "UPDATE $tbl_course_description SET id = iid WHERE iid = $last_id"; + Database::query($sql); + return $affected_rows; } @@ -255,25 +291,32 @@ class CourseDescription { $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION); $sql = "UPDATE $tbl_course_description SET - title = '".Database::escape_string($this->title)."', - content = '".Database::escape_string($this->content)."', - progress = '".$this->progress."' - WHERE id = '".intval($this->id)."' AND - session_id = '".$this->session_id."' AND - c_id = ".api_get_course_int_id()." - "; + title = '".Database::escape_string($this->title)."', + content = '".Database::escape_string($this->content)."', + progress = '".$this->progress."' + WHERE + id = '".intval($this->id)."' AND + session_id = '".$this->session_id."' AND + c_id = ".api_get_course_int_id(); $result = Database::query($sql); $affected_rows = Database::affected_rows($result); if ($this->id > 0) { //insert into item_property - api_item_property_update(api_get_course_info(), TOOL_COURSE_DESCRIPTION, $this->id, 'CourseDescriptionUpdated', api_get_user_id()); + api_item_property_update( + api_get_course_info(), + TOOL_COURSE_DESCRIPTION, + $this->id, + 'CourseDescriptionUpdated', + api_get_user_id() + ); } return $affected_rows; } /** - * Delete a description, first you must set description_type and session_id properties with the object CourseDescription + * Delete a description, first you must set description_type and session_id + * properties with the object CourseDescription * @return int affected rows */ public function delete() @@ -281,13 +324,23 @@ class CourseDescription $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION); $course_id = api_get_course_int_id(); $sql = "DELETE FROM $tbl_course_description - WHERE c_id = $course_id AND id = '".intval($this->id)."' AND session_id = '".intval($this->session_id)."'"; + WHERE + c_id = $course_id AND + id = '".intval($this->id)."' AND + session_id = '".intval($this->session_id)."'"; $result = Database::query($sql); $affected_rows = Database::affected_rows($result); if ($this->id > 0) { //insert into item_property - api_item_property_update(api_get_course_info(), TOOL_COURSE_DESCRIPTION, $this->id, 'CourseDescriptionDeleted', api_get_user_id()); + api_item_property_update( + api_get_course_info(), + TOOL_COURSE_DESCRIPTION, + $this->id, + 'CourseDescriptionDeleted', + api_get_user_id() + ); } + return $affected_rows; } @@ -301,7 +354,8 @@ class CourseDescription $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION); $course_id = api_get_course_int_id(); - $sql = "SELECT id FROM $tbl_course_description WHERE c_id = $course_id AND description_type = '".intval($description_type)."'"; + $sql = "SELECT id FROM $tbl_course_description + WHERE c_id = $course_id AND description_type = '".intval($description_type)."'"; $rs = Database::query($sql); $row = Database::fetch_array($rs); $description_id = $row['id']; @@ -315,12 +369,17 @@ class CourseDescription * @param int Description type (optional) * @return string img html */ - public function get_progress_porcent($with_icon = false, $description_type = THEMATIC_ADVANCE) { + public function get_progress_porcent($with_icon = false, $description_type = THEMATIC_ADVANCE) + { $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION); $session_id = intval($session_id); $course_id = api_get_course_int_id(); - $sql = "SELECT progress FROM $tbl_course_description WHERE c_id = $course_id AND description_type = '".intval($description_type)."' AND session_id = '".intval($this->session_id)."' "; + $sql = "SELECT progress FROM $tbl_course_description + WHERE + c_id = $course_id AND + description_type = '".intval($description_type)."' AND + session_id = '".intval($this->session_id)."' "; $rs = Database::query($sql); $progress = ''; $img = ''; @@ -361,7 +420,8 @@ class CourseDescription * Get description titles editable by default * @return array */ - public function get_default_description_title_editable() { + public function get_default_description_title_editable() + { $default_description_title_editable = array(); $default_description_title_editable[1] = true; $default_description_title_editable[2] = true; @@ -378,7 +438,8 @@ class CourseDescription * Get description icons by default * @return array */ - public function get_default_description_icon() { + public function get_default_description_icon() + { $default_description_icon = array(); $default_description_icon[1]= 'info.png'; $default_description_icon[2]= 'objective.png'; @@ -396,7 +457,8 @@ class CourseDescription * Get questions by default for help * @return array */ - public function get_default_question() { + public function get_default_question() + { $question = array(); $question[1]= get_lang('GeneralDescriptionQuestions'); $question[2]= get_lang('ObjectivesQuestions'); @@ -413,7 +475,8 @@ class CourseDescription * Get informations by default for help * @return array */ - public function get_default_information() { + public function get_default_information() + { $information = array(); $information[1]= get_lang('GeneralDescriptionInformation'); $information[2]= get_lang('ObjectivesInformation'); @@ -430,7 +493,8 @@ class CourseDescription * Set description id * @return void */ - public function set_id($id) { + public function set_id($id) + { $this->id = $id; } @@ -439,7 +503,8 @@ class CourseDescription * @param int Course ID * @return void */ - public function set_course_id($id) { + public function set_course_id($id) + { $this->course_id = intval($id); } @@ -447,7 +512,8 @@ class CourseDescription * Set description title * @return void */ - public function set_title($title) { + public function set_title($title) + { $this->title = $title; } @@ -455,7 +521,8 @@ class CourseDescription * Set description content * @return void */ - public function set_content($content) { + public function set_content($content) + { $this->content = $content; } @@ -463,7 +530,8 @@ class CourseDescription * Set description session id * @return void */ - public function set_session_id($session_id) { + public function set_session_id($session_id) + { $this->session_id = $session_id; } @@ -471,7 +539,8 @@ class CourseDescription * Set description type * @return void */ - public function set_description_type($description_type) { + public function set_description_type($description_type) + { $this->description_type = $description_type; } @@ -479,7 +548,8 @@ class CourseDescription * Set progress of a description * @return void */ - public function set_progress($progress) { + public function set_progress($progress) + { $this->progress = $progress; } @@ -487,7 +557,8 @@ class CourseDescription * get description id * @return int */ - public function get_id() { + public function get_id() + { return $this->id; } @@ -495,7 +566,8 @@ class CourseDescription * get description title * @return string */ - public function get_title() { + public function get_title() + { return $this->title; } @@ -503,7 +575,8 @@ class CourseDescription * get description content * @return string */ - public function get_content() { + public function get_content() + { return $this->content; } @@ -511,7 +584,8 @@ class CourseDescription * get session id * @return int */ - public function get_session_id() { + public function get_session_id() + { return $this->session_id; } @@ -519,7 +593,8 @@ class CourseDescription * get description type * @return int */ - public function get_description_type() { + public function get_description_type() + { return $this->description_type; } @@ -527,7 +602,8 @@ class CourseDescription * get progress of a description * @return int */ - public function get_progress() { + public function get_progress() + { return $this->progress; } } diff --git a/main/inc/lib/course_entity.class.php b/main/inc/lib/course_entity.class.php deleted file mode 100755 index b453bc7890..0000000000 --- a/main/inc/lib/course_entity.class.php +++ /dev/null @@ -1,21 +0,0 @@ - for the Univesity of Geneva - */ -class CourseEntity extends Entity -{ - - public function __construct() - { - $current_course = self::current_course(); - if ($current_course) { - $this->defaults('c_id', self::current_course()->get_id()); - } - $this->defaults('session_id', api_get_session_id()); - } - -} \ No newline at end of file diff --git a/main/inc/lib/course_entity_repository.class.php b/main/inc/lib/course_entity_repository.class.php deleted file mode 100755 index d06c8c040d..0000000000 --- a/main/inc/lib/course_entity_repository.class.php +++ /dev/null @@ -1,17 +0,0 @@ - for the Univesity of Geneva - */ -class CourseEntityRepository extends EntityRepository -{ - //put your code here -} \ No newline at end of file diff --git a/main/inc/lib/course_home.lib.php b/main/inc/lib/course_home.lib.php index 1abaffc23c..fb2481f6c3 100755 --- a/main/inc/lib/course_home.lib.php +++ b/main/inc/lib/course_home.lib.php @@ -443,46 +443,47 @@ class CourseHome // Condition for the session $session_id = api_get_session_id(); $course_id = api_get_course_int_id(); - $condition_session = api_get_session_condition($session_id, true, true); + $condition_session = api_get_session_condition($session_id, true, true, 't.session_id'); switch ($course_tool_category) { case TOOL_STUDENT_VIEW: - $condition_display_tools = ' WHERE visibility = 1 AND (category = "authoring" OR category = "interaction" OR category = "plugin") '; + $conditions = ' WHERE visibility = 1 AND (category = "authoring" OR category = "interaction" OR category = "plugin") '; if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') { - $condition_display_tools = ' WHERE (visibility = 1 AND (category = "authoring" OR category = "interaction" OR category = "plugin") OR (name = "'.TOOL_TRACKING.'") ) '; + $conditions = ' WHERE (visibility = 1 AND (category = "authoring" OR category = "interaction" OR category = "plugin") OR (name = "'.TOOL_TRACKING.'") ) '; } $sql = "SELECT * - FROM $course_tool_table - $condition_display_tools AND + FROM $course_tool_table t + $conditions AND c_id = $course_id $condition_session ORDER BY id"; $result = Database::query($sql); break; case TOOL_AUTHORING: - $sql = "SELECT * FROM $course_tool_table + $sql = "SELECT * FROM $course_tool_table t WHERE category = 'authoring' AND c_id = $course_id $condition_session ORDER BY id"; $result = Database::query($sql); break; case TOOL_INTERACTION: - $sql = "SELECT * FROM $course_tool_table + $sql = "SELECT * FROM $course_tool_table t WHERE category = 'interaction' AND c_id = $course_id $condition_session ORDER BY id"; $result = Database::query($sql); break; case TOOL_ADMIN_VISIBLE: - $sql = "SELECT * FROM $course_tool_table + $sql = "SELECT * FROM $course_tool_table t WHERE category = 'admin' AND visibility ='1' AND c_id = $course_id $condition_session ORDER BY id"; $result = Database::query($sql); break; case TOOL_ADMIN_PLATFORM: - $sql = "SELECT * FROM $course_tool_table - WHERE category = 'admin' AND c_id = $course_id $condition_session ORDER BY id"; + $sql = "SELECT * FROM $course_tool_table t + WHERE category = 'admin' AND c_id = $course_id $condition_session + ORDER BY id"; $result = Database::query($sql); break; case TOOL_DRH: - $sql = "SELECT * FROM $course_tool_table + $sql = "SELECT * FROM $course_tool_table t WHERE name IN ('tracking') AND c_id = $course_id $condition_session ORDER BY id"; $result = Database::query($sql); @@ -490,7 +491,7 @@ class CourseHome case TOOL_COURSE_PLUGIN: //Other queries recover id, name, link, image, visibility, admin, address, added_tool, target, category and session_id // but plugins are not present in the tool table, only globally and inside the course_settings table once configured - $sql = "SELECT * FROM $course_tool_table + $sql = "SELECT * FROM $course_tool_table t WHERE category = 'plugin' AND c_id = $course_id $condition_session ORDER BY id"; $result = Database::query($sql); @@ -553,6 +554,8 @@ class CourseHome $course_link_table = Database::get_course_table(TABLE_LINK); $course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY); + $condition_session = api_get_session_condition($session_id, true, true, 'tip.session_id'); + switch ($course_tool_category) { case TOOL_AUTHORING: $sql_links = "SELECT tl.*, tip.visibility @@ -576,7 +579,8 @@ class CourseHome case TOOL_STUDENT_VIEW: $sql_links = "SELECT tl.*, tip.visibility FROM $course_link_table tl - LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id + LEFT JOIN $course_item_property_table tip + ON tip.tool='link' AND tip.ref=tl.id WHERE tl.c_id = $course_id AND tip.c_id = $course_id AND @@ -585,7 +589,8 @@ class CourseHome case TOOL_ADMIN: $sql_links = "SELECT tl.*, tip.visibility FROM $course_link_table tl - LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id + LEFT JOIN $course_item_property_table tip + ON tip.tool='link' AND tip.ref=tl.id WHERE tl.c_id = $course_id AND tip.c_id = $course_id AND diff --git a/main/inc/lib/course_request.lib.php b/main/inc/lib/course_request.lib.php index 573e6c9518..282b954325 100755 --- a/main/inc/lib/course_request.lib.php +++ b/main/inc/lib/course_request.lib.php @@ -59,7 +59,6 @@ class CourseRequestManager $user_id, $exemplary_content ) { - global $_configuration; $wanted_code = trim($wanted_code); $user_id = (int)$user_id; $exemplary_content = (bool)$exemplary_content ? 1 : 0; @@ -95,7 +94,8 @@ class CourseRequestManager $db_name = isset($keys['currentCourseDbName']) ? $keys['currentCourseDbName'] : null; $directory = $keys['currentCourseRepository']; - $sql = sprintf('INSERT INTO %s ( + $sql = sprintf( + 'INSERT INTO %s ( code, user_id, directory, db_name, course_language, title, description, category_code, tutor_name, visual_code, request_date, @@ -104,23 +104,37 @@ class CourseRequestManager "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", - "%s", "%s", "%s", "%s", "%s");', Database::get_main_table(TABLE_MAIN_COURSE_REQUEST), - Database::escape_string($code), Database::escape_string($user_id), Database::escape_string($directory), Database::escape_string($db_name), - Database::escape_string($course_language), Database::escape_string($title), Database::escape_string($description), Database::escape_string($category_code), - Database::escape_string($tutor_name), Database::escape_string($visual_code), Database::escape_string($request_date), - Database::escape_string($objetives), Database::escape_string($target_audience), Database::escape_string($status), Database::escape_string($info), Database::escape_string($exemplary_content)); + "%s", "%s", "%s", "%s", "%s");', + Database::get_main_table(TABLE_MAIN_COURSE_REQUEST), + Database::escape_string($code), + Database::escape_string($user_id), + Database::escape_string($directory), + Database::escape_string($db_name), + Database::escape_string($course_language), + Database::escape_string($title), + Database::escape_string($description), + Database::escape_string($category_code), + Database::escape_string($tutor_name), + Database::escape_string($visual_code), + Database::escape_string($request_date), + Database::escape_string($objetives), + Database::escape_string($target_audience), + Database::escape_string($status), + Database::escape_string($info), + Database::escape_string($exemplary_content) + ); + $result_sql = Database::query($sql); if (!$result_sql) { return false; } + $last_insert_id = Database::insert_id(); // E-mail notifications. // E-mail language: The platform language seems to be the best choice. - //$email_language = $course_language; - //$email_language = api_get_interface_language(); $email_language = api_get_setting('platformLanguage'); $email_subject = sprintf(get_lang('CourseRequestEmailSubject', null, $email_language), '['.api_get_setting('siteName').']', $code); @@ -146,13 +160,12 @@ class CourseRequestManager $sender_name_teacher = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS); $sender_email_teacher = $user_info['mail']; $recipient_name_admin = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); - $recipient_email_admin = get_setting('emailAdministrator'); + $recipient_email_admin = api_get_setting('emailAdministrator'); $userInfo = api_get_user_info($user_id); - $plugin = new AppPlugin(); - $className = $plugin->getSMSPluginName(); + $additionalParameters = array( - 'smsType' => constant($className.'::NEW_COURSE_SUGGESTED_TEACHER'), + 'smsType' => SmsPlugin::NEW_COURSE_SUGGESTED_TEACHER, 'userId' => $user_id, 'userUsername' => $userInfo['username'] ); @@ -189,7 +202,7 @@ class CourseRequestManager $recipient_email_teacher = $sender_email_teacher; $additionalParameters = array( - 'smsType' => constant($className.'::COURSE_OPENING_REQUEST_CODE_REGISTERED'), + 'smsType' => SmsPlugin::COURSE_OPENING_REQUEST_CODE_REGISTERED, 'userId' => $user_info['user_id'], 'courseCode' => $wanted_code ); @@ -464,14 +477,13 @@ class CourseRequestManager $email_body .= "\n".get_lang('CourseRequestLegalNote', null, $email_language)."\n"; $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); - $sender_email = get_setting('emailAdministrator'); + $sender_email = api_get_setting('emailAdministrator'); $recipient_name = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS); $recipient_email = $user_info['mail']; $extra_headers = 'Bcc: '.$sender_email; - $plugin = new AppPlugin(); $additionalParameters = array( - 'smsType' => constant($plugin->getSMSPluginName().'::COURSE_OPENING_REQUEST_CODE_APPROVED'), + 'smsType' => SmsPlugin::COURSE_OPENING_REQUEST_CODE_APPROVED, 'userId' => $user_id, 'courseCode' => $course_info['code'] ); @@ -543,14 +555,13 @@ class CourseRequestManager $email_body .= "\n".get_lang('CourseRequestLegalNote', null, $email_language)."\n"; $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); - $sender_email = get_setting('emailAdministrator'); + $sender_email = api_get_setting('emailAdministrator'); $recipient_name = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS); $recipient_email = $user_info['mail']; $extra_headers = 'Bcc: '.$sender_email; - $plugin = new AppPlugin(); $additionalParameters = array( - 'smsType' => constant($plugin->getSMSPluginName().'::COURSE_OPENING_REQUEST_CODE_REJECTED'), + 'smsType' => SmsPlugin::COURSE_OPENING_REQUEST_CODE_REJECTED, 'userId' => $user_id, 'courseCode' => $code ); @@ -621,14 +632,13 @@ class CourseRequestManager $email_body .= "\n".get_lang('CourseRequestLegalNote', null, $email_language)."\n"; $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); - $sender_email = get_setting('emailAdministrator'); + $sender_email = api_get_setting('emailAdministrator'); $recipient_name = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS); $recipient_email = $user_info['mail']; $extra_headers = 'Bcc: '.$sender_email; - $plugin = new AppPlugin(); $additionalParameters = array( - 'smsType' => constant($plugin->getSMSPluginName().'::COURSE_OPENING_REQUEST_CODE'), + 'smsType' => SmsPlugin::COURSE_OPENING_REQUEST_CODE, 'userId' => $user_id, 'courseCode' => $code ); diff --git a/main/inc/lib/current_course.class.php b/main/inc/lib/current_course.class.php deleted file mode 100755 index 1ea55ec0f7..0000000000 --- a/main/inc/lib/current_course.class.php +++ /dev/null @@ -1,167 +0,0 @@ - for the Univesity of Geneva - */ -class CurrentCourse -{ - - /** - * - * @return CurrentCourse - */ - public static function instance() - { - static $result = null; - if (empty($result)) { - $result = new self(); - } - return $result; - } - - protected function __construct() - { - ; - } - - public function is_empty() - { - $id = $this->real_id(); - return empty($id); - } - - public function data() - { - global $_course; - if ($_course == '-1') { - $_course = array(); - } - return $_course; - } - - public function real_id() - { - return (int)$this->get('real_id'); - } - - public function code() - { - return $this->get('code'); - } - - public function name() - { - return $this->get('name'); - } - - public function title() - { - return $this->get('title'); - } - - public function official_code() - { - return $this->get('official_code'); - } - - public function sys_code() - { - return $this->get('sysCode'); - } - - public function path() - { - return $this->get('path'); - } - - /** - * not needed in Chamilo 1.9 - * - * @return type - */ - public function db_name() - { - return $this->get('dbName'); - } - - public function db_name_glu() - { - return $this->get('dbNameGlu'); - } - - public function titular() - { - return $this->get('titular'); - } - - public function language() - { - return $this->get('language'); - } - - public function category_code() - { - return $this->get('categoryCode'); - } - - public function category_ame() - { - return $this->get('category_name'); - } - - public function visibility() - { - return $this->get('visibility'); - } - - public function subscribe_allowed() - { - return $this->get('subscribe_allowed'); - } - - public function unsubscribe_allowed() - { - return $this->get('unsubscribe'); - } - - public function activate_legal() - { - return $this->get('activate_legal'); - } - - public function show_score() - { - return $this->get('show_score'); - } - - public function extrnal_link() - { - return $this->get('extLink'); - } - - /** - * Returns the current user (logged in user) relationship with the course. - * I.e his role - * - * @return array - */ - public function user() - { - $result = Session::read('_courseUser'); - $result = $result ? $result : array(); - return $result; - } - - public function get($name, $default = false) - { - $data = $this->data(); - return isset($data[$name]) ? $data[$name] : $default; - } - -} \ No newline at end of file diff --git a/main/inc/lib/current_user.class.php b/main/inc/lib/current_user.class.php deleted file mode 100755 index b66188047a..0000000000 --- a/main/inc/lib/current_user.class.php +++ /dev/null @@ -1,185 +0,0 @@ - for the Univesity of Geneva - */ -class CurrentUser -{ - - /** - * - * @return CurrentUser - */ - public static function instance() - { - static $result = null; - if (empty($result)) { - $result = new self(); - } - return $result; - } - - protected function __construct() - { - ; - } - - public function data() - { - global $_user; - return $_user; - //return Session::read('_user'); - } - - public function is_anonymous() - { - return api_is_anonymous(); - } - - public function first_name() - { - return $this->get('firstName'); - } - - public function last_name() - { - return $this->get('lastName'); - } - - public function email() - { - return $this->get('mail'); - } - - public function last_login() - { - return $this->get('lastLogin'); - } - - public function official_code() - { - return $this->get('official_code'); - } - - public function picture_uri() - { - return $this->get('picture_uri'); - } - - public function user_id() - { - return (int) $this->get('user_id'); - } - - public function language() - { - return $this->get('language'); - } - - public function auth_source() - { - return $this->get('auth_source'); - } - - public function theme() - { - return $this->get('theme'); - } - - /** - * Returns true if user is a platform administrator, false otherwise. - * - * @return boolean - * @see UserManager::is_admin(user_id) for user-id specific function. - */ - public function is_platform_admin() - { - return (bool) Session::read('is_platformAdmin', false); - } - - /** - * Returns true if user is a session administrator, false otherwise. - * - * @return boolean - */ - public function is_session_admin($allow_sessions_admins = false) - { - global $_user; - return (bool) $_user['status'] == SESSIONADMIN; - } - - /** - * Returns true if the current user is allowed to create courses, false otherwise. - * - * @return boolean - * false otherwise. - */ - public function is_allowed_to_create_course() - { - return (bool) Session::read('is_allowedCreateCourse', false); - } - - /** - * Returns true if the current user is a course administrator for the current course, false otherwise. - * - * @return boolean - */ - public function is_course_admin() - { - return (bool) Session::read('is_courseAdmin', false); - } - - /** - * Returns true if the current user is a course member of the current course, false otherwise. - * - * @return bool - */ - public function is_course_member() - { - return (bool) Session::read('is_courseMember', false); - } - - /** - * Returns true if the current user is allowed in the current course, false otherwise. - * - * @return bool - */ - public function is_allowed_in_course() - { - return (bool) Session::read('is_allowed_in_course', false); - } - - /** - * Returns true if the current user is a course coach for the current course, false otherwise. - * - * @return bool - */ - public function is_course_coach() - { - return (bool) Session::read('is_courseCoach', false); - } - - /** - * Returns true if the current user is a course tutor for the current course, false otherwise. - * - * @return bool - */ - public function is_course_tutor() - { - return (bool) Session::read('is_courseTutor', false); - } - - public function get($name, $default = false) - { - $data = $this->data(); - return isset($data[$name]) ? $data[$name] : $default; - } - -} \ No newline at end of file diff --git a/main/inc/lib/database.constants.inc.php b/main/inc/lib/database.constants.inc.php index d95d59fb9a..60acd4213d 100755 --- a/main/inc/lib/database.constants.inc.php +++ b/main/inc/lib/database.constants.inc.php @@ -2,7 +2,7 @@ /* For licensing terms, see /license.txt */ /** * This is the database constants definition for Chamilo - * This file is called by database.lib.php and database.mysqli.lib.php + * This file is called by database.lib.php * * @todo the table constants have all to start with TABLE_ * This is because of the analogy with the tool constants TOOL_ @@ -21,7 +21,7 @@ define('DB_COURSE_PREFIX', 'c_'); // Main database tables define('TABLE_MAIN_COURSE', 'course'); define('TABLE_MAIN_USER', 'user'); -define('TABLE_MAIN_CLASS', 'class'); +define('TABLE_MAIN_CLASS', 'class_item'); define('TABLE_MAIN_ADMIN', 'admin'); define('TABLE_MAIN_COURSE_CLASS', 'course_rel_class'); define('TABLE_MAIN_COURSE_USER', 'course_rel_user'); @@ -91,6 +91,7 @@ define('TABLE_MAIN_ACCESS_URL_REL_USER', 'access_url_rel_user'); define('TABLE_MAIN_ACCESS_URL_REL_COURSE', 'access_url_rel_course'); define('TABLE_MAIN_ACCESS_URL_REL_SESSION', 'access_url_rel_session'); define('TABLE_MAIN_ACCESS_URL_REL_USERGROUP', 'access_url_rel_usergroup'); +// This table seems not to be use define('TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY', 'access_url_rel_course_category'); // Global calendar @@ -110,7 +111,7 @@ define('TABLE_MAIN_USER_FRIEND_RELATION_TYPE', 'user_friend_relation_type'); // Web services define('TABLE_MAIN_USER_API_KEY', 'user_api_key'); define('TABLE_MAIN_COURSE_FIELD', 'course_field'); -define('TABLE_MAIN_COURSE_FIELD_OPTIONS', 'course_field_options'); +define('TABLE_MAIN_COURSE_FIELD_OPTIONS', 'course_field_options'); define('TABLE_MAIN_COURSE_FIELD_VALUES', 'course_field_values'); define('TABLE_MAIN_SESSION_FIELD', 'session_field'); define('TABLE_MAIN_SESSION_FIELD_OPTIONS', 'session_field_options'); @@ -138,14 +139,7 @@ define('TABLE_STATISTIC_TRACK_E_DEFAULT', 'track_e_default'); define('TABLE_STATISTIC_TRACK_E_UPLOADS', 'track_e_uploads'); define('TABLE_STATISTIC_TRACK_E_HOTSPOT', 'track_e_hotspot'); define('TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY', 'track_e_item_property'); -define('TABLE_STATISTIC_TRACK_E_OPEN', 'track_e_open'); - define('TABLE_STATISTIC_TRACK_FILTERED_TERMS', 'track_filtered_terms'); -define('TABLE_STATISTIC_TRACK_C_BROWSERS', 'track_c_browsers'); -define('TABLE_STATISTIC_TRACK_C_COUNTRIES', 'track_c_countries'); -define('TABLE_STATISTIC_TRACK_C_OS', 'track_c_os'); -define('TABLE_STATISTIC_TRACK_C_PROVIDERS', 'track_c_providers'); -define('TABLE_STATISTIC_TRACK_C_REFERERS', 'track_c_referers'); //Course catalog stats see #4191 define('TABLE_STATISTIC_TRACK_COURSE_RANKING', 'track_course_ranking'); @@ -203,14 +197,14 @@ define('TABLE_DROPBOX_FILE', 'dropbox_file'); define('TABLE_DROPBOX_PERSON', 'dropbox_person'); // Course quiz (or test, or exercice) tables -define('TABLE_QUIZ_QUESTION', 'quiz_question'); -define('TABLE_QUIZ_TEST', 'quiz'); -define('TABLE_QUIZ_ORDER', 'quiz_order'); -define('TABLE_QUIZ_ANSWER', 'quiz_answer'); -define('TABLE_QUIZ_TEST_QUESTION', 'quiz_rel_question'); -define('TABLE_QUIZ_QUESTION_OPTION', 'quiz_question_option'); -define('TABLE_QUIZ_QUESTION_CATEGORY', 'quiz_question_category'); -define('TABLE_QUIZ_QUESTION_REL_CATEGORY', 'quiz_question_rel_category'); +define('TABLE_QUIZ_QUESTION', 'quiz_question'); +define('TABLE_QUIZ_TEST', 'quiz'); +define('TABLE_QUIZ_ORDER', 'quiz_order'); +define('TABLE_QUIZ_ANSWER', 'quiz_answer'); +define('TABLE_QUIZ_TEST_QUESTION', 'quiz_rel_question'); +define('TABLE_QUIZ_QUESTION_OPTION', 'quiz_question_option'); +define('TABLE_QUIZ_QUESTION_CATEGORY', 'quiz_question_category'); +define('TABLE_QUIZ_QUESTION_REL_CATEGORY', 'quiz_question_rel_category'); // Linked resource table //@todo table exists? @@ -244,11 +238,6 @@ define('TABLE_BLOGS_TASKS_REL_USER', 'blog_task_rel_user'); define('TABLE_BLOGS_RATING', 'blog_rating'); define('TABLE_BLOGS_ATTACHMENT', 'blog_attachment'); define('TABLE_BLOGS_TASKS_PERMISSIONS', 'permission_task'); -//end of Smartblogs - -// User information tables -define('TABLE_USER_INFO', 'userinfo_def'); -define('TABLE_USER_INFO_CONTENT', 'userinfo_content'); // Course settings table define('TABLE_COURSE_SETTING', 'course_setting'); @@ -294,9 +283,6 @@ define('TABLE_NOTEBOOK', 'notebook'); define('TABLE_MESSAGE', 'message'); define('TABLE_MESSAGE_ATTACHMENT', 'message_attachment'); -// Metadata -define('TABLE_METADATA', 'metadata'); - // Attendance Sheet define('TABLE_ATTENDANCE', 'attendance'); define('TABLE_ATTENDANCE_CALENDAR', 'attendance_calendar'); diff --git a/main/inc/lib/database.lib.php b/main/inc/lib/database.lib.php index 8ddef3977f..057d015dae 100755 --- a/main/inc/lib/database.lib.php +++ b/main/inc/lib/database.lib.php @@ -4,20 +4,10 @@ use Doctrine\DBAL\Connection; use Doctrine\ORM\EntityManager; use Doctrine\DBAL\Driver\Statement; +use Doctrine\Common\Annotations\AnnotationRegistry; /** * Class Database - * This is the main database library for Chamilo. - * Include/require it in your code to use its functionality. - * Because this library contains all the basic database calls, it could be - * replaced by another library for say, PostgreSQL, to actually use Chamilo - * with another database (this is not ready yet because a lot of code still - * uses the MySQL database functions extensively). - * - * If trying to replicate the database layer, don't forget to look for "sql" - * named functions in main_api.lib.php - * - * @package chamilo.library */ class Database { @@ -29,6 +19,7 @@ class Database * @var EntityManager */ private static $em; + private static $connection; /** * @param EntityManager $em @@ -39,89 +30,37 @@ class Database } /** - * @return EntityManager - */ - public static function getManager() - { - return self::$em; - } - - /** - * Returns the name of the main database. - */ - public static function get_main_database() - { - global $_configuration; - return $_configuration['main_database']; - } - - /** - * Returns the glued name of the current course database. - * @return mixed Glued database name of false if undefined + * @param Connection $connection */ - public static function get_current_course_glued_database() + public function setConnection(Connection $connection) { - $course_info = api_get_course_info(); - if (empty($course_info['dbNameGlu'])) { - return false; - } - return $course_info['dbNameGlu']; + self::$connection = $connection; } /** - * The glue is the string needed between database and table. - * The trick is: in multiple databases, this is a period (with backticks). - * In single database, this can be e.g. an underscore so we just fake - * there are multiple databases and the code can be written independent - * of the single / multiple database setting. + * @return Connection */ - public static function get_database_glue() + public function getConnection() { - global $_configuration; - return $_configuration['db_glue']; + return self::$connection; } /** - * Returns the database prefix. - * All created COURSE databases are prefixed with this string. - * - * TIP: This can be convenient if you have multiple system installations - * on the same physical server. + * @return EntityManager */ - public static function get_database_name_prefix() + public static function getManager() { - global $_configuration; - return $_configuration['db_prefix']; + return self::$em; } /** - * Returns the course table prefix for single database. - * Not certain exactly when this is used. - * Do research. - * It's used in local.inc.php. + * Returns the name of the main database. */ - public static function get_course_table_prefix() + public static function get_main_database() { - global $_configuration; - return $_configuration['table_prefix']; + return self::getManager()->getConnection()->getDatabase(); } - /* - Table name methods - Use these methods to get table names for queries, - instead of constructing them yourself. - - Backticks automatically surround the result, - e.g. COURSE_NAME.link - so the queries can look cleaner. - - Example: - $table = Database::get_course_table(TABLE_DOCUMENT); - $sql_query = "SELECT * FROM $table WHERE $condition"; - $sql_result = Database::query($sql_query); - $result = Database::fetch_array($sql_result); - */ - /** * A more generic method than the other get_main_xxx_table methods, * This one returns the correct complete name of any table of the main @@ -129,13 +68,11 @@ class Database * Please, define table names as constants in this library and use them * instead of directly using magic words in your tool code. * - * @param string $short_table_name, the name of the table + * @param string $table, the name of the table */ - public static function get_main_table($short_table_name) + public static function get_main_table($table) { - return self::format_table_name( - self::get_main_database(), - $short_table_name); + return $table; } /** @@ -145,74 +82,79 @@ class Database * Please, define table names as constants in this library and use them * instead of directly using magic words in your tool code. * - * @param string $short_table_name, the name of the table - * @param string $database_name, optional, name of the course database - * - if you don't specify this, you work on the current course. + * @param string $table, the name of the table */ - public static function get_course_table($short_table_name, $extra = null) + public static function get_course_table($table) { - //forces fatal errors so we can debug more easily - if (!empty($extra)) { - var_dump($extra); - //@todo remove this - echo "

    Dev Message: get_course_table() doesn't have a 2nd parameter

    "; - //exit; - } - return self::format_table_name(self::get_main_database(), DB_COURSE_PREFIX.$short_table_name); + return DB_COURSE_PREFIX.$table; } - /* - Query methods - These methods execute a query and return the result(s). - */ - /** * Counts the number of rows in a table * @param string $table The table of which the rows should be counted * @return int The number of rows in the given table. * @deprecated */ - public static function count_rows($table) { - $obj = self::fetch_object(self::query("SELECT COUNT(*) AS n FROM $table")); // + public static function count_rows($table) + { + $obj = self::fetch_object(self::query("SELECT COUNT(*) AS n FROM $table")); + return $obj->n; } - /* - An intermediate API-layer between the system and the database server. - */ /** * Returns the number of affected rows in the last database operation. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return int Returns the number of affected rows on success, and -1 if the last query failed. + * @param Statement $result + * + * @return int */ - public static function affected_rows($connection = null) { - return self::use_default_connection($connection) ? mysql_affected_rows() : mysql_affected_rows($connection); + public static function affected_rows(Statement $result) + { + return $result->rowCount(); } /** - * Closes non-persistent database connection. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return bool Returns TRUE on success or FALSE on failure. + * Connect to the database sets the entity manager. + * @param array $params + * + * @throws \Doctrine\ORM\ORMException */ - public static function close($connection = null) { - return self::use_default_connection($connection) ? mysql_close() : mysql_close($connection); - } + public function connect($params = []) + { + $config = self::getDoctrineConfig(); + $config->setEntityNamespaces( + array( + 'ChamiloUserBundle' => 'Chamilo\UserBundle\Entity', + 'ChamiloCoreBundle' => 'Chamilo\CoreBundle\Entity', + 'ChamiloCourseBundle' => 'Chamilo\CourseBundle\Entity' + ) + ); + + $params['charset'] = 'utf8'; + $entityManager = EntityManager::create($params, $config); + + // Registering Constraints + AnnotationRegistry::registerAutoloadNamespace( + 'Symfony\Component\Validator\Constraint', + api_get_path(SYS_PATH)."vendor/symfony/validator" + ); + + AnnotationRegistry::registerFile( + api_get_path(SYS_PATH)."vendor/symfony/doctrine-bridge/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php" + ); + + // Registering gedmo extensions + AnnotationRegistry::registerAutoloadNamespace( + 'Gedmo\Mapping\Annotation', + api_get_path(SYS_PATH)."vendor/gedmo/doctrine-extensions/lib" + ); + + $this->setConnection($entityManager->getConnection()); + $this->setManager($entityManager); - /** - * Opens a connection to a database server. - * @param array $parameters (optional) An array that contains the necessary parameters for accessing the server. - * @return resource/boolean Returns a database connection on success or FALSE on failure. - * Note: Currently the array could contain MySQL-specific parameters: - * $parameters['server'], $parameters['username'], $parameters['password'], - * $parameters['new_link'], $parameters['client_flags'], $parameters['persistent']. - * For details see documentation about the functions mysql_connect() and mysql_pconnect(). - * @link http://php.net/manual/en/function.mysql-connect.php - * @link http://php.net/manual/en/function.mysql-pconnect.php - */ - public static function connect($parameters = array()) { // A MySQL-specific implementation. - if (!isset($parameters['server'])) { + /*if (!isset($parameters['server'])) { $parameters['server'] = @ini_get('mysql.default_host'); if (empty($parameters['server'])) { $parameters['server'] = 'localhost:3306'; @@ -240,26 +182,7 @@ class Database $client_flags = isset($parameters['client_flags']) ? $parameters['client_flags'] : null; return $persistent ? mysql_pconnect($server, $username, $password, $client_flags) - : mysql_connect($server, $username, $password, $new_link, $client_flags); - } - - /** - * Returns error number from the last operation done on the database server. - * @param resource $connection (optional) The database server connection, - * for detailed description see the method query(). - * @return int Returns the error number from the last database (operation, or 0 (zero) if no error occurred. - */ - public static function errno($connection = null) { - return self::use_default_connection($connection) ? mysql_errno() : mysql_errno($connection); - } - - /** - * Returns error text from the last operation done on the database server. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return string Returns the error text from the last database operation, or '' (empty string) if no error occurred. - */ - public static function error($connection = null) { - return self::use_default_connection($connection) ? mysql_error() : mysql_error($connection); + : mysql_connect($server, $username, $password, $new_link, $client_flags);*/ } /** @@ -277,24 +200,16 @@ class Database /** * Escapes a string to insert into the database as text - * @param string $string The string to escape - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @param bool $addFix - * @return string he escaped string - * @author Yannick Warnier - * @author Patrick Cool , Ghent University + * @param $string + * + * @return string */ - public static function escape_string($string, $connection = null, $addFix = true) + public static function escape_string($string) { - return get_magic_quotes_gpc() - ? (self::use_default_connection($connection) - ? mysql_real_escape_string(stripslashes($string)) - : mysql_real_escape_string(stripslashes($string), $connection)) - : (self::use_default_connection($connection) - ? mysql_real_escape_string($string) - : mysql_real_escape_string($string, $connection)); - } + $string = self::getManager()->getConnection()->quote($string); + return trim($string, "'"); + } /** * Gets the array from a SQL result (as returned by Database::query) - help achieving database independence @@ -303,10 +218,13 @@ class Database * @return array Array of results as returned by php * @author Yannick Warnier */ - public static function fetch_array($result, $option = 'BOTH') + public static function fetch_array(Statement $result, $option = 'BOTH') { - if ($result === false) { return array(); } - return $option == 'ASSOC' ? mysql_fetch_array($result, MYSQL_ASSOC) : ($option == 'NUM' ? mysql_fetch_array($result, MYSQL_NUM) : mysql_fetch_array($result)); + if ($result === false) { + return array(); + } + + return $result->fetch(self::customOptionToDoctrineOption($option)); } /** @@ -315,29 +233,31 @@ class Database * @param resource $result The result from a call to sql_query (e.g. Database::query). * @return array Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead. */ - public static function fetch_assoc($result) { - return mysql_fetch_assoc($result); + public static function fetch_assoc(Statement $result) + { + return $result->fetch(PDO::FETCH_ASSOC); } /** * Gets the next row of the result of the SQL query (as returned by Database::query) in an object form - * @param resource The result from a call to sql_query (e.g. Database::query) - * @param string Optional class name to instanciate - * @param array Optional array of parameters - * @return object Object of class StdClass or the required class, containing the query result row - * @author Yannick Warnier + * + * @param Statement $result + * @return mixed */ - public static function fetch_object($result, $class = null, $params = null) { - return !empty($class) ? (is_array($params) ? mysql_fetch_object($result, $class, $params) : mysql_fetch_object($result, $class)) : mysql_fetch_object($result); + public static function fetch_object(Statement $result) + { + return $result->fetch(PDO::FETCH_OBJ); } /** * Gets the array from a SQL result (as returned by Database::query) - help achieving database independence - * @param resource The result from a call to sql_query (see Database::query()). - * @return array Array of results as returned by php (mysql_fetch_row) + * @param Statement $result + * + * @return mixed */ - public static function fetch_row($result) { - return mysql_fetch_row($result); + public static function fetch_row(Statement $result) + { + return $result->fetch(PDO::FETCH_NUM); } /** @@ -346,283 +266,81 @@ class Database * Notes: Use this method if you are concerned about how much memory is being used for queries that return large result sets. * Anyway, all associated result memory is automatically freed at the end of the script's execution. */ - public static function free_result($result) { - return mysql_free_result($result); - } - - /** - * Returns the database client library version. - * @return strung Returns a string that represents the client library version. - */ - public static function get_client_info() { - return mysql_get_client_info(); - } - - /** - * Returns a list of databases created on the server. The list may contain all of the - * available database names or filtered database names by using a pattern. - * @param string $pattern (optional) A pattern for filtering database names as if it was needed for the SQL's LIKE clause, for example 'chamilo_%'. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return array Returns in an array the retrieved list of database names. - */ - public static function get_databases($pattern = '', $connection = null) { - $result = array(); - $query_result = Database::query(!empty($pattern) ? "SHOW DATABASES LIKE '".self::escape_string($pattern, $connection)."'" : "SHOW DATABASES", $connection); - while ($row = Database::fetch_row($query_result)) { - $result[] = $row[0]; - } - return $result; - } - - /** - * Returns information about the type of the current connection and the server host name. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return string/boolean Returns string data on success or FALSE on failure. - */ - public static function get_host_info($connection = null) { - return self::use_default_connection($connection) ? mysql_get_host_info() : mysql_get_host_info($connection); - } - - /** - * Retrieves database client/server protocol version. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return int/boolean Returns the protocol version on success or FALSE on failure. - */ - public static function get_proto_info($connection = null) { - return self::use_default_connection($connection) ? mysql_get_proto_info() : mysql_get_proto_info($connection); - } - - /** - * Retrieves the database server version. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return string/boolean Returns the MySQL server version on success or FALSE on failure. - */ - public static function get_server_info($connection = null) { - return self::use_default_connection($connection) ? mysql_get_server_info() : mysql_get_server_info($connection); - } - - /** - * Returns a list of tables within a database. The list may contain all of the - * available table names or filtered table names by using a pattern. - * @param string $database (optional) The name of the examined database. If it is omited, the current database is assumed, see Database::select_db(). - * @param string $pattern (optional) A pattern for filtering table names as if it was needed for the SQL's LIKE clause, for example 'access_%'. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return array Returns in an array the retrieved list of table names. - */ - public static function get_tables($database = '', $pattern = '', $connection = null) { - $result = array(); - $query = "SHOW TABLES"; - if (!empty($database)) { - $query .= " FROM `".self::escape_string($database, $connection)."`"; - } - if (!empty($pattern)) { - $query .= " LIKE '".self::escape_string($pattern, $connection)."'"; - } - $query_result = Database::query($query, $connection); - while ($row = Database::fetch_row($query_result)) { - $result[] = $row[0]; - } - return $result; + public static function free_result(Statement $result) + { + $result->closeCursor(); } /** * Gets the ID of the last item inserted into the database - * This should be updated to use ADODB at some point - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return int The last ID as returned by the DB function + * @return string */ - public static function insert_id($connection = null) { - return self::use_default_connection($connection) ? mysql_insert_id() : mysql_insert_id($connection); + public static function insert_id() + { + return self::getManager()->getConnection()->lastInsertId(); } /** - * Gets the number of rows from the last query result - help achieving database independence - * @param resource The result - * @return integer The number of rows contained in this result - * @author Yannick Warnier - **/ - public static function num_rows($result) { - return is_resource($result) ? mysql_num_rows($result) : false; + * @param Statement $result + * + * @return int + */ + public static function num_rows(Statement $result) + { + return $result->rowCount(); } /** * Acts as the relative *_result() function of most DB drivers and fetches a * specific line and a field - * @param resource The database resource to get data from - * @param integer The row number - * @param string Optional field name or number - * @return mixed One cell of the result, or FALSE on error - */ - public static function result($resource, $row, $field = '') { - return self::num_rows($resource) > 0 ? (!empty($field) ? mysql_result($resource, $row, $field) : mysql_result($resource, $row)) : null; - } - - /** - * This method returns a resource - * Documentation has been added by Arthur Portugal - * Some adaptations have been implemented by Ivan Tcholakov, 2009, 2010 - * @author Olivier Brouckaert - * @param string $query The SQL query - * @param resource $connection (optional) The database server (MySQL) connection. - * If it is not specified, the connection opened by mysql_connect() is assumed. - * If no connection is found, the server will try to create one as if mysql_connect() was called with no arguments. - * If no connection is found or established, an E_WARNING level error is generated. - * @param string $file (optional) On error it shows the file in which the error has been trigerred (use the "magic" constant __FILE__ as input parameter) - * @param string $line (optional) On error it shows the line in which the error has been trigerred (use the "magic" constant __LINE__ as input parameter) * - * @return resource The returned result from the query + * @param Statement $resource + * @param int $row + * @param string $field * - * Note: The parameter $connection could be skipped. Here are examples of this method usage: - * Database::query($query); - * $result = Database::query($query); - * Database::query($query, $connection); - * $result = Database::query($query, $connection); - * The following ways for calling this method are obsolete: - * Database::query($query, __FILE__, __LINE__); - * $result = Database::query($query, __FILE__, __LINE__); - * Database::query($query, $connection, __FILE__, __LINE__); - * $result = Database::query($query, $connection, __FILE__, __LINE__); + * @return mixed */ - public static function query($query, $connection = null, $file = null, $line = null) + public static function result(Statement $resource, $row, $field = '') { - $use_default_connection = self::use_default_connection($connection); - if ($use_default_connection) { - // Let us do parameter shifting, thus the method would be similar - // (in regard to parameter order) to the original function mysql_query(). - $line = $file; - $file = $connection; - $connection = null; - } + if ($resource->rowCount() > 0) { + $result = $resource->fetchAll(PDO::FETCH_BOTH); - // Check if the table contains a c_ (means a course id) - if (api_get_setting('server_type') === 'test' && strpos($query, 'c_')) { - //Check if the table contains inner joins - if ( - strpos($query, 'assoc_handle') === false && - strpos($query, 'olpc_peru_filter') === false && - strpos($query, 'allow_public_certificates') === false && - strpos($query, 'DROP TABLE IF EXISTS') === false && - strpos($query, 'thematic_advance') === false && - strpos($query, 'thematic_plan') === false && - strpos($query, 'track_c_countries') === false && - strpos($query, 'track_c_os') === false && - strpos($query, 'track_c_providers') === false && - strpos($query, 'track_c_referers') === false && - strpos($query, 'track_c_browsers') === false && - strpos($query, 'settings_current') === false && - strpos($query, 'dokeos_classic_2D') === false && - strpos($query, 'cosmic_campus') === false && - strpos($query, 'static_') === false && - strpos($query, 'public_admin') === false && - strpos($query, 'chamilo_electric_blue') === false && - strpos($query, 'specific_field') === false && - strpos($query, 'down_doc_path') === false && - strpos($query, 'INNER JOIN') === false && - strpos($query, 'inner join') === false && - strpos($query, 'left join') === false && - strpos($query, 'LEFT JOIN') === false && - strpos($query, 'insert') === false && - strpos($query, 'INSERT') === false && - strpos($query, 'ALTER') === false && - strpos($query, 'alter') === false && - strpos($query, 'c_id') === false && - strpos($query, 'create table') === false && - strpos($query, 'CREATE TABLE') === false && - strpos($query, 'AUTO_INCREMENT') === false - ) { - //@todo remove this - echo '
    ';
    -                $message = '

    Dev message: please add the c_id field in this query or report this error in support.chamilo.org

    '; - $message .= $query; - echo $message; - echo '
    '; - //error_log($message); - } + return $result[$row][$field]; } + } - if (!($result = $use_default_connection ? mysql_query($query) : mysql_query($query, $connection))) { - $backtrace = debug_backtrace(); // Retrieving information about the caller statement. - if (isset($backtrace[0])) { - $caller = & $backtrace[0]; - } else { - $caller = array(); - } - if (isset($backtrace[1])) { - $owner = & $backtrace[1]; - } else { - $owner = array(); - } - if (empty($file)) { - $file = $caller['file']; - } - if (empty($line) && $line !== false) { - $line = $caller['line']; - } - $type = isset($owner['type']) ? $owner['type'] : null; - $function = $owner['function']; - $class = isset($owner['class']) ? $owner['class'] : null; - $server_type = api_get_setting('server_type'); - if (!empty($line) && !empty($server_type) && $server_type != 'production') { - $errMsg = self::error($connection); - $info = '
    ' .
    -                    'DATABASE ERROR #'.self::errno($connection).':
    ' . - self::remove_XSS($errMsg) . '
    ' . - 'QUERY :
    ' . - self::remove_XSS($query) . '
    ' . - 'FILE :
    ' . - (empty($file) ? ' unknown ' : $file) . '
    ' . - 'LINE :
    ' . - (empty($line) ? ' unknown ' : $line) . '
    '; - if (empty($type)) { - if (!empty($function)) { - $info .= 'FUNCTION :
    ' . $function; - } - } else { - if (!empty($class) && !empty($function)) { - $info .= 'CLASS :
    ' . $class . '
    '; - $info .= 'METHOD :
    ' . $function; - } - } - $info .= '
    '; - echo $info; - } - - if (isset(self::$log_queries) && self::$log_queries) { - error_log("---------------- SQL error ---------------- "); - error_log($query); - - error_log('error #'.self::errno($connection)); - error_log('error: '.self::error($connection)); - - $info = 'FILE: ' .(empty($file) ? ' unknown ' : $file); - $info .= ' +'.(empty($line) ? ' unknown ' : $line); - error_log($info); + /** + * @param $query + * @return Statement + * + * @throws \Doctrine\DBAL\DBALException + */ + public static function query($query) + { + $result = self::getManager()->getConnection()->executeQuery($query); - if (empty($type)) { - if (!empty($function)) { - $info = 'FUNCTION: ' . $function; - error_log($info); - } - } else { - if (!empty($class) && !empty($function)) { - $info = 'CLASS: ' . $class.' METHOD: '.$function; - error_log($info); - } - } - error_log("---------------- end ----------------"); - } - } return $result; } /** - * Selects a database. - * @param string $database_name The name of the database that is to be selected. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return bool Returns TRUE on success or FALSE on failure. + * @param string $option + * + * @return int */ - public static function select_db($database_name, $connection = null) { - return self::use_default_connection($connection) ? mysql_select_db($database_name) : mysql_select_db($database_name, $connection); + public static function customOptionToDoctrineOption($option) + { + switch($option) { + case 'ASSOC': + return PDO::FETCH_ASSOC; + break; + case 'NUM': + return PDO::FETCH_NUM; + break; + case 'BOTH': + default: + return PDO::FETCH_BOTH; + break; + } } /** @@ -633,263 +351,9 @@ class Database * @param option BOTH, ASSOC, or NUM * @return array - the value returned by the query */ - public static function store_result($result, $option = 'BOTH') { - $array = array(); - if ($result !== false) { // For isolation from database engine's behaviour. - while ($row = self::fetch_array($result, $option)) { - $array[] = $row; - } - } - return $array; - } - - /* - Encodings and collations supported by MySQL database server - */ - - /** - * Checks whether a given encoding is supported by the database server. - * @param string $encoding The encoding (a system conventional id, for example 'UTF-8') to be checked. - * @return bool Returns a boolean value as a check-result. - * @author Ivan Tcholakov - */ - public static function is_encoding_supported($encoding) { - static $supported = array(); - if (!isset($supported[$encoding])) { - $supported[$encoding] = false; - if (strlen($db_encoding = self::to_db_encoding($encoding)) > 0) { - if (self::num_rows(self::query("SHOW CHARACTER SET WHERE Charset = '".self::escape_string($db_encoding)."';")) > 0) { - $supported[$encoding] = true; - } - } - } - return $supported[$encoding]; - } - - /** - * Constructs a SQL clause about default character set and default collation for newly created databases and tables. - * Example: Database::make_charset_clause('UTF-8', 'bulgarian') returns - * DEFAULT CHARACTER SET `utf8` DEFAULT COLLATE `utf8_general_ci` - * @param string $encoding (optional) The default database/table encoding (a system conventional id) to be used. - * @param string $language (optional) Language (a system conventional id) used for choosing language sensitive collation (if it is possible). - * @return string Returns the constructed SQL clause or empty string if $encoding is not correct or is not supported. - * @author Ivan Tcholakov - */ - public static function make_charset_clause($encoding = null, $language = null) { - if (empty($encoding)) { - $encoding = api_get_system_encoding(); - } - if (empty($language)) { - $language = api_get_interface_language(); - } - $charset_clause = ''; - if (self::is_encoding_supported($encoding)) { - $db_encoding = Database::to_db_encoding($encoding); - $charset_clause .= " DEFAULT CHARACTER SET `".$db_encoding."`"; - $db_collation = Database::to_db_collation($encoding, $language); - if (!empty($db_collation)) { - $charset_clause .= " DEFAULT COLLATE `".$db_collation."`"; - } - } - return $charset_clause; - } - - /** - * Converts an encoding identificator to MySQL-specific encoding identifictor, - * i.e. 'UTF-8' --> 'utf8'. - * @param string $encoding The conventional encoding identificator. - * @return string Returns the corresponding MySQL-specific encoding identificator if any, otherwise returns NULL. - * @author Ivan Tcholakov - */ - public static function to_db_encoding($encoding) { - static $result = array(); - if (!isset($result[$encoding])) { - $result[$encoding] = null; - $encoding_map = & self::get_db_encoding_map(); - foreach ($encoding_map as $key => $value) { - if (api_equal_encodings($encoding, $key)) { - $result[$encoding] = $value; - break; - } - } - } - return $result[$encoding]; - } - - /** - * Converts a MySQL-specific encoding identifictor to conventional encoding identificator, - * i.e. 'utf8' --> 'UTF-8'. - * @param string $encoding The MySQL-specific encoding identificator. - * @return string Returns the corresponding conventional encoding identificator if any, otherwise returns NULL. - * @author Ivan Tcholakov - */ - public static function from_db_encoding($db_encoding) { - static $result = array(); - if (!isset($result[$db_encoding])) { - $result[$db_encoding] = null; - $encoding_map = & self::get_db_encoding_map(); - foreach ($encoding_map as $key => $value) { - if (strtolower($db_encoding) == $value) { - $result[$db_encoding] = $key; - break; - } - } - } - return $result[$db_encoding]; - } - - /** - * Chooses the default MySQL-specific collation from given encoding and language. - * @param string $encoding A conventional encoding id, i.e. 'UTF-8' - * @param string $language (optional) A conventional for the system language id, i.e. 'bulgarian'. If it is empty, the chosen collation is the default server value corresponding to the given encoding. - * @return string Returns a suitable default collation, for example 'utf8_general_ci', or NULL if collation was not found. - * @author Ivan Tcholakov - */ - public static function to_db_collation($encoding, $language = null) { - static $result = array(); - if (!isset($result[$encoding][$language])) { - $result[$encoding][$language] = null; - if (self::is_encoding_supported($encoding)) { - $db_encoding = self::to_db_encoding($encoding); - if (!empty($language)) { - $lang = api_purify_language_id($language); - $res = self::check_db_collation($db_encoding, $lang); - if (empty($res)) { - $db_collation_map = & self::get_db_collation_map(); - if (isset($db_collation_map[$lang])) { - $res = self::check_db_collation($db_encoding, $db_collation_map[$lang]); - } - } - if (empty($res)) { - $res = self::check_db_collation($db_encoding, null); - } - $result[$encoding][$language] = $res; - } else { - $result[$encoding][$language] = self::check_db_collation($db_encoding, null); - } - } - } - return $result[$encoding][$language]; - } - - /* - Private methods - You should not access these from outside the class - No effort is made to keep the names / results the same. - */ - - /** - * Structures a database and table name to ready them - * for querying. The database parameter is considered not glued, - * just plain e.g. COURSE001 - */ - private static function format_table_name($database, $table) { - global $_configuration; - if ($_configuration['single_database']) { - $table_name = '`'.$database.'`.`'.$table.'`'; - } else { - $table_name = '`'.$database.$_configuration['db_glue'].$table.'`'; - } - return $table_name; - } - - /** - * This private method is to be used by the other methods in this class for - * checking whether the input parameter $connection actually has been provided. - * If the input parameter connection is not a resource or if it is not FALSE (in case of error) - * then the default opened connection should be used by the called method. - * @param resource/boolean $connection The checked parameter $connection. - * @return boolean TRUE means that calling method should use the default connection. - * FALSE means that (valid) parameter $connection has been provided and it should be used. - */ - private static function use_default_connection($connection) { - return !is_resource($connection) && $connection !== false; - } - - /** - * This private method tackles the XSS injections. It is similar to Security::remove_XSS() and works always, - * including the time of initialization when the class Security has not been loaded yet. - * @param string The input variable to be filtered from XSS, in this class it is expected to be a string. - * @return string Returns the filtered string as a result. - */ - private static function remove_XSS(& $var) { - return class_exists('Security') ? Security::remove_XSS($var) : @htmlspecialchars($var, ENT_QUOTES, api_get_system_encoding()); - } - - /** - * This private method encapsulates a table with relations between - * conventional and MuSQL-specific encoding identificators. - * @author Ivan Tcholakov - */ - private static function & get_db_encoding_map() { - static $encoding_map = array( - 'ARMSCII-8' => 'armscii8', - 'BIG5' => 'big5', - 'BINARY' => 'binary', - 'CP866' => 'cp866', - 'EUC-JP' => 'ujis', - 'EUC-KR' => 'euckr', - 'GB2312' => 'gb2312', - 'GBK' => 'gbk', - 'ISO-8859-1' => 'latin1', - 'ISO-8859-2' => 'latin2', - 'ISO-8859-7' => 'greek', - 'ISO-8859-8' => 'hebrew', - 'ISO-8859-9' => 'latin5', - 'ISO-8859-13' => 'latin7', - 'ISO-8859-15' => 'latin1', - 'KOI8-R' => 'koi8r', - 'KOI8-U' => 'koi8u', - 'SHIFT-JIS' => 'sjis', - 'TIS-620' => 'tis620', - 'US-ASCII' => 'ascii', - 'UTF-8' => 'utf8', - 'WINDOWS-1250' => 'cp1250', - 'WINDOWS-1251' => 'cp1251', - 'WINDOWS-1252' => 'latin1', - 'WINDOWS-1256' => 'cp1256', - 'WINDOWS-1257' => 'cp1257' - ); - return $encoding_map; - } - - /** - * A helper language id translation table for choosing some collations. - * @author Ivan Tcholakov - */ - private static function & get_db_collation_map() { - static $db_collation_map = array( - 'german' => 'german2', - 'simpl_chinese' => 'chinese', - 'trad_chinese' => 'chinese', - 'turkce' => 'turkish' - ); - return $db_collation_map; - } - - /** - * Constructs a MySQL-specific collation and checks whether it is supported by the database server. - * @param string $db_encoding A MySQL-specific encoding id, i.e. 'utf8' - * @param string $language A MySQL-compatible language id, i.e. 'bulgarian' - * @return string Returns a suitable default collation, for example 'utf8_general_ci', or NULL if collation was not found. - * @author Ivan Tcholakov - */ - private static function check_db_collation($db_encoding, $language) { - if (empty($db_encoding)) { - return null; - } - if (empty($language)) { - $result = self::fetch_array(self::query("SHOW COLLATION WHERE Charset = '".self::escape_string($db_encoding)."' AND `Default` = 'Yes';"), 'NUM'); - return $result ? $result[0] : null; - } - $collation = $db_encoding.'_'.$language.'_ci'; - $query_result = self::query("SHOW COLLATION WHERE Charset = '".self::escape_string($db_encoding)."';"); - while ($result = self::fetch_array($query_result, 'NUM')) { - if ($result[0] == $collation) { - return $collation; - } - } - return null; + public static function store_result(Statement $result, $option = 'BOTH') + { + return $result->fetchAll(self::customOptionToDoctrineOption($option)); } /** @@ -908,7 +372,6 @@ class Database foreach($attributes as $key => $value) { $filtred_attributes[$key] = "'".self::escape_string($value)."'"; } - //@todo check if the field exists in the table we should use a describe of that table $params = array_keys($filtred_attributes); $values = array_values($filtred_attributes); @@ -919,8 +382,10 @@ class Database var_dump($sql); error_log($sql); } + return self::insert_id(); } + return false; } @@ -962,6 +427,7 @@ class Database } else { $array = self::fetch_array($result, $option); } + return $array; } @@ -1083,8 +549,8 @@ class Database $where_return = self::parse_where_conditions($where_conditions); $sql = "DELETE FROM $table_name $where_return "; if ($show_query) { echo $sql; echo '
    '; } - self::query($sql); - $affected_rows = self::affected_rows(); + $result = self::query($sql); + $affected_rows = self::affected_rows($result); //@todo should return affected_rows for return $affected_rows; } @@ -1124,28 +590,14 @@ class Database if ($show_query) { var_dump($sql); } - self::query($sql); - $affected_rows = self::affected_rows(); + $result = self::query($sql); + $affected_rows = self::affected_rows($result); return $affected_rows; } } return false; } - /** - * @deprecated Use api_get_language_isocode($language) instead. - */ - public static function get_language_isocode($language) { - return api_get_language_isocode($language); - } - - /** - * @deprecated Use Database::insert_id() instead. - */ - public static function get_last_insert_id() { - return mysql_insert_id(); - } - /** * @return \Doctrine\ORM\Configuration */ diff --git a/main/inc/lib/database.mysqli.lib.php b/main/inc/lib/database.mysqli.lib.php deleted file mode 100755 index 17acd04e4a..0000000000 --- a/main/inc/lib/database.mysqli.lib.php +++ /dev/null @@ -1,1098 +0,0 @@ -n; - } - - /* - An intermediate API-layer between the system and the dabase server. - */ - - /** - * Returns the number of affected rows in the last database operation. - * @param resource $connection The database server connection, for detailed description see the method query(). - * @return int Returns the number of affected rows on success, and -1 if the last query failed. - */ - public static function affected_rows($connection = null) - { - global $database_connection; - return $database_connection->affected_rows; - } - - /** - * Closes non-persistent database connection. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return bool Returns TRUE on success or FALSE on failure. - */ - public static function close($connection = null) - { - return self::use_default_connection($connection) ? mysqli::close() : mysqli::close($connection); - } - - /** - * Opens a connection to a database server. - * @param array $parameters (optional) An array that contains the necessary parameters for accessing the server. - * @return resource/boolean Returns a database connection on success or FALSE on failure. - * Note: Currently the array could contain MySQL-specific parameters: - * $parameters['server'], $parameters['username'], $parameters['password'], - * $parameters['new_link'], $parameters['client_flags'], $parameters['persistent']. - * For details see documentation about the functions mysql_connect() and mysql_pconnect(). - * @link http://php.net/manual/en/function.mysql-connect.php - * @link http://php.net/manual/en/function.mysql-pconnect.php - */ - public static function connect($parameters = array()) - { - global $database_connection; - // A MySQL-specific implementation. - if (!isset($parameters['server'])) { - $parameters['server'] = @ini_get('mysqli.default_host'); - if (empty($parameters['server'])) { - $parameters['server'] = 'localhost:3306'; - } - } - if (!isset($parameters['username'])) { - $parameters['username'] = @ini_get('mysqli.default_user'); - } - if (!isset($parameters['password'])) { - $parameters['password'] = @ini_get('mysqli.default_pw'); - } - $database_connection = $parameters['persistent'] - ? new mysqli('p:'.$parameters['server'], $parameters['username'], $parameters['password']) - : new mysqli($parameters['server'], $parameters['username'], $parameters['password']); - if ($database_connection->connect_errno) { - error_log($database_connection->connect_errno()); - return false; - } else { - return true; - } - } - - /** - * Returns the error number from the last operation done on the database server. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return int Returns the error number from the last database (operation, or 0 (zero) if no error occurred. - */ - public static function errno($connection = null) - { - return self::use_default_connection($connection) ? mysqli::mysqli_errno() : mysqli::mysqli_errno($connection); - } - - /** - * Returns the error text from the last operation done on the database server. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return string Returns the error text from the last database operation, or '' (empty string) if no error occurred. - */ - public static function error($connection = null) - { - return self::use_default_connection($connection) ? mysqli::mysqli_error() : mysqli::mysqli_error($connection); - } - - /** - * Escapes a string to insert into the database as text - * @param string The string to escape - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return string The escaped string - * @author Yannick Warnier - * @author Patrick Cool , Ghent University - */ - public static function escape_string($string, $connection = null) - { - global $database_connection; - return get_magic_quotes_gpc() - ? ( $database_connection->escape_string(stripslashes($string))) - : ( $database_connection->escape_string($string)); - } - - /** - * Gets the array from a SQL result (as returned by Database::query) - help achieving database independence - * @param resource The result from a call to sql_query (e.g. Database::query) - * @param string Optional: "ASSOC","NUM" or "BOTH", as the constant used in mysqli_fetch_array. - * @return array Array of results as returned by php - * @author Yannick Warnier - */ - public static function fetch_array($result, $option = 'BOTH') - { - return ($option == 'ASSOC') ? $result->fetch_array(MYSQLI_ASSOC) : ($option == 'NUM' ? $result->fetch_array(MYSQLI_NUM) : $result->fetch_array()); - } - - /** - * Gets an associative array from a SQL result (as returned by Database::query). - * This method is equivalent to calling Database::fetch_array() with 'ASSOC' value for the optional second parameter. - * @param resource $result The result from a call to sql_query (e.g. Database::query). - * @return array Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead. - */ - public static function fetch_assoc($result) - { - return $result->fetch_assoc(); - } - - /** - * Gets the next row of the result of the SQL query (as returned by Database::query) in an object form - * @param mysqli $result The result from a call to sql_query (e.g. Database::query) - * @param string $class Optional class name to instantiate - * @param array $params Optional array of parameters - * @return resource Object of class StdClass or the required class, containing the query result row - * @author Yannick Warnier - */ - public static function fetch_object($result, $class = null, $params = null) - { - return !empty($class) ? (is_array($params) ? $result->fetch_object($class, $params) : $result->fetch_object($class)) : $result->fetch_object(); - } - - /** - * Gets the array from a SQL result (as returned by Database::query) - help achieving database independence - * @param resource The result from a call to sql_query (see Database::query()). - * @return array Array of results as returned by php (mysql_fetch_row) - */ - public static function fetch_row($result) - { - return $result->fetch_row(); - } - - /** - * Frees all the memory associated with the provided result identifier. - * @return bool Returns TRUE on success or FALSE on failure. - * Notes: Use this method if you are concerned about how much memory is being used for queries that return large result sets. - * Anyway, all associated result memory is automatically freed at the end of the script's execution. - */ - public static function free_result($result) - { - return $result->free_result(); - } - - /** - * Returns the database client library version. - * @return string String that represents the client library version. - */ - public function get_client_info() - { - return mysqli_get_client_info(); - } - - /** - * Returns a list of databases created on the server. The list may contain all of the - * available database names or filtered database names by using a pattern. - * @param string $pattern A pattern for filtering database names as if it was needed for the SQL's LIKE clause, for example 'chamilo_%'. - * @param resource $connection The database server connection, for detailed description see the method query(). - * @return array Returns in an array the retrieved list of database names. - */ - public static function get_databases($pattern = '', $connection = null) - { - $result = array(); - $query_result = Database::query(!empty($pattern) ? - "SHOW DATABASES LIKE '".self::escape_string($pattern, $connection)."'" : - "SHOW DATABASES", $connection); - while ($row = Database::fetch_row($query_result)) { - $result[] = $row[0]; - } - return $result; - } - - /** - * Returns information about the type of the current connection and the server host name. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return string/boolean Returns string data on success or FALSE on failure. - */ - public function get_host_info($connection = null) - { - return self::use_default_connection($connection) ? mysqli::mysqli_get_host_info() : mysqli::mysqli_get_host_info($connection); - } - - /** - * Retrieves database client/server protocol version. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return int/boolean Returns the protocol version on success or FALSE on failure. - */ - public function get_proto_info($connection = null) - { - return self::use_default_connection($connection) ? mysqli::mysqli_get_proto_info() : mysqli::mysqli_get_proto_info($connection); - } - - /** - * Retrieves the database server version. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return string/boolean Returns the MySQL server version on success or FALSE on failure. - */ - public function get_server_info($connection = null) - { - return self::use_default_connection($connection) ? mysqli::mysqli_get_server_info() : mysqli::mysqli_get_server_info($connection); - } - - /** - * Returns a list of tables within a database. The list may contain all of the - * available table names or filtered table names by using a pattern. - * @param string $database (optional) The name of the examined database. If it is omitted, the current database is assumed, see Database::select_db(). - * @param string $pattern (optional) A pattern for filtering table names as if it was needed for the SQL LIKE clause, for example 'access_%'. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return array Returns in an array the retrieved list of table names. - */ - public static function get_tables($database = '', $pattern = '', $connection = null) - { - $result = array(); - $query = "SHOW TABLES"; - if (!empty($database)) { - $query .= " FROM `".self::escape_string($database, $connection)."`"; - } - if (!empty($pattern)) { - $query .= " LIKE '".self::escape_string($pattern, $connection)."'"; - } - $query_result = Database::query($query, $connection); - while ($row = Database::fetch_row($query_result)) { - $result[] = $row[0]; - } - return $result; - } - - /** - * Gets the ID of the last item inserted into the database - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return int The last ID as returned by the DB function - * @comment This should be updated to use ADODB at some point - */ - public static function insert_id($connection = null) - { - global $database_connection; - return $database_connection->insert_id; - } - - /** - * Gets the number of rows from the last query result - help achieving database independence - * @param resource The result - * @return integer The number of rows contained in this result - * @author Yannick Warnier - **/ - public static function num_rows($result) - { - return is_a($result,'mysqli_result') ? $result->num_rows : false; - } - - /** - * Acts as the relative *_result() function of most DB drivers and fetches a - * specific line and a field - * @param resource The database resource to get data from - * @param integer The row number - * @param string Optional field name or number - * @result mixed One cell of the result, or FALSE on error - */ - public static function result(&$resource, $row, $field = '') - { - if (self::num_rows($resource) > 0) { - if (!empty($field)) { - $r = mysqli_data_seek($resource, $row); - return $r[$field]; - } else { - return mysqli_data_seek($resource, $row); - } - } else { return null; } - } - - /** - * This method returns a resource - * Documentation has been added by Arthur Portugal - * Some adaptations have been implemented by Ivan Tcholakov, 2009, 2010 - * @author Olivier Brouckaert - * @param string $query The SQL query - * @param resource $connection (optional) The database server (MySQL) connection. - * If it is not specified, the connection opened by mysql_connect() is assumed. - * If no connection is found, the server will try to create one as if mysql_connect() was called with no arguments. - * If no connection is found or established, an E_WARNING level error is generated. - * @param string $file (optional) On error it shows the file in which the error has been triggered (use the "magic" constant __FILE__ as input parameter) - * @param string $line (optional) On error it shows the line in which the error has been triggered (use the "magic" constant __LINE__ as input parameter) - * @return resource The returned result from the query - * Note: The parameter $connection could be skipped. Here are examples of this method usage: - * Database::query($query); - * $result = Database::query($query); - * Database::query($query, $connection); - * $result = Database::query($query, $connection); - * The following ways for calling this method are obsolete: - * Database::query($query, __FILE__, __LINE__); - * $result = Database::query($query, __FILE__, __LINE__); - * Database::query($query, $connection, __FILE__, __LINE__); - * $result = Database::query($query, $connection, __FILE__, __LINE__); - */ - public static function query($query, $connection = null, $file = null, $line = null) - { - global $database_connection; - - $result = @$database_connection->query($query); - if ($database_connection->errno) { - $backtrace = debug_backtrace(); // Retrieving information about the caller statement. - if (isset($backtrace[0])) { - $caller = & $backtrace[0]; - } else { - $caller = array(); - } - if (isset($backtrace[1])) { - $owner = & $backtrace[1]; - } else { - $owner = array(); - } - if (empty($file)) { - $file = $caller['file']; - } - if (empty($line) && $line !== false) { - $line = $caller['line']; - } - $type = $owner['type']; - $function = $owner['function']; - $class = $owner['class']; - $server_type = api_get_setting('server_type'); - if (!empty($line) && !empty($server_type) && $server_type != 'production') { - $info = '
    ' .
    -                    'DATABASE ERROR #'.self::errno($connection).':
    ' . - self::remove_XSS(self::error($connection)) . '
    ' . - 'QUERY :
    ' . - self::remove_XSS($query) . '
    ' . - 'FILE :
    ' . - (empty($file) ? ' unknown ' : $file) . '
    ' . - 'LINE :
    ' . - (empty($line) ? ' unknown ' : $line) . '
    '; - if (empty($type)) { - if (!empty($function)) { - $info .= 'FUNCTION :
    ' . $function; - } - } else { - if (!empty($class) && !empty($function)) { - $info .= 'CLASS :
    ' . $class . '
    '; - $info .= 'METHOD :
    ' . $function; - } - } - $info .= '
    '; - echo $info; - } - - if (isset(self::$log_queries) && self::$log_queries) { - error_log("---------------- SQL error ---------------- "); - error_log($query); - - error_log('error #'.self::errno($connection)); - error_log('error: '.self::error($connection)); - - $info = 'FILE: ' .(empty($file) ? ' unknown ' : $file); - error_log($info); - $info = 'LINE: '.(empty($line) ? ' unknown ' : $line); - error_log($info); - - if (empty($type)) { - if (!empty($function)) { - $info = 'FUNCTION: ' . $function; - error_log($info); - } - } else { - if (!empty($class) && !empty($function)) { - $info .= 'CLASS: ' . $class; - error_log($info); - $info .= 'METHOD: ' . $function; - error_log($info); - } - } - error_log("---------------- end ----------------"); - } - - } - return $result; - } - - /** - * Selects a database. - * @param string $database_name The name of the database that is to be selected. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return bool Returns TRUE on success or FALSE on failure. - */ - public static function select_db($database_name, $connection = null) - { - global $database_connection; - $database_connection->select_db($database_name); - return !$database_connection->errno; - //return self::use_default_connection($connection) ? mysqli_select_db($connection, $database_name) : mysqli_select_db($connection, $database_name); - } - - /** - * Stores a query result into an array. - * - * @author Olivier Brouckaert - * @param resource $result - the return value of the query - * @param option BOTH, ASSOC, or NUM - * @return array - the value returned by the query - */ - public static function store_result($result, $option = 'BOTH') - { - $array = array(); - if ($result !== false) { // For isolation from database engine's behaviour. - while ($row = self::fetch_array($result, $option)) { - $array[] = $row; - } - } - return $array; - } - - /* - Encodings and collations supported by MySQL database server - */ - - /** - * Checks whether a given encoding is supported by the database server. - * @param string $encoding The encoding (a system conventional id, for example 'UTF-8') to be checked. - * @return bool Returns a boolean value as a check-result. - * @author Ivan Tcholakov - */ - public static function is_encoding_supported($encoding) - { - static $supported = array(); - if (!isset($supported[$encoding])) { - $supported[$encoding] = false; - if (strlen($db_encoding = self::to_db_encoding($encoding)) > 0) { - if (self::num_rows(self::query("SHOW CHARACTER SET WHERE Charset = '".self::escape_string($db_encoding)."';")) > 0) { - $supported[$encoding] = true; - } - } - } - return $supported[$encoding]; - } - - /** - * Constructs a SQL clause about default character set and default collation for newly created databases and tables. - * Example: Database::make_charset_clause('UTF-8', 'bulgarian') returns - * DEFAULT CHARACTER SET `utf8` DEFAULT COLLATE `utf8_general_ci` - * @param string $encoding (optional) The default database/table encoding (a system conventional id) to be used. - * @param string $language (optional) Language (a system conventional id) used for choosing language sensitive collation (if it is possible). - * @return string Returns the constructed SQL clause or empty string if $encoding is not correct or is not supported. - * @author Ivan Tcholakov - */ - public static function make_charset_clause($encoding = null, $language = null) - { - if (empty($encoding)) { - $encoding = api_get_system_encoding(); - } - if (empty($language)) { - $language = api_get_interface_language(); - } - $charset_clause = ''; - if (self::is_encoding_supported($encoding)) { - $db_encoding = Database::to_db_encoding($encoding); - $charset_clause .= " DEFAULT CHARACTER SET `".$db_encoding."`"; - $db_collation = Database::to_db_collation($encoding, $language); - if (!empty($db_collation)) { - $charset_clause .= " DEFAULT COLLATE `".$db_collation."`"; - } - } - return $charset_clause; - } - - /** - * Converts an encoding identificator to MySQL-specific encoding identifier, - * i.e. 'UTF-8' --> 'utf8'. - * @param string $encoding The conventional encoding identifier. - * @return string Returns the corresponding MySQL-specific encoding identifier if any, otherwise returns NULL. - * @author Ivan Tcholakov - */ - public static function to_db_encoding($encoding) - { - static $result = array(); - if (!isset($result[$encoding])) { - $result[$encoding] = null; - $encoding_map = & self::get_db_encoding_map(); - foreach ($encoding_map as $key => $value) { - if (api_equal_encodings($encoding, $key)) { - $result[$encoding] = $value; - break; - } - } - } - return $result[$encoding]; - } - - /** - * Converts a MySQL-specific encoding identifier to conventional encoding identifier, - * i.e. 'utf8' --> 'UTF-8'. - * @param string $encoding The MySQL-specific encoding identifier. - * @return string Returns the corresponding conventional encoding identifier if any, otherwise returns NULL. - * @author Ivan Tcholakov - */ - public static function from_db_encoding($db_encoding) - { - static $result = array(); - if (!isset($result[$db_encoding])) { - $result[$db_encoding] = null; - $encoding_map = & self::get_db_encoding_map(); - foreach ($encoding_map as $key => $value) { - if (strtolower($db_encoding) == $value) { - $result[$db_encoding] = $key; - break; - } - } - } - return $result[$db_encoding]; - } - - /** - * Chooses the default MySQL-specific collation from given encoding and language. - * @param string $encoding A conventional encoding id, i.e. 'UTF-8' - * @param string $language (optional) A conventional for the system language id, i.e. 'bulgarian'. If it is empty, the chosen collation is the default server value corresponding to the given encoding. - * @return string Returns a suitable default collation, for example 'utf8_general_ci', or NULL if collation was not found. - * @author Ivan Tcholakov - */ - public static function to_db_collation($encoding, $language = null) - { - static $result = array(); - if (!isset($result[$encoding][$language])) { - $result[$encoding][$language] = null; - if (self::is_encoding_supported($encoding)) { - $db_encoding = self::to_db_encoding($encoding); - if (!empty($language)) { - $lang = api_purify_language_id($language); - $res = self::check_db_collation($db_encoding, $lang); - if (empty($res)) { - $db_collation_map = & self::get_db_collation_map(); - if (isset($db_collation_map[$lang])) { - $res = self::check_db_collation($db_encoding, $db_collation_map[$lang]); - } - } - if (empty($res)) { - $res = self::check_db_collation($db_encoding, null); - } - $result[$encoding][$language] = $res; - } else { - $result[$encoding][$language] = self::check_db_collation($db_encoding, null); - } - } - } - return $result[$encoding][$language]; - } - - /* - Private methods - You should not access these from outside the class - No effort is made to keep the names / results the same. - */ - - /** - * Glues a course database. - * glue format from local.inc.php. - */ - private static function glue_course_database_name($database_name) - { - return self::get_course_table_prefix().$database_name.self::get_database_glue(); - } - - /** - * @param string $database_name, can be empty to use current course db - * - * @return the glued parameter if it is not empty, - * or the current course database (glued) if the parameter is empty. - */ - private static function fix_database_parameter($database_name) - { - if (empty($database_name)) { - $course_info = api_get_course_info(); - return $course_info['dbNameGlu']; - } - return self::glue_course_database_name($database_name); - } - - /** - * Structures a course database and table name to ready them - * for querying. The course database parameter is considered glued: - * e.g. COURSE001`.` - */ - private static function format_glued_course_table_name($database_name_with_glue, $table) - { - return '`'.$database_name_with_glue.$table.'`'; - } - - /** - * Structures a database and table name to ready them - * for querying. The database parameter is considered not glued, - * just plain e.g. COURSE001 - */ - private static function format_table_name($database, $table) - { - return '`'.$database.'`.`'.$table.'`'; - } - - /** - * This private method is to be used by the other methods in this class for - * checking whether the input parameter $connection actually has been provided. - * If the input parameter connection is not a resource or if it is not FALSE (in case of error) - * then the default opened connection should be used by the called method. - * @param resource/boolean $connection The checked parameter $connection. - * @return boolean TRUE means that calling method should use the default connection. - * FALSE means that (valid) parameter $connection has been provided and it should be used. - */ - private static function use_default_connection($connection) - { - return !is_resource($connection) && $connection !== false; - } - - /** - * This private method tackles the XSS injections. It is similar to Security::remove_XSS() and works always, - * including the time of initialization when the class Security has not been loaded yet. - * @param string The input variable to be filtered from XSS, in this class it is expected to be a string. - * @return string Returns the filtered string as a result. - */ - private static function remove_XSS(& $var) - { - return class_exists('Security') ? Security::remove_XSS($var) : @htmlspecialchars($var, ENT_QUOTES, api_get_system_encoding()); - } - - /** - * This private method encapsulates a table with relations between - * conventional and MuSQL-specific encoding identificators. - * @author Ivan Tcholakov - */ - private static function & get_db_encoding_map() - { - static $encoding_map = array( - 'ARMSCII-8' => 'armscii8', - 'BIG5' => 'big5', - 'BINARY' => 'binary', - 'CP866' => 'cp866', - 'EUC-JP' => 'ujis', - 'EUC-KR' => 'euckr', - 'GB2312' => 'gb2312', - 'GBK' => 'gbk', - 'ISO-8859-1' => 'latin1', - 'ISO-8859-2' => 'latin2', - 'ISO-8859-7' => 'greek', - 'ISO-8859-8' => 'hebrew', - 'ISO-8859-9' => 'latin5', - 'ISO-8859-13' => 'latin7', - 'ISO-8859-15' => 'latin1', - 'KOI8-R' => 'koi8r', - 'KOI8-U' => 'koi8u', - 'SHIFT-JIS' => 'sjis', - 'TIS-620' => 'tis620', - 'US-ASCII' => 'ascii', - 'UTF-8' => 'utf8', - 'WINDOWS-1250' => 'cp1250', - 'WINDOWS-1251' => 'cp1251', - 'WINDOWS-1252' => 'latin1', - 'WINDOWS-1256' => 'cp1256', - 'WINDOWS-1257' => 'cp1257' - ); - return $encoding_map; - } - - /** - * A helper language id translation table for choosing some collations. - * @author Ivan Tcholakov - */ - private static function & get_db_collation_map() - { - static $db_collation_map = array( - 'german' => 'german2', - 'simpl_chinese' => 'chinese', - 'trad_chinese' => 'chinese', - 'turkce' => 'turkish' - ); - return $db_collation_map; - } - - /** - * Constructs a MySQL-specific collation and checks whether it is supported by the database server. - * @param string $db_encoding A MySQL-specific encoding id, i.e. 'utf8' - * @param string $language A MySQL-compatible language id, i.e. 'bulgarian' - * @return string Returns a suitable default collation, for example 'utf8_general_ci', or NULL if collation was not found. - * @author Ivan Tcholakov - */ - private static function check_db_collation($db_encoding, $language) - { - if (empty($db_encoding)) { - return null; - } - if (empty($language)) { - $result = self::fetch_array(self::query("SHOW COLLATION WHERE Charset = '".self::escape_string($db_encoding)."' AND `Default` = 'Yes';"), 'NUM'); - return $result ? $result[0] : null; - } - $collation = $db_encoding.'_'.$language.'_ci'; - $query_result = self::query("SHOW COLLATION WHERE Charset = '".self::escape_string($db_encoding)."';"); - while ($result = self::fetch_array($query_result, 'NUM')) { - if ($result[0] == $collation) { - return $collation; - } - } - return null; - } - - /* - New useful DB functions - */ - - /** - * Experimental useful database insert - * @todo lot of stuff to do here - */ - public static function insert($table_name, $attributes) - { - if (empty($attributes) || empty($table_name)) { - return false; - } - $filtred_attributes = array(); - foreach($attributes as $key => $value) { - $filtred_attributes[$key] = "'".self::escape_string($value)."'"; - } - $params = array_keys($filtred_attributes); //@todo check if the field exists in the table we should use a describe of that table - $values = array_values($filtred_attributes); - if (!empty($params) && !empty($values)) { - $sql = 'INSERT INTO '.$table_name.' ('.implode(',',$params).') VALUES ('.implode(',',$values).')'; - $result = self::query($sql); - return self::get_last_insert_id(); - } - return false; - } - - /** - * Experimental useful database finder - * @todo lot of stuff to do here - */ - - public static function select($columns, $table_name, $conditions = array(), $type_result = 'all', $option = 'ASSOC') - { - $conditions = self::parse_conditions($conditions); - - //@todo we could do a describe here to check the columns ... - $clean_columns = ''; - if (is_array($columns)) { - $clean_columns = implode(',', $columns); - } else { - if ($columns == '*') { - $clean_columns = '*'; - } else { - $clean_columns = (string)$columns; - } - } - - - $sql = "SELECT $clean_columns FROM $table_name $conditions"; - - $result = self::query($sql); - $array = array(); - //if (self::num_rows($result) > 0 ) { - if ($type_result == 'all') { - while ($row = self::fetch_array($result, $option)) { - if (isset($row['id'])) { - $array[$row['id']] = $row; - } else { - $array[] = $row; - } - } - } else { - $array = self::fetch_array($result, $option); - } - return $array; - } - - /** - * Parses WHERE/ORDER conditions i.e array('where'=>array('id = ?' =>'4'), 'order'=>'id DESC')) - * @param array - * @todo lot of stuff to do here - */ - static function parse_conditions($conditions) - { - if (empty($conditions)) { - return ''; - } - $return_value = ''; - foreach ($conditions as $type_condition => $condition_data) { - $type_condition = strtolower($type_condition); - switch($type_condition) { - case 'where': - $where_return = ''; - foreach ($condition_data as $condition => $value_array) { - if (is_array($value_array)) { - $clean_values = array(); - foreach($value_array as $item) { - $item = Database::escape_string($item); - $clean_values[]= $item; - } - } else { - $value_array = Database::escape_string($value_array); - $clean_values = $value_array; - } - if (!empty($condition) && $clean_values != '') { - $condition = str_replace('%',"'@percentage@'", $condition); //replace "%" - $condition = str_replace("'?'","%s", $condition); - $condition = str_replace("?","%s", $condition); - - $condition = str_replace("@%s@","@-@", $condition); - $condition = str_replace("%s","'%s'", $condition); - $condition = str_replace("@-@","@%s@", $condition); - - //Treat conditons as string - $condition = vsprintf($condition, $clean_values); - $condition = str_replace('@percentage@','%', $condition); //replace "%" - $where_return .= $condition; - } - } - if (!empty($where_return)) { - $return_value = " WHERE $where_return" ; - } - break; - case 'order': - $order_array = $condition_data; - - if (!empty($order_array)) { - // 'order' => 'id desc, name desc' - $order_array = self::escape_string($order_array); - $new_order_array = explode(',', $order_array); - $temp_value = array(); - - foreach($new_order_array as $element) { - $element = explode(' ', $element); - $element = array_filter($element); - $element = array_values($element); - - if (!empty($element[1])) { - $element[1] = strtolower($element[1]); - $order = 'DESC'; - if (in_array($element[1], array('desc', 'asc'))) { - $order = $element[1]; - } - $temp_value[]= $element[0].' '.$order.' '; - } else { - //by default DESC - $temp_value[]= $element[0].' DESC '; - } - } - if (!empty($temp_value)) { - $return_value .= ' ORDER BY '.implode(', ', $temp_value); - } else { - //$return_value .= ''; - } - } - break; - - case 'limit': - $limit_array = explode(',', $condition_data); - if (!empty($limit_array)) { - if (count($limit_array) > 1) { - $return_value .= ' LIMIT '.intval($limit_array[0]).' , '.intval($limit_array[1]); - } else { - $return_value .= ' LIMIT '.intval($limit_array[0]); - } - } - break; - - } - } - return $return_value; - } - - public static function parse_where_conditions($coditions) - { - return self::parse_conditions(array('where'=>$coditions)); - } - - /** - * Experimental useful database update - * @todo lot of stuff to do here - */ - public static function delete($table_name, $where_conditions) - { - $result = false; - $where_return = self::parse_where_conditions($where_conditions); - $sql = "DELETE FROM $table_name $where_return "; - $result = self::query($sql); - $affected_rows = self::affected_rows(); - //@todo should return affected_rows for - return $affected_rows; - } - - - /** - * Experimental useful database update - * @todo lot of stuff to do here - */ - public static function update($table_name, $attributes, $where_conditions = array()) - { - - if (!empty($table_name) && !empty($attributes)) { - $update_sql = ''; - //Cleaning attributes - $count = 1; - foreach ($attributes as $key=>$value) { - $value = self::escape_string($value); - $update_sql .= "$key = '$value' "; - if ($count < count($attributes)) { - $update_sql.=', '; - } - $count++; - } - if (!empty($update_sql)) { - //Parsing and cleaning the where conditions - $where_return = self::parse_where_conditions($where_conditions); - $sql = "UPDATE $table_name SET $update_sql $where_return "; - //echo $sql; exit; - $result = self::query($sql); - $affected_rows = self::affected_rows(); - return $affected_rows; - } - } - return false; - } -} diff --git a/main/inc/lib/databaseDoctrine.php b/main/inc/lib/databaseDoctrine.php deleted file mode 100644 index 4d92dd58c7..0000000000 --- a/main/inc/lib/databaseDoctrine.php +++ /dev/null @@ -1,1126 +0,0 @@ -getConnection()->getDatabase(); - /*global $_configuration; - return $_configuration['main_database'];*/ - } - - /** - * A more generic method than the other get_main_xxx_table methods, - * This one returns the correct complete name of any table of the main - * database of which you pass the short name as a parameter. - * Please, define table names as constants in this library and use them - * instead of directly using magic words in your tool code. - * - * @param string $short_table_name, the name of the table - */ - public static function get_main_table($short_table_name) - { - return $short_table_name; - /* - return self::format_table_name( - self::get_main_database(), - $short_table_name);*/ - } - - /** - * A more generic method than the older get_course_xxx_table methods, - * This one can return the correct complete name of any course table of - * which you pass the short name as a parameter. - * Please, define table names as constants in this library and use them - * instead of directly using magic words in your tool code. - * - * @param string $short_table_name, the name of the table - * @param string $database_name, optional, name of the course database - * - if you don't specify this, you work on the current course. - */ - public static function get_course_table($short_table_name, $extra = null) - { - return DB_COURSE_PREFIX.$short_table_name; - /* - //forces fatal errors so we can debug more easily - if (!empty($extra)) { - var_dump($extra); - //@todo remove this - echo "

    Dev Message: get_course_table() doesn't have a 2nd parameter

    "; - //exit; - } - return self::format_table_name(self::get_main_database(), DB_COURSE_PREFIX.$short_table_name);*/ - } - - /* - Query methods - These methods execute a query and return the result(s). - */ - - /** - * Counts the number of rows in a table - * @param string $table The table of which the rows should be counted - * @return int The number of rows in the given table. - * @deprecated - */ - public static function count_rows($table) { - $obj = self::fetch_object(self::query("SELECT COUNT(*) AS n FROM $table")); - return $obj->n; - } - - /* - An intermediate API-layer between the system and the database server. - */ - - /** - * Returns the number of affected rows in the last database operation. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return int Returns the number of affected rows on success, and -1 if the last query failed. - */ - public static function affected_rows(Statement $result) - { - return $result->rowCount(); - //return self::use_default_connection($connection) ? mysql_affected_rows() : mysql_affected_rows($connection); - } - - /** - * Closes non-persistent database connection. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return bool Returns TRUE on success or FALSE on failure. - */ - public static function close($connection = null) { - return self::use_default_connection($connection) ? mysql_close() : mysql_close($connection); - } - - /** - * Opens a connection to a database server. - * @param array $parameters (optional) An array that contains the necessary parameters for accessing the server. - * @return resource/boolean Returns a database connection on success or FALSE on failure. - * Note: Currently the array could contain MySQL-specific parameters: - * $parameters['server'], $parameters['username'], $parameters['password'], - * $parameters['new_link'], $parameters['client_flags'], $parameters['persistent']. - * For details see documentation about the functions mysql_connect() and mysql_pconnect(). - * @link http://php.net/manual/en/function.mysql-connect.php - * @link http://php.net/manual/en/function.mysql-pconnect.php - */ - public static function connect($parameters = array()) { - // A MySQL-specific implementation. - if (!isset($parameters['server'])) { - $parameters['server'] = @ini_get('mysql.default_host'); - if (empty($parameters['server'])) { - $parameters['server'] = 'localhost:3306'; - } - } - if (!isset($parameters['username'])) { - $parameters['username'] = @ini_get('mysql.default_user'); - } - if (!isset($parameters['password'])) { - $parameters['password'] = @ini_get('mysql.default_password'); - } - if (!isset($parameters['new_link'])) { - $parameters['new_link'] = false; - } - if (!isset($parameters['client_flags']) || empty($parameters['client_flags'])) { - $parameters['client_flags'] = 0; - } - - $persistent = isset($parameters['persistent']) ? $parameters['persistent'] : null; - $server = isset($parameters['server']) ? $parameters['server'] : null; - $username = isset($parameters['username']) ? $parameters['username'] : null; - $password = isset($parameters['password']) ? $parameters['password'] : null; - $client_flag = isset($parameters['client_flags']) ? $parameters['client_flags'] : null; - $new_link = isset($parameters['new_link']) ? $parameters['new_link'] : null; - $client_flags = isset($parameters['client_flags']) ? $parameters['client_flags'] : null; - return $persistent - ? mysql_pconnect($server, $username, $password, $client_flags) - : mysql_connect($server, $username, $password, $new_link, $client_flags); - } - - /** - * Returns error number from the last operation done on the database server. - * @param resource $connection (optional) The database server connection, - * for detailed description see the method query(). - * @return int Returns the error number from the last database (operation, or 0 (zero) if no error occurred. - */ - public static function errno($connection = null) { - return self::use_default_connection($connection) ? mysql_errno() : mysql_errno($connection); - } - - /** - * Returns error text from the last operation done on the database server. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return string Returns the error text from the last database operation, or '' (empty string) if no error occurred. - */ - public static function error($connection = null) { - return self::use_default_connection($connection) ? mysql_error() : mysql_error($connection); - } - - /** - * Escape MySQL wildchars _ and % in LIKE search - * @param string The string to escape - * @return string The escaped string - */ - public static function escape_sql_wildcards($in_txt) - { - $out_txt = api_preg_replace("/_/", "\_", $in_txt); - $out_txt = api_preg_replace("/%/", "\%", $out_txt); - - return $out_txt; - } - - /** - * Escapes a string to insert into the database as text - * @param string $string The string to escape - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @param bool $addFix - * @return string he escaped string - * @author Yannick Warnier - * @author Patrick Cool , Ghent University - */ - public static function escape_string($string, $connection = null, $addFix = true) - { - $string = self::getManager()->getConnection()->quote($string); - return trim($string, "'"); - - /*return get_magic_quotes_gpc() - ? (self::use_default_connection($connection) - ? mysql_real_escape_string(stripslashes($string)) - : mysql_real_escape_string(stripslashes($string), $connection)) - : (self::use_default_connection($connection) - ? mysql_real_escape_string($string) - : mysql_real_escape_string($string, $connection));-*/ - } - - - /** - * Gets the array from a SQL result (as returned by Database::query) - help achieving database independence - * @param resource The result from a call to sql_query (e.g. Database::query) - * @param string Optional: "ASSOC","NUM" or "BOTH", as the constant used in mysql_fetch_array. - * @return array Array of results as returned by php - * @author Yannick Warnier - */ - public static function fetch_array(Statement $result, $option = 'BOTH') - { - if ($result === false) { - return array(); - } - return $result->fetch(self::customOptionToDoctrineOption($option)); - //if ($result === false) { return array(); } - //return $option == 'ASSOC' ? mysql_fetch_array($result, MYSQL_ASSOC) : ($option == 'NUM' ? mysql_fetch_array($result, MYSQL_NUM) : mysql_fetch_array($result)); - } - - /** - * Gets an associative array from a SQL result (as returned by Database::query). - * This method is equivalent to calling Database::fetch_array() with 'ASSOC' value for the optional second parameter. - * @param resource $result The result from a call to sql_query (e.g. Database::query). - * @return array Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead. - */ - public static function fetch_assoc(Statement $result) - { - return $result->fetch(PDO::FETCH_ASSOC); - //return mysql_fetch_assoc($result); - } - - /** - * Gets the next row of the result of the SQL query (as returned by Database::query) in an object form - * @param resource The result from a call to sql_query (e.g. Database::query) - * @param string Optional class name to instanciate - * @param array Optional array of parameters - * @return object Object of class StdClass or the required class, containing the query result row - * @author Yannick Warnier - */ - //public static function fetch_object($result, $class = null, $params = null) { - public static function fetch_object(Statement $result) - { - return $result->fetch(PDO::FETCH_OBJ); - //return !empty($class) ? (is_array($params) ? mysql_fetch_object($result, $class, $params) : mysql_fetch_object($result, $class)) : mysql_fetch_object($result); - } - - /** - * Gets the array from a SQL result (as returned by Database::query) - help achieving database independence - * @param resource The result from a call to sql_query (see Database::query()). - * @return array Array of results as returned by php (mysql_fetch_row) - */ - public static function fetch_row(Statement $result) - { - return $result->fetch(PDO::FETCH_NUM); - //return mysql_fetch_row($result); - } - - /** - * Frees all the memory associated with the provided result identifier. - * @return bool Returns TRUE on success or FALSE on failure. - * Notes: Use this method if you are concerned about how much memory is being used for queries that return large result sets. - * Anyway, all associated result memory is automatically freed at the end of the script's execution. - */ - public static function free_result(Statement $result) - { - $result->closeCursor(); - //return mysql_free_result($result); - } - - /** - * Returns the database client library version. - * @return strung Returns a string that represents the client library version. - */ - public static function get_client_info() { - return mysql_get_client_info(); - } - - /** - * Returns a list of databases created on the server. The list may contain all of the - * available database names or filtered database names by using a pattern. - * @param string $pattern (optional) A pattern for filtering database names as if it was needed for the SQL's LIKE clause, for example 'chamilo_%'. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return array Returns in an array the retrieved list of database names. - */ - public static function get_databases($pattern = '', $connection = null) { - $result = array(); - $query_result = Database::query(!empty($pattern) ? "SHOW DATABASES LIKE '".self::escape_string($pattern, $connection)."'" : "SHOW DATABASES", $connection); - while ($row = Database::fetch_row($query_result)) { - $result[] = $row[0]; - } - return $result; - } - - /** - * Returns information about the type of the current connection and the server host name. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return string/boolean Returns string data on success or FALSE on failure. - */ - public static function get_host_info($connection = null) { - return self::use_default_connection($connection) ? mysql_get_host_info() : mysql_get_host_info($connection); - } - - /** - * Retrieves database client/server protocol version. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return int/boolean Returns the protocol version on success or FALSE on failure. - */ - public static function get_proto_info($connection = null) { - return self::use_default_connection($connection) ? mysql_get_proto_info() : mysql_get_proto_info($connection); - } - - /** - * Retrieves the database server version. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return string/boolean Returns the MySQL server version on success or FALSE on failure. - */ - public static function get_server_info($connection = null) { - return self::use_default_connection($connection) ? mysql_get_server_info() : mysql_get_server_info($connection); - } - - /** - * Returns a list of tables within a database. The list may contain all of the - * available table names or filtered table names by using a pattern. - * @param string $database (optional) The name of the examined database. If it is omited, the current database is assumed, see Database::select_db(). - * @param string $pattern (optional) A pattern for filtering table names as if it was needed for the SQL's LIKE clause, for example 'access_%'. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return array Returns in an array the retrieved list of table names. - */ - public static function get_tables($database = '', $pattern = '', $connection = null) { - $result = array(); - $query = "SHOW TABLES"; - if (!empty($database)) { - $query .= " FROM `".self::escape_string($database, $connection)."`"; - } - if (!empty($pattern)) { - $query .= " LIKE '".self::escape_string($pattern, $connection)."'"; - } - $query_result = Database::query($query, $connection); - while ($row = Database::fetch_row($query_result)) { - $result[] = $row[0]; - } - return $result; - } - - /** - * Gets the ID of the last item inserted into the database - * This should be updated to use ADODB at some point - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return int The last ID as returned by the DB function - */ - public static function insert_id() - { - return self::getManager()->getConnection()->lastInsertId(); - //return self::use_default_connection($connection) ? mysql_insert_id() : mysql_insert_id($connection); - } - - /** - * Gets the number of rows from the last query result - help achieving database independence - * @param resource The result - * @return integer The number of rows contained in this result - * @author Yannick Warnier - **/ - public static function num_rows(Statement $result) - { - return $result->rowCount(); - //return is_resource($result) ? mysql_num_rows($result) : false; - } - - /** - * Acts as the relative *_result() function of most DB drivers and fetches a - * specific line and a field - * @param resource The database resource to get data from - * @param integer The row number - * @param string Optional field name or number - * @return mixed One cell of the result, or FALSE on error - */ - public static function result(Statement $resource, $row, $field = '') - { - if ($resource->rowCount() > 0) { - $result = $resource->fetchAll(PDO::FETCH_BOTH); - return $result[$row][$field]; - } - //return self::num_rows($resource) > 0 ? (!empty($field) ? mysql_result($resource, $row, $field) : mysql_result($resource, $row)) : null; - } - - /** - * This method returns a resource - * Documentation has been added by Arthur Portugal - * Some adaptations have been implemented by Ivan Tcholakov, 2009, 2010 - * @author Olivier Brouckaert - * @param string $query The SQL query - * @param resource $connection (optional) The database server (MySQL) connection. - * If it is not specified, the connection opened by mysql_connect() is assumed. - * If no connection is found, the server will try to create one as if mysql_connect() was called with no arguments. - * If no connection is found or established, an E_WARNING level error is generated. - * @param string $file (optional) On error it shows the file in which the error has been trigerred (use the "magic" constant __FILE__ as input parameter) - * @param string $line (optional) On error it shows the line in which the error has been trigerred (use the "magic" constant __LINE__ as input parameter) - * - * @return Statement The returned result from the query - * - * Note: The parameter $connection could be skipped. Here are examples of this method usage: - * Database::query($query); - * $result = Database::query($query); - * Database::query($query, $connection); - * $result = Database::query($query, $connection); - * The following ways for calling this method are obsolete: - * Database::query($query, __FILE__, __LINE__); - * $result = Database::query($query, __FILE__, __LINE__); - * Database::query($query, $connection, __FILE__, __LINE__); - * $result = Database::query($query, $connection, __FILE__, __LINE__); - */ - public static function query($query, $connection = null, $file = null, $line = null) - { - $result = self::getManager()->getConnection()->executeQuery($query); - - return $result; - - $use_default_connection = self::use_default_connection($connection); - if ($use_default_connection) { - // Let us do parameter shifting, thus the method would be similar - // (in regard to parameter order) to the original function mysql_query(). - $line = $file; - $file = $connection; - $connection = null; - } - - // Check if the table contains a c_ (means a course id) - if (api_get_setting('server_type') === 'test' && strpos($query, 'c_')) { - //Check if the table contains inner joins - if ( - strpos($query, 'assoc_handle') === false && - strpos($query, 'olpc_peru_filter') === false && - strpos($query, 'allow_public_certificates') === false && - strpos($query, 'DROP TABLE IF EXISTS') === false && - strpos($query, 'thematic_advance') === false && - strpos($query, 'thematic_plan') === false && - strpos($query, 'track_c_countries') === false && - strpos($query, 'track_c_os') === false && - strpos($query, 'track_c_providers') === false && - strpos($query, 'track_c_referers') === false && - strpos($query, 'track_c_browsers') === false && - strpos($query, 'settings_current') === false && - strpos($query, 'dokeos_classic_2D') === false && - strpos($query, 'cosmic_campus') === false && - strpos($query, 'static_') === false && - strpos($query, 'public_admin') === false && - strpos($query, 'chamilo_electric_blue') === false && - strpos($query, 'specific_field') === false && - strpos($query, 'down_doc_path') === false && - strpos($query, 'INNER JOIN') === false && - strpos($query, 'inner join') === false && - strpos($query, 'left join') === false && - strpos($query, 'LEFT JOIN') === false && - strpos($query, 'insert') === false && - strpos($query, 'INSERT') === false && - strpos($query, 'ALTER') === false && - strpos($query, 'alter') === false && - strpos($query, 'c_id') === false && - strpos($query, 'create table') === false && - strpos($query, 'CREATE TABLE') === false && - strpos($query, 'AUTO_INCREMENT') === false - ) { - //@todo remove this - echo '
    ';
    -                $message = '

    Dev message: please add the c_id field in this query or report this error in support.chamilo.org

    '; - $message .= $query; - echo $message; - echo '
    '; - //error_log($message); - } - } - - if (!($result = $use_default_connection ? mysql_query($query) : mysql_query($query, $connection))) { - $backtrace = debug_backtrace(); // Retrieving information about the caller statement. - if (isset($backtrace[0])) { - $caller = & $backtrace[0]; - } else { - $caller = array(); - } - if (isset($backtrace[1])) { - $owner = & $backtrace[1]; - } else { - $owner = array(); - } - if (empty($file)) { - $file = $caller['file']; - } - if (empty($line) && $line !== false) { - $line = $caller['line']; - } - $type = isset($owner['type']) ? $owner['type'] : null; - $function = $owner['function']; - $class = isset($owner['class']) ? $owner['class'] : null; - $server_type = api_get_setting('server_type'); - if (!empty($line) && !empty($server_type) && $server_type != 'production') { - $info = '
    ' .
    -                    'DATABASE ERROR #'.self::errno($connection).':
    ' . - self::remove_XSS(self::error($connection)) . '
    ' . - 'QUERY :
    ' . - self::remove_XSS($query) . '
    ' . - 'FILE :
    ' . - (empty($file) ? ' unknown ' : $file) . '
    ' . - 'LINE :
    ' . - (empty($line) ? ' unknown ' : $line) . '
    '; - if (empty($type)) { - if (!empty($function)) { - $info .= 'FUNCTION :
    ' . $function; - } - } else { - if (!empty($class) && !empty($function)) { - $info .= 'CLASS :
    ' . $class . '
    '; - $info .= 'METHOD :
    ' . $function; - } - } - $info .= '
    '; - echo $info; - } - - if (isset(self::$log_queries) && self::$log_queries) { - error_log("---------------- SQL error ---------------- "); - error_log($query); - - error_log('error #'.self::errno($connection)); - error_log('error: '.self::error($connection)); - - $info = 'FILE: ' .(empty($file) ? ' unknown ' : $file); - $info .= ' +'.(empty($line) ? ' unknown ' : $line); - error_log($info); - - if (empty($type)) { - if (!empty($function)) { - $info = 'FUNCTION: ' . $function; - error_log($info); - } - } else { - if (!empty($class) && !empty($function)) { - $info = 'CLASS: ' . $class.' METHOD: '.$function; - error_log($info); - } - } - error_log("---------------- end ----------------"); - } - } - return $result; - } - - /** - * @param string $option - * @return int - */ - public static function customOptionToDoctrineOption($option) - { - switch($option) { - case 'ASSOC': - return PDO::FETCH_ASSOC; - break; - case 'NUM': - return PDO::FETCH_NUM; - break; - case 'BOTH': - default: - return PDO::FETCH_BOTH; - break; - } - } - - /** - * Selects a database. - * @param string $database_name The name of the database that is to be selected. - * @param resource $connection (optional) The database server connection, for detailed description see the method query(). - * @return bool Returns TRUE on success or FALSE on failure. - */ - public static function select_db($database_name, $connection = null) { - return self::use_default_connection($connection) ? mysql_select_db($database_name) : mysql_select_db($database_name, $connection); - } - - /** - * Stores a query result into an array. - * - * @author Olivier Brouckaert - * @param resource $result - the return value of the query - * @param option BOTH, ASSOC, or NUM - * @return array - the value returned by the query - */ - public static function store_result(Statement $result, $option = 'BOTH') - { - return $result->fetchAll(self::customOptionToDoctrineOption($option)); - - $array = array(); - if ($result !== false) { // For isolation from database engine's behaviour. - while ($row = self::fetch_array($result, $option)) { - $array[] = $row; - } - } - return $array; - } - - /* - Encodings and collations supported by MySQL database server - */ - - /** - * Checks whether a given encoding is supported by the database server. - * @param string $encoding The encoding (a system conventional id, for example 'UTF-8') to be checked. - * @return bool Returns a boolean value as a check-result. - * @author Ivan Tcholakov - */ - public static function is_encoding_supported($encoding) { - static $supported = array(); - if (!isset($supported[$encoding])) { - $supported[$encoding] = false; - if (strlen($db_encoding = self::to_db_encoding($encoding)) > 0) { - if (self::num_rows(self::query("SHOW CHARACTER SET WHERE Charset = '".self::escape_string($db_encoding)."';")) > 0) { - $supported[$encoding] = true; - } - } - } - return $supported[$encoding]; - } - - /** - * Constructs a SQL clause about default character set and default collation for newly created databases and tables. - * Example: Database::make_charset_clause('UTF-8', 'bulgarian') returns - * DEFAULT CHARACTER SET `utf8` DEFAULT COLLATE `utf8_general_ci` - * @param string $encoding (optional) The default database/table encoding (a system conventional id) to be used. - * @param string $language (optional) Language (a system conventional id) used for choosing language sensitive collation (if it is possible). - * @return string Returns the constructed SQL clause or empty string if $encoding is not correct or is not supported. - * @author Ivan Tcholakov - */ - public static function make_charset_clause($encoding = null, $language = null) { - if (empty($encoding)) { - $encoding = api_get_system_encoding(); - } - if (empty($language)) { - $language = api_get_interface_language(); - } - $charset_clause = ''; - if (self::is_encoding_supported($encoding)) { - $db_encoding = Database::to_db_encoding($encoding); - $charset_clause .= " DEFAULT CHARACTER SET `".$db_encoding."`"; - $db_collation = Database::to_db_collation($encoding, $language); - if (!empty($db_collation)) { - $charset_clause .= " DEFAULT COLLATE `".$db_collation."`"; - } - } - return $charset_clause; - } - - /** - * Converts an encoding identificator to MySQL-specific encoding identifictor, - * i.e. 'UTF-8' --> 'utf8'. - * @param string $encoding The conventional encoding identificator. - * @return string Returns the corresponding MySQL-specific encoding identificator if any, otherwise returns NULL. - * @author Ivan Tcholakov - */ - public static function to_db_encoding($encoding) { - static $result = array(); - if (!isset($result[$encoding])) { - $result[$encoding] = null; - $encoding_map = & self::get_db_encoding_map(); - foreach ($encoding_map as $key => $value) { - if (api_equal_encodings($encoding, $key)) { - $result[$encoding] = $value; - break; - } - } - } - return $result[$encoding]; - } - - /** - * Converts a MySQL-specific encoding identifictor to conventional encoding identificator, - * i.e. 'utf8' --> 'UTF-8'. - * @param string $encoding The MySQL-specific encoding identificator. - * @return string Returns the corresponding conventional encoding identificator if any, otherwise returns NULL. - * @author Ivan Tcholakov - */ - public static function from_db_encoding($db_encoding) { - static $result = array(); - if (!isset($result[$db_encoding])) { - $result[$db_encoding] = null; - $encoding_map = & self::get_db_encoding_map(); - foreach ($encoding_map as $key => $value) { - if (strtolower($db_encoding) == $value) { - $result[$db_encoding] = $key; - break; - } - } - } - return $result[$db_encoding]; - } - - /** - * Chooses the default MySQL-specific collation from given encoding and language. - * @param string $encoding A conventional encoding id, i.e. 'UTF-8' - * @param string $language (optional) A conventional for the system language id, i.e. 'bulgarian'. If it is empty, the chosen collation is the default server value corresponding to the given encoding. - * @return string Returns a suitable default collation, for example 'utf8_general_ci', or NULL if collation was not found. - * @author Ivan Tcholakov - */ - public static function to_db_collation($encoding, $language = null) { - static $result = array(); - if (!isset($result[$encoding][$language])) { - $result[$encoding][$language] = null; - if (self::is_encoding_supported($encoding)) { - $db_encoding = self::to_db_encoding($encoding); - if (!empty($language)) { - $lang = api_purify_language_id($language); - $res = self::check_db_collation($db_encoding, $lang); - if (empty($res)) { - $db_collation_map = & self::get_db_collation_map(); - if (isset($db_collation_map[$lang])) { - $res = self::check_db_collation($db_encoding, $db_collation_map[$lang]); - } - } - if (empty($res)) { - $res = self::check_db_collation($db_encoding, null); - } - $result[$encoding][$language] = $res; - } else { - $result[$encoding][$language] = self::check_db_collation($db_encoding, null); - } - } - } - return $result[$encoding][$language]; - } - - /* - Private methods - You should not access these from outside the class - No effort is made to keep the names / results the same. - */ - - /** - * This private method is to be used by the other methods in this class for - * checking whether the input parameter $connection actually has been provided. - * If the input parameter connection is not a resource or if it is not FALSE (in case of error) - * then the default opened connection should be used by the called method. - * @param resource/boolean $connection The checked parameter $connection. - * @return boolean TRUE means that calling method should use the default connection. - * FALSE means that (valid) parameter $connection has been provided and it should be used. - */ - private static function use_default_connection($connection) { - return !is_resource($connection) && $connection !== false; - } - - /** - * This private method encapsulates a table with relations between - * conventional and MuSQL-specific encoding identificators. - * @author Ivan Tcholakov - */ - private static function & get_db_encoding_map() { - static $encoding_map = array( - 'ARMSCII-8' => 'armscii8', - 'BIG5' => 'big5', - 'BINARY' => 'binary', - 'CP866' => 'cp866', - 'EUC-JP' => 'ujis', - 'EUC-KR' => 'euckr', - 'GB2312' => 'gb2312', - 'GBK' => 'gbk', - 'ISO-8859-1' => 'latin1', - 'ISO-8859-2' => 'latin2', - 'ISO-8859-7' => 'greek', - 'ISO-8859-8' => 'hebrew', - 'ISO-8859-9' => 'latin5', - 'ISO-8859-13' => 'latin7', - 'ISO-8859-15' => 'latin1', - 'KOI8-R' => 'koi8r', - 'KOI8-U' => 'koi8u', - 'SHIFT-JIS' => 'sjis', - 'TIS-620' => 'tis620', - 'US-ASCII' => 'ascii', - 'UTF-8' => 'utf8', - 'WINDOWS-1250' => 'cp1250', - 'WINDOWS-1251' => 'cp1251', - 'WINDOWS-1252' => 'latin1', - 'WINDOWS-1256' => 'cp1256', - 'WINDOWS-1257' => 'cp1257' - ); - return $encoding_map; - } - - /** - * A helper language id translation table for choosing some collations. - * @author Ivan Tcholakov - */ - private static function & get_db_collation_map() { - static $db_collation_map = array( - 'german' => 'german2', - 'simpl_chinese' => 'chinese', - 'trad_chinese' => 'chinese', - 'turkce' => 'turkish' - ); - return $db_collation_map; - } - - /** - * Constructs a MySQL-specific collation and checks whether it is supported by the database server. - * @param string $db_encoding A MySQL-specific encoding id, i.e. 'utf8' - * @param string $language A MySQL-compatible language id, i.e. 'bulgarian' - * @return string Returns a suitable default collation, for example 'utf8_general_ci', or NULL if collation was not found. - * @author Ivan Tcholakov - */ - private static function check_db_collation($db_encoding, $language) { - if (empty($db_encoding)) { - return null; - } - if (empty($language)) { - $result = self::fetch_array(self::query("SHOW COLLATION WHERE Charset = '".self::escape_string($db_encoding)."' AND `Default` = 'Yes';"), 'NUM'); - return $result ? $result[0] : null; - } - $collation = $db_encoding.'_'.$language.'_ci'; - $query_result = self::query("SHOW COLLATION WHERE Charset = '".self::escape_string($db_encoding)."';"); - while ($result = self::fetch_array($query_result, 'NUM')) { - if ($result[0] == $collation) { - return $collation; - } - } - return null; - } - - /** - * Database insert - * @param string $table_name - * @param array $attributes - * @param bool $show_query - * @return bool|int - */ - public static function insert($table_name, $attributes, $show_query = false) - { - $result = self::getManager()->getConnection()->insert($table_name, $attributes); - if ($result) { - return self::insert_id(); - } - return false; - - if (empty($attributes) || empty($table_name)) { - return false; - } - $filtred_attributes = array(); - foreach($attributes as $key => $value) { - $filtred_attributes[$key] = "'".self::escape_string($value)."'"; - } - - //@todo check if the field exists in the table we should use a describe of that table - $params = array_keys($filtred_attributes); - $values = array_values($filtred_attributes); - if (!empty($params) && !empty($values)) { - $sql = 'INSERT INTO '.$table_name.' ('.implode(',',$params).') VALUES ('.implode(',',$values).')'; - self::query($sql); - if ($show_query) { - var_dump($sql); - error_log($sql); - } - return self::insert_id(); - } - return false; - } - - /** - * Experimental useful database finder - * @todo lot of stuff to do here - * @todo known issues, it doesn't work when using LIKE conditions - * @example array('where'=> array('course_code LIKE "?%"')) - * @example array('where'=> array('type = ? AND category = ?' => array('setting', 'Plugins')) - * @example array('where'=> array('name = "Julio" AND lastname = "montoya"')) - */ - public static function select($columns, $table_name, $conditions = array(), $type_result = 'all', $option = 'ASSOC') - { - $conditions = self::parse_conditions($conditions); - - //@todo we could do a describe here to check the columns ... - if (is_array($columns)) { - $clean_columns = implode(',', $columns); - } else { - if ($columns == '*') { - $clean_columns = '*'; - } else { - $clean_columns = (string)$columns; - } - } - - $sql = "SELECT $clean_columns FROM $table_name $conditions"; - $result = self::query($sql); - $array = array(); - - if ($type_result == 'all') { - while ($row = self::fetch_array($result, $option)) { - if (isset($row['id'])) { - $array[$row['id']] = $row; - } else { - $array[] = $row; - } - } - } else { - $array = self::fetch_array($result, $option); - } - return $array; - } - - /** - * Parses WHERE/ORDER conditions i.e array('where'=>array('id = ?' =>'4'), 'order'=>'id DESC')) - * @todo known issues, it doesn't work when using - * LIKE conditions example: array('where'=>array('course_code LIKE "?%"')) - * @param array $conditions - */ - public static function parse_conditions($conditions) - { - if (empty($conditions)) { - return ''; - } - $return_value = $where_return = ''; - foreach ($conditions as $type_condition => $condition_data) { - if ($condition_data == false) { - continue; - } - $type_condition = strtolower($type_condition); - switch ($type_condition) { - case 'where': - foreach ($condition_data as $condition => $value_array) { - if (is_array($value_array)) { - $clean_values = array(); - foreach($value_array as $item) { - $item = Database::escape_string($item); - $clean_values[]= $item; - } - } else { - $value_array = Database::escape_string($value_array); - $clean_values = $value_array; - } - - if (!empty($condition) && $clean_values != '') { - $condition = str_replace('%',"'@percentage@'", $condition); //replace "%" - $condition = str_replace("'?'","%s", $condition); - $condition = str_replace("?","%s", $condition); - - $condition = str_replace("@%s@","@-@", $condition); - $condition = str_replace("%s","'%s'", $condition); - $condition = str_replace("@-@","@%s@", $condition); - - // Treat conditions as string - $condition = vsprintf($condition, $clean_values); - $condition = str_replace('@percentage@','%', $condition); //replace "%" - $where_return .= $condition; - } - } - - if (!empty($where_return)) { - $return_value = " WHERE $where_return" ; - } - break; - case 'order': - $order_array = $condition_data; - - if (!empty($order_array)) { - // 'order' => 'id desc, name desc' - $order_array = self::escape_string($order_array, null, false); - $new_order_array = explode(',', $order_array); - $temp_value = array(); - - foreach($new_order_array as $element) { - $element = explode(' ', $element); - $element = array_filter($element); - $element = array_values($element); - - if (!empty($element[1])) { - $element[1] = strtolower($element[1]); - $order = 'DESC'; - if (in_array($element[1], array('desc', 'asc'))) { - $order = $element[1]; - } - $temp_value[]= $element[0].' '.$order.' '; - } else { - //by default DESC - $temp_value[]= $element[0].' DESC '; - } - } - if (!empty($temp_value)) { - $return_value .= ' ORDER BY '.implode(', ', $temp_value); - } else { - //$return_value .= ''; - } - } - break; - case 'limit': - $limit_array = explode(',', $condition_data); - if (!empty($limit_array)) { - if (count($limit_array) > 1) { - $return_value .= ' LIMIT '.intval($limit_array[0]).' , '.intval($limit_array[1]); - } else { - $return_value .= ' LIMIT '.intval($limit_array[0]); - } - } - break; - } - } - - return $return_value; - } - - /** - * @param array $conditions - * @return string - */ - public static function parse_where_conditions($conditions) - { - return self::parse_conditions(array('where' => $conditions)); - } - - /** - * Experimental useful database update - * @todo lot of stuff to do here - */ - public static function delete($table_name, $where_conditions, $show_query = false) - { - $where_return = self::parse_where_conditions($where_conditions); - $sql = "DELETE FROM $table_name $where_return "; - if ($show_query) { echo $sql; echo '
    '; } - $result = self::query($sql); - $affected_rows = self::affected_rows($result); - //@todo should return affected_rows for - return $affected_rows; - } - - /** - * @param string $table_name use Database::get_main_table - * @param array $attributes Values to updates - * Example: $params['name'] = 'Julio'; $params['lastname'] = 'Montoya'; - * @param array $where_conditions where conditions i.e array('id = ?' =>'4') - * @param bool $show_query - * @return bool|int - */ - public static function update( - $table_name, - $attributes, - $where_conditions = array(), - $show_query = false - ) { - if (!empty($table_name) && !empty($attributes)) { - $update_sql = ''; - //Cleaning attributes - $count = 1; - foreach ($attributes as $key=>$value) { - if (!is_array($value)) { - $value = self::escape_string($value); - } - $update_sql .= "$key = '$value' "; - if ($count < count($attributes)) { - $update_sql.=', '; - } - $count++; - } - if (!empty($update_sql)) { - //Parsing and cleaning the where conditions - $where_return = self::parse_where_conditions($where_conditions); - $sql = "UPDATE $table_name SET $update_sql $where_return "; - if ($show_query) { - var_dump($sql); - } - $result = self::query($sql); - $affected_rows = self::affected_rows($result); - return $affected_rows; - } - } - return false; - } - - /** - * @return \Doctrine\ORM\Configuration - */ - public static function getDoctrineConfig() - { - $isDevMode = true; - $isSimpleMode = false; - $proxyDir = null; - $cache = null; - - $paths = array( - api_get_path(SYS_PATH).'src/Chamilo/CoreBundle/Entity', - api_get_path(SYS_PATH).'src/Chamilo/UserBundle/Entity', - api_get_path(SYS_PATH).'src/Chamilo/CourseBundle/Entity' - ); - - /*$doctrineCache = api_get_path(SYS_ARCHIVE_PATH).'doctrine/'; - - if (!is_dir($doctrineCache)) { - mkdir($doctrineCache, api_get_permissions_for_new_directories(), true); - }*/ - - return \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration( - $paths, - $isDevMode, - $proxyDir, - $cache, - $isSimpleMode - ); - } -} diff --git a/main/inc/lib/diagnoser.lib.php b/main/inc/lib/diagnoser.lib.php index 03e2de5472..c7915ac906 100755 --- a/main/inc/lib/diagnoser.lib.php +++ b/main/inc/lib/diagnoser.lib.php @@ -225,13 +225,13 @@ class Diagnoser // A note: Maybe it would be better if all "MySQL"-like variable names and words on the page to be replaced with "Database"-like ones. - $array[] = $this->build_setting(self :: STATUS_INFORMATION, '[MySQL]', 'mysql_get_host_info()', 'http://www.php.net/manual/en/function.mysql-get-host-info.php', Database::get_host_info(), null, null, get_lang('MysqlHostInfo')); - + //$array[] = $this->build_setting(self :: STATUS_INFORMATION, '[MySQL]', 'host', 'http://www.php.net/manual/en/function.mysql-get-host-info.php', Database::get_host_info(), null, null, get_lang('MysqlHostInfo')); + /* $array[] = $this->build_setting(self :: STATUS_INFORMATION, '[MySQL]', 'mysql_get_server_info()', 'http://www.php.net/manual/en/function.mysql-get-server-info.php', Database::get_server_info(), null, null, get_lang('MysqlServerInfo')); $array[] = $this->build_setting(self :: STATUS_INFORMATION, '[MySQL]', 'mysql_get_proto_info()', 'http://www.php.net/manual/en/function.mysql-get-proto-info.php', Database::get_proto_info(), null, null, get_lang('MysqlProtoInfo')); - $array[] = $this->build_setting(self :: STATUS_INFORMATION, '[MySQL]', 'mysql_get_client_info()', 'http://www.php.net/manual/en/function.mysql-get-client-info.php', Database::get_client_info(), null, null, get_lang('MysqlClientInfo')); + $array[] = $this->build_setting(self :: STATUS_INFORMATION, '[MySQL]', 'mysql_get_client_info()', 'http://www.php.net/manual/en/function.mysql-get-client-info.php', Database::get_client_info(), null, null, get_lang('MysqlClientInfo'));*/ return $array; } diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index 1a7a745c45..97aca7f17a 100755 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -745,9 +745,7 @@ class Display $size = ICON_SIZE_SMALL, $show_text = true, $return_only_path = false - ) - { - + ) { $code_path = api_get_path(SYS_CODE_PATH); $w_code_path = api_get_path(WEB_CODE_PATH); @@ -779,7 +777,8 @@ class Display // it checks if there is an SVG version. If so, it uses it. // When moving this to production, the return_icon() calls should // ask for the SVG version directly - if (Chamilo::is_test_server()) { + $testServer = api_get_setting('server_type'); + if ($testServer == 'test') { $svgImage = substr($image, 0, -3) . 'svg'; if (is_file($code_path . $theme . 'svg/' . $svgImage)) { $icon = $w_code_path . $theme . 'svg/' . $svgImage; @@ -1019,21 +1018,36 @@ class Display $lis = ''; $i = 1; foreach ($header_list as $item) { - $item =self::tag('a', $item, array('href'=>'#'.$id.'-'.$i)); - $lis .=self::tag('li', $item, $ul_attributes); + $active = ''; + if ($i == 1) { + $active = ' active'; + } + $item = self::tag('a', $item, array('href'=>'#'.$id.'-'.$i, 'role'=> 'tab')); + $ul_attributes['data-toggle'] = 'tab'; + $ul_attributes['role'] = 'presentation'; + $ul_attributes['class'] = $active; + $lis .= self::tag('li', $item, $ul_attributes); $i++; } - $ul = self::tag('ul',$lis); + $ul = self::tag('ul', $lis, ['class' => 'nav nav-tabs', 'role'=> 'tablist']); $i = 1; $divs = ''; foreach ($content_list as $content) { - $content = self::tag('p',$content); - $divs .=self::tag('div', $content, array('id'=>$id.'-'.$i)); + $active = ''; + if ($i == 1) { + $active = ' active'; + } + $divs .= self::tag('div', $content, array('id'=> $id.'-'.$i, 'class' => 'tab-pane '.$active, 'role' => 'tabpanel')); $i++; } + $attributes['id'] = $id; - $main_div = self::tag('div',$ul.$divs, $attributes); + $attributes['role'] = 'tabpanel'; + $attributes['class'] = 'tab-wrapper'; + + $main_div = self::tag('div', $ul.self::tag('div', $divs, ['class' => 'tab-content']), $attributes); + return $main_div ; } @@ -1359,7 +1373,7 @@ class Display // Special hack for work tool, which is called student_publication in c_tool and work in c_item_property :-/ BT#7104 " AND (ctt.name = tet.tool OR (ctt.name = 'student_publication' AND tet.tool = 'work')) ". " AND ctt.visibility = '1' ". - " AND tet.lastedit_user_id != $user_id AND tet.id_session = '".$course_info['id_session']."' + " AND tet.lastedit_user_id != $user_id AND tet.session_id = '".$course_info['id_session']."' ORDER BY tet.lastedit_date"; $res = Database::query($sql); @@ -1404,7 +1418,7 @@ class Display } // If it's a survey, make sure the user's invited. Otherwise drop it. if ($item_property['tool'] == TOOL_SURVEY) { - $survey_info = survey_manager::get_survey($item_property['ref'], 0, $course_code); + $survey_info = SurveyManager::get_survey($item_property['ref'], 0, $course_code); if (!empty($survey_info)) { $invited_users = SurveyUtil::get_invited_users( $survey_info['code'], diff --git a/main/inc/lib/document.class.php b/main/inc/lib/document.class.php deleted file mode 100755 index d10ef9ef94..0000000000 --- a/main/inc/lib/document.class.php +++ /dev/null @@ -1,302 +0,0 @@ - for the Univesity of Geneva - */ -class Document -{ - - /** - * - * @param string $where - * @return \ResultSet - */ - public static function query($where) - { - $table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); - $table_document = Database::get_course_table(TABLE_DOCUMENT); - $tool = TOOL_DOCUMENT; - - $sql = "SELECT doc.*, - prop.id AS property_id, - prop.tool, - prop.insert_user_id, - prop.insert_date, - prop.lastedit_date, - prop.ref, - prop.lastedit_type, - prop.lastedit_user_id, - prop.to_group_id, - prop.to_user_id, - prop.visibility, - prop.start_visible, - prop.end_visible, - prop.id_session - FROM - $table_document AS doc, - $table_item_property AS prop - WHERE - (doc.id = prop.ref AND - doc.c_id = prop.c_id AND - prop.tool = '$tool')"; - - $sql .= $where ? "AND ($where)" : ''; - $result = new ResultSet($sql); - return $result->return_type(__CLASS__); - } - - /** - * - * @param int|Course $c_id - * @param int $id - * @return \Model\Document - */ - public static function get_by_id($c_id, $id) - { - $c_id = is_object($c_id) ? $c_id->get_id() : (int) $c_id; - return self::query("doc.c_id = $c_id AND doc.id = $id")->first(); - } - - /** - * - * @param int|Course $c_id - * @param int $id - * @return \Model\Document - */ - public static function get_by_path($c_id, $path) - { - $c_id = is_object($c_id) ? $c_id->get_id() : (int) $c_id; - return self::query("doc.c_id = $c_id AND doc.path = '$path'")->first(); - } - - protected $c_id = 0; - protected $id = 0; - protected $path = ''; - protected $comment = ''; - protected $title = ''; - protected $filetype = ''; - protected $size = 0; - protected $readonly = false; - protected $session_id = 0; - protected $course = null; - protected $item_property = null; - - public function __construct($data) - { - $data = (object) $data; - $this->c_id = (int) $data->c_id; - $this->id = (int) $data->id; - $this->path = $data->path; - $this->comment = $data->comment; - $this->title = $data->title; - $this->filetype = $data->filetype; - $this->size = (int) $data->size; - $this->readonly = (bool) $data->readonly; - $this->session_id = (int) $data->session_id; - - $this->course = null; - - if (isset($data->property_id)) { - $property = (array) $data; - $property = (object) $property; - $property->id = $property->property_id; - $this->item_property = ItemProperty::create($property); - } else { - $this->item_property = null; - } - } - - public function get_c_id() - { - return $this->c_id; - } - - public function set_c_id($value) - { - $this->c_id = (int) $value; - $this->course = null; - $this->item_property = null; - } - - public function get_id() - { - return $this->id; - } - - public function set_id($value) - { - $this->id = (int) $value; - $this->item_property = null; - } - - public function get_path() - { - return $this->path; - } - - public function set_path($value) - { - $this->path = $value; - } - - public function get_comment() - { - return $this->comment; - } - - public function set_comment($value) - { - $this->comment = $value; - } - - public function get_title() - { - return $this->title; - } - - public function set_title($value) - { - $this->title = $value; - } - - public function get_filetype() - { - return $this->filetype; - } - - public function set_filetype($value) - { - $this->filetype = $value; - } - - public function get_size() - { - return $this->size; - } - - public function set_size($value) - { - $this->size = (int) $value; - } - - public function get_readonly() - { - return $this->readonly; - } - - public function set_readonly($value) - { - $this->readonly = (bool) $value; - } - - public function get_session_id() - { - return $this->session_id; - } - - public function set_session_id($value) - { - $this->session_id = (int) $value; - } - - public function is_folder() - { - return $this->filetype == 'folder'; - } - - public function is_file() - { - return $this->filetype == 'file'; - } - - public function is_visible() - { - $this->get_item_property()->get_visibility() == 1; - } - - public function is_accessible() - { - return api_is_allowed_to_edit() || $this->is_visible(); - } - - /** - * - * @return \Model\Course - */ - public function get_course() - { - if ($this->course && $this->course->get_id() == $this->c_id) { - return $this->course; - } - - $this->course = Course::get_by_id($this->c_id); - return $this->course; - } - - /** - * - * @return \Model\ItemProperty - */ - public function get_item_property() - { - if ($this->item_property && $this->item_property->get_c_id() == $this->c_id && $this->item_property->get_ref() == $this->id) { - return $this->item_property; - } - - $this->item_property = ItemProperty::get_by_ref($this->id, TOOL_DOCUMENT); - return $this->item_property; - } - - public function get_absolute_path() - { - $course = $this->get_course(); - return $course->get_path() . 'document' . $this->path; - } - - public function __toString() - { - return $this->get_absolute_path(); - } - - /** - * - * @param bool $all - * @return ResultSet|array - */ - public function get_children($all = false) - { - if (!$this->is_folder()) { - return array(); - } - $path = $this->path; - $c_id = $this->c_id; - if ($this->all) { - $where = "doc.c_id = $c_id AND doc.path LIKE '$path/%'"; - } else { - $where = "doc.c_id = $c_id AND doc.path LIKE '$path/%' AND doc.path NOT LIKE '$path/%/%'"; - } - return self::query($where); - } - -} \ No newline at end of file diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 7afbcbdefd..dee4b68d80 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -541,7 +541,7 @@ class DocumentManager // Condition for the session $sessionId = api_get_session_id(); - $condition_session = " AND (id_session = '$sessionId' OR (id_session = '0') )"; + $condition_session = " AND (last.session_id = '$sessionId' OR (last.session_id = '0') )"; $condition_session .= self::getSessionFolderFilters($originalPath, $sessionId); $sharedCondition = null; @@ -565,7 +565,7 @@ class DocumentManager docs.size, docs.readonly, docs.session_id, - last.id_session item_property_session_id, + last.session_id item_property_session_id, last.lastedit_date, last.visibility, last.insert_user_id @@ -739,7 +739,7 @@ class DocumentManager if ($can_see_invisible) { // condition for the session $session_id = api_get_session_id(); - $condition_session = api_get_session_condition($session_id); + $condition_session = api_get_session_condition($session_id, true, false, 'docs.session_id'); $show_users_condition = ""; if (api_get_setting('show_users_folders') == 'false') { $show_users_condition = " AND docs.path NOT LIKE '%shared_folder%'"; @@ -760,7 +760,8 @@ class DocumentManager last.to_group_id = " . $to_group_id . " AND docs.path NOT LIKE '%shared_folder%' AND docs.path NOT LIKE '%_DELETED_%' AND - last.visibility <> 2 $condition_session "; + last.visibility <> 2 + $condition_session "; } else { $sql = "SELECT DISTINCT docs.id, path FROM $TABLE_ITEMPROPERTY AS last @@ -806,7 +807,7 @@ class DocumentManager // No invisible folders // Condition for the session $session_id = api_get_session_id(); - $condition_session = api_get_session_condition($session_id); + $condition_session = api_get_session_condition($session_id, true, false, 'docs.session_id'); //get visible folders $sql = "SELECT DISTINCT docs.id, path FROM @@ -816,7 +817,8 @@ class DocumentManager docs.filetype = 'folder' AND last.tool = '" . TOOL_DOCUMENT . "' AND last.to_group_id = " . $to_group_id . " AND - last.visibility = 1 $condition_session AND + last.visibility = 1 + $condition_session AND last.c_id = {$_course['real_id']} AND docs.c_id = {$_course['real_id']} "; $result = Database::query($sql); @@ -827,7 +829,7 @@ class DocumentManager // Condition for the session $session_id = api_get_session_id(); - $condition_session = api_get_session_condition($session_id); + $condition_session = api_get_session_condition($session_id, true, false, 'docs.session_id'); //get invisible folders $sql = "SELECT DISTINCT docs.id, path FROM $TABLE_ITEMPROPERTY AS last, $TABLE_DOCUMENT AS docs @@ -844,7 +846,7 @@ class DocumentManager while ($row = Database::fetch_array($result, 'ASSOC')) { //condition for the session $session_id = api_get_session_id(); - $condition_session = api_get_session_condition($session_id); + $condition_session = api_get_session_condition($session_id, true, false, 'docs.session_id'); //get visible folders in the invisible ones -> they are invisible too $sql = "SELECT DISTINCT docs.id, path FROM $TABLE_ITEMPROPERTY AS last, $TABLE_DOCUMENT AS docs @@ -1044,25 +1046,9 @@ class DocumentManager $sql = "DELETE FROM $TABLE_DOCUMENT WHERE c_id = {$course_info['real_id']} AND id = ".$document_id; Database::query($sql); - self::delete_document_metadata($document_id); } } - /** - * @param int $document_id - */ - public static function delete_document_metadata($document_id) - { - // needed to deleted medadata - require_once api_get_path(SYS_CODE_PATH) . 'metadata/md_funcs.php'; - $mdStore = new mdstore(true); - - //delete metadata - $eid = 'Document' . '.' . $document_id; - $mdStore->mds_delete($eid); - $mdStore->mds_delete_offspring($eid); - } - /** * This deletes a document by changing visibility to 2, renaming it to filename_DELETED_#id * Files/folders that are inside a deleted folder get visibility 2 @@ -1527,7 +1513,7 @@ class DocumentManager //note the extra / at the end of doc_path to match every path in the document table that is part of the document path $session_id = intval($session_id); - $condition = "AND id_session IN ('$session_id', '0') "; + $condition = "AND d.session_id IN ('$session_id', '0') "; // The " d.filetype='file' " let the user see a file even if the folder is hidden see #2198 /* @@ -1639,7 +1625,7 @@ class DocumentManager } else { $user_status = SessionManager::get_user_status_in_course_session( $user_id, - $course_info['code'], + $course_info['real_id'], $session_id ); @@ -1825,7 +1811,7 @@ class DocumentManager $official_code = $user_info['official_code']; //Teacher information - $info_teacher_id = UserManager::get_user_id_of_course_admin_or_session_admin($course_id); + $info_teacher_id = UserManager::get_user_id_of_course_admin_or_session_admin($course_info); $teacher_info = api_get_user_info($info_teacher_id); $teacher_first_name = $teacher_info['firstname']; $teacher_last_name = $teacher_info['lastname']; @@ -2549,6 +2535,7 @@ class DocumentManager } } } + return $content_html; } @@ -2940,7 +2927,7 @@ class DocumentManager if (isset($session_id)) { $session_id = intval($session_id); - $session_condition = " AND props.id_session='" . $session_id . "' "; + $session_condition = " AND props.session_id='" . $session_id . "' "; } $sql = "SELECT SUM(size) @@ -3198,7 +3185,7 @@ class DocumentManager $overwrite_url = null, $showInvisibleFiles = false, $showOnlyFolders = false, - $folderId = 0 + $folderId = false ) { if (empty($course_info['real_id']) || empty($course_info['code']) || !is_array($course_info)) { return ''; @@ -3231,7 +3218,11 @@ class DocumentManager $user_in_course = true; } } else { - $user_status = SessionManager::get_user_status_in_course_session($user_id, $course_info['code'], $session_id); + $user_status = SessionManager::get_user_status_in_course_session( + $user_id, + $course_info['real_id'], + $session_id + ); //is true if is an student, course session teacher or coach if (in_array($user_status, array('0', '2', '6'))) { $user_in_course = true; @@ -3241,7 +3232,7 @@ class DocumentManager $tbl_doc = Database::get_course_table(TABLE_DOCUMENT); $tbl_item_prop = Database::get_course_table(TABLE_ITEM_PROPERTY); - $condition_session = " AND (id_session = '$session_id' OR id_session = '0' )"; + $condition_session = " AND (last.session_id = '$session_id' OR last.session_id = '0' )"; $add_folder_filter = null; if (!empty($filter_by_folder)) { @@ -3271,7 +3262,8 @@ class DocumentManager } } - if ($folderId !== 0) { + $parentData = []; + if ($folderId !== false) { $parentData = self::get_document_data_by_id($folderId, $course_info['code']); if (!empty($parentData)) { $cleanedPath = $parentData['path']; @@ -3295,7 +3287,6 @@ class DocumentManager } $levelCondition = null; - if ($folderId === false) { $levelCondition = " AND docs.path NOT LIKE'/%/%'"; } @@ -3344,6 +3335,7 @@ class DocumentManager // If you want to debug it, I advise you to do "echo" on the eval statements. $newResources = array(); + if (!empty($resources) && $user_in_course) { foreach ($resources as $resource) { $is_visible = self::is_visible_by_id( @@ -3361,16 +3353,20 @@ class DocumentManager } $label = get_lang('Documents'); + + $documents = []; if ($folderId === false) { $documents[$label] = array( 'id' => 0, 'files' => $newResources ); } else { - $documents[$parentData['title']] = array( - 'id' => intval($folderId), - 'files' => $newResources - ); + if (!empty($parentData)) { + $documents[$parentData['title']] = array( + 'id' => intval($folderId), + 'files' => $newResources + ); + } } $write_result = self::write_resources_tree( @@ -3628,7 +3624,6 @@ class DocumentManager } $return .= ''; - $return .= ' '; $return .= ''.$title.''; $return .= ''; @@ -4251,7 +4246,7 @@ class DocumentManager */ public static function updateVisibilityFromAllSessions($courseInfo, $id, $visibility, $userId) { - $sessionList = SessionManager::get_session_by_course($courseInfo['code']); + $sessionList = SessionManager::get_session_by_course($courseInfo['real_id']); if (!empty($sessionList)) { foreach ($sessionList as $session) { @@ -5753,24 +5748,6 @@ class DocumentManager return $path_displayed; } - /** - * This function displays the name of the user and makes the link tothe user tool. - * - * @param $user_id - * @param $name - * @return a link to the userInfo.php - * @author Patrick Cool , Ghent University - * @version february 2006, dokeos 1.8 - */ - public static function display_user_link_document($user_id, $name) - { - if ($user_id != 0) { - return '' . $name . ''; - } else { - return get_lang('Anonymous'); - } - } - /** * Creates form that asks for the directory name. * @return string html-output text for the form @@ -5778,15 +5755,16 @@ class DocumentManager public static function create_dir_form($dirId) { global $document_id; - $form = new FormValidator('create_dir_form', 'post', api_get_self().'?'.api_get_cidreq(), '', null, false); + $form = new FormValidator('create_dir_form', 'post', api_get_self().'?'.api_get_cidreq()); $form->addElement('hidden', 'create_dir', 1); $form->addElement('hidden', 'dir_id', intval($document_id)); $form->addElement('hidden', 'id', intval($dirId)); - $form->addElement('header', '', get_lang('CreateDir')); - $form->addElement('text', 'dirname', get_lang('NewDir'), array('autofocus' => 'autofocus')); - $form->addButtonCreate(get_lang('CreateFolder'), 'submit'); - $new_folder_text = $form->returnForm(); - return $new_folder_text; + $form->addElement('header', get_lang('CreateDir')); + $form->addText('dirname', get_lang('NewDir'), array('autofocus' => 'autofocus')); + $form->addButtonCreate(get_lang('CreateFolder')); + + return $form->returnForm(); + } /** diff --git a/main/inc/lib/elfinder/templates.php b/main/inc/lib/elfinder/templates.php index 8e970c0d17..20d7568c6b 100644 --- a/main/inc/lib/elfinder/templates.php +++ b/main/inc/lib/elfinder/templates.php @@ -11,7 +11,9 @@ $table = Database::get_main_table(TABLE_MAIN_SYSTEM_TEMPLATE); $sql = "SELECT * FROM $table"; $result = Database::query($sql); $templates = Database::store_result($result, 'ASSOC'); -$editor = new CkEditor(); -$templates = $editor->simpleFormatTemplates($templates); -$template->assign('templates', $templates); -$template->display('default/javascript/editor/ckeditor/templates.tpl'); +if (!empty($templates)) { + $editor = new CkEditor(); + $templates = $editor->simpleFormatTemplates($templates); + $template->assign('templates', $templates); + $template->display('default/javascript/editor/ckeditor/templates.tpl'); +} diff --git a/main/inc/lib/entity.class.php b/main/inc/lib/entity.class.php deleted file mode 100755 index 43b0645b9f..0000000000 --- a/main/inc/lib/entity.class.php +++ /dev/null @@ -1,100 +0,0 @@ - for the Univesity of Geneva - */ -class Entity -{ - - /** - * - * @return \Entity\Course - */ - public static function current_course() - { - static $result = false; - if ($result === false) { - $repo = \Entity\Course::repository(); - $course_id = api_get_course_int_id(); - if ($course_id) { - $result = $repo->find($course_id); - } - } - return $result; - } - - /** - * - * @return \Entity\Session - */ - public static function current_session() - { - static $result = false; - if ($result === false) { - $repo = \Entity\Session::repository(); - $session_id = api_get_session_id(); - $result = $repo->find($session_id); - } - return $result; - } - - function __construct($data = null) - { - if ($data) { - foreach ($this as $key => $value) { - if (isset($data->{$key})) { - $this->{$key} = $data->{$key}; - } - } - } - $this->defaults('session_id', api_get_session_id()); - } - - function __get($name) - { - $f = array($this, "get_$name"); - return call_user_func($f); - } - - function __isset($name) - { - $f = array($this, "get_$name"); - return is_callable($f); - } - - function __set($name, $value) - { - $f = array($this, "set_$name"); - if (!is_callable($f)) { - return; - } - call_user_func($f, $value); - } - - function before_save() - { - $repo = $this->repository(); - $field = $repo->get_id_field(); - if (empty($field)) { - return; - } - - $value = isset($this->{$field}) ? $this->{$field} : null; - if ($value) { - return; - } - $next_id = $repo->next_id($this); - $this->{$field} = $next_id; - } - - function defaults($name, $value) - { - if (property_exists($this, $name) && empty($this->{$name})) { - $this->{$name} = $value; - } - } - -} \ No newline at end of file diff --git a/main/inc/lib/entity_repository.class.php b/main/inc/lib/entity_repository.class.php deleted file mode 100755 index 21f17d1eb4..0000000000 --- a/main/inc/lib/entity_repository.class.php +++ /dev/null @@ -1,83 +0,0 @@ - for the Univesity of Geneva - */ -class EntityRepository extends Doctrine\ORM\EntityRepository -{ - - function next_id($entity = null) - { - $column = $this->get_id_field(); - if (empty($column)) { - return false; - } - - $metadata = $this->getClassMetadata(); - $entity_name = $metadata->name; - - if ($this->is_course_table()) { - $course = $entity ? $entity->get_c_id() : Entity::current_course(); - $course = $course ? $course : Entity::current_course(); - $c_id = is_object($course) ? $course->get_id() : $course; - if (empty($c_id)) { - return null; - } - - $query = new QueryBuilder($this->getEntityManager()); - $query = $query->select("MAX(t.id) AS m")->from($entity_name, 't')->where('t.c_id = ' . $c_id); - } else { - $query = new QueryBuilder($this->getEntityManager()); - $query = $query->select("MAX(t.$column) AS m")->from($entity_name, 't'); - } - $result = $this->getEntityManager()->createQuery($query); - $result = $result->getSingleScalarResult(); - $result += 10; //in case somebody does an insert in between - return $result; - } - - /** - * - * @return string|bool - */ - function get_id_field() - { - $metadata = $this->getClassMetadata(); - if (count($metadata->identifier) == 1) { - $field = $metadata->identifier[0]; - return $field; - } - if (count($metadata->identifier) > 2) { - return false; - } - - if (isset($metadata->identifier['id'])) { - return 'id'; - } - - if (!$this->is_course_table()) { - return false; - } - - - foreach ($metadata->identifier as $field) { - if ($field != 'c_id' && $field != 'course') { - return $field; - } - } - return false; - } - - function is_course_table() - { - $metadata = $this->getClassMetadata(); - $table = $metadata->table['name']; - return strpos($table, 'c_') === 0; - } - -} \ No newline at end of file diff --git a/main/inc/lib/evalmath.class.php b/main/inc/lib/evalmath.class.php deleted file mode 100644 index 1ea18bbed8..0000000000 --- a/main/inc/lib/evalmath.class.php +++ /dev/null @@ -1,390 +0,0 @@ - - -================================================================================ - -NAME - EvalMath - safely evaluate math expressions - -SYNOPSIS - evaluate('2+2'); - // supports: order of operation; parentheses; negation; built-in functions - $result = $m->evaluate('-8(5/2)^2*(1-sqrt(4))-8'); - // create your own variables - $m->evaluate('a = e^(ln(pi))'); - // or functions - $m->evaluate('f(x,y) = x^2 + y^2 - 2x*y + 1'); - // and then use them - $result = $m->evaluate('3*f(42,a)'); - ?> - -DESCRIPTION - Use the EvalMath class when you want to evaluate mathematical expressions - from untrusted sources. You can define your own variables and functions, - which are stored in the object. Try it, it's fun! - -METHODS - $m->evalute($expr) - Evaluates the expression and returns the result. If an error occurs, - prints a warning and returns false. If $expr is a function assignment, - returns true on success. - - $m->e($expr) - A synonym for $m->evaluate(). - - $m->vars() - Returns an associative array of all user-defined variables and values. - - $m->funcs() - Returns an array of all user-defined functions. - -PARAMETERS - $m->suppress_errors - Set to true to turn off warnings when evaluating expressions - - $m->last_error - If the last evaluation failed, contains a string describing the error. - (Useful when suppress_errors is on). - -AUTHOR INFORMATION - Copyright 2005, Miles Kaufmann. - -LICENSE - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1 Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written - permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -*/ - -class EvalMath { - - var $suppress_errors = false; - var $last_error = null; - - var $v = array('e'=>2.71,'pi'=>3.14); // variables (and constants) - var $f = array(); // user-defined functions - var $vb = array('e', 'pi'); // constants - var $fb = array( // built-in functions - 'sin','sinh','arcsin','asin','arcsinh','asinh', - 'cos','cosh','arccos','acos','arccosh','acosh', - 'tan','tanh','arctan','atan','arctanh','atanh', - 'sqrt','abs','ln','log'); - - function EvalMath() { - // make the variables a little more accurate - $this->v['pi'] = pi(); - $this->v['e'] = exp(1); - } - - function e($expr) { - return $this->evaluate($expr); - } - - function evaluate($expr) { - $this->last_error = null; - $expr = trim($expr); - if (substr($expr, -1, 1) == ';') $expr = substr($expr, 0, strlen($expr)-1); // strip semicolons at the end - //=============== - // is it a variable assignment? - if (preg_match('/^\s*([a-z]\w*)\s*=\s*(.+)$/', $expr, $matches)) { - if (in_array($matches[1], $this->vb)) { // make sure we're not assigning to a constant - return $this->trigger("cannot assign to constant '$matches[1]'"); - } - if (($tmp = $this->pfx($this->nfx($matches[2]))) === false) return false; // get the result and make sure it's good - $this->v[$matches[1]] = $tmp; // if so, stick it in the variable array - return $this->v[$matches[1]]; // and return the resulting value - //=============== - // is it a function assignment? - } elseif (preg_match('/^\s*([a-z]\w*)\s*\(\s*([a-z]\w*(?:\s*,\s*[a-z]\w*)*)\s*\)\s*=\s*(.+)$/', $expr, $matches)) { - $fnn = $matches[1]; // get the function name - if (in_array($matches[1], $this->fb)) { // make sure it isn't built in - return $this->trigger("cannot redefine built-in function '$matches[1]()'"); - } - $args = explode(",", preg_replace("/\s+/", "", $matches[2])); // get the arguments - if (($stack = $this->nfx($matches[3])) === false) return false; // see if it can be converted to postfix - for ($i = 0; $iv)) { - $stack[$i] = $this->v[$token]; - } else { - return $this->trigger("undefined variable '$token' in function definition"); - } - } - } - $this->f[$fnn] = array('args'=>$args, 'func'=>$stack); - return true; - //=============== - } else { - return $this->pfx($this->nfx($expr)); // straight up evaluation, woo - } - } - - function vars() { - $output = $this->v; - unset($output['pi']); - unset($output['e']); - return $output; - } - - function funcs() { - $output = array(); - foreach ($this->f as $fnn=>$dat) - $output[] = $fnn . '(' . implode(',', $dat['args']) . ')'; - return $output; - } - - //===================== HERE BE INTERNAL METHODS ====================\\ - - // Convert infix to postfix notation - function nfx($expr) { - - $index = 0; - $stack = new EvalMathStack; - $output = array(); // postfix form of expression, to be passed to pfx() - $expr = trim(strtolower($expr)); - - $ops = array('+', '-', '*', '/', '^', '_'); - $ops_r = array('+'=>0,'-'=>0,'*'=>0,'/'=>0,'^'=>1); // right-associative operator? - $ops_p = array('+'=>0,'-'=>0,'*'=>1,'/'=>1,'_'=>1,'^'=>2); // operator precedence - - $expecting_op = false; // we use this in syntax-checking the expression - // and determining when a - is a negation - - if (preg_match("/[^\w\s+*^\/()\.,-]/", $expr, $matches)) { // make sure the characters are all good - return $this->trigger("illegal character '{$matches[0]}'"); - } - - while(1) { // 1 Infinite Loop ;) - $op = substr($expr, $index, 1); // get the first character at the current index - // find out if we're currently at the beginning of a number/variable/function/parenthesis/operand - $ex = preg_match('/^([a-z]\w*\(?|\d+(?:\.\d*)?|\.\d+|\()/', substr($expr, $index), $match); - //=============== - if ($op == '-' and !$expecting_op) { // is it a negation instead of a minus? - $stack->push('_'); // put a negation on the stack - $index++; - } elseif ($op == '_') { // we have to explicitly deny this, because it's legal on the stack - return $this->trigger("illegal character '_'"); // but not in the input expression - //=============== - } elseif ((in_array($op, $ops) or $ex) and $expecting_op) { // are we putting an operator on the stack? - if ($ex) { // are we expecting an operator but have a number/variable/function/opening parethesis? - $op = '*'; $index--; // it's an implicit multiplication - } - // heart of the algorithm: - while($stack->count > 0 and ($o2 = $stack->last()) and in_array($o2, $ops) and ($ops_r[$op] ? $ops_p[$op] < $ops_p[$o2] : $ops_p[$op] <= $ops_p[$o2])) { - $output[] = $stack->pop(); // pop stuff off the stack into the output - } - // many thanks: http://en.wikipedia.org/wiki/Reverse_Polish_notation#The_algorithm_in_detail - $stack->push($op); // finally put OUR operator onto the stack - $index++; - $expecting_op = false; - //=============== - } elseif ($op == ')' and $expecting_op) { // ready to close a parenthesis? - while (($o2 = $stack->pop()) != '(') { // pop off the stack back to the last ( - if (is_null($o2)) return $this->trigger("unexpected ')'"); - else $output[] = $o2; - } - if (preg_match("/^([a-z]\w*)\($/", $stack->last(2), $matches)) { // did we just close a function? - $fnn = $matches[1]; // get the function name - $arg_count = $stack->pop(); // see how many arguments there were (cleverly stored on the stack, thank you) - $output[] = $stack->pop(); // pop the function and push onto the output - if (in_array($fnn, $this->fb)) { // check the argument count - if($arg_count > 1) - return $this->trigger("too many arguments ($arg_count given, 1 expected)"); - } elseif (array_key_exists($fnn, $this->f)) { - if ($arg_count != count($this->f[$fnn]['args'])) - return $this->trigger("wrong number of arguments ($arg_count given, " . count($this->f[$fnn]['args']) . " expected)"); - } else { // did we somehow push a non-function on the stack? this should never happen - return $this->trigger("internal error"); - } - } - $index++; - //=============== - } elseif ($op == ',' and $expecting_op) { // did we just finish a function argument? - while (($o2 = $stack->pop()) != '(') { - if (is_null($o2)) return $this->trigger("unexpected ','"); // oops, never had a ( - else $output[] = $o2; // pop the argument expression stuff and push onto the output - } - // make sure there was a function - if (!preg_match("/^([a-z]\w*)\($/", $stack->last(2), $matches)) - return $this->trigger("unexpected ','"); - $stack->push($stack->pop()+1); // increment the argument count - $stack->push('('); // put the ( back on, we'll need to pop back to it again - $index++; - $expecting_op = false; - //=============== - } elseif ($op == '(' and !$expecting_op) { - $stack->push('('); // that was easy - $index++; - $allow_neg = true; - //=============== - } elseif ($ex and !$expecting_op) { // do we now have a function/variable/number? - $expecting_op = true; - $val = $match[1]; - if (preg_match("/^([a-z]\w*)\($/", $val, $matches)) { // may be func, or variable w/ implicit multiplication against parentheses... - if (in_array($matches[1], $this->fb) or array_key_exists($matches[1], $this->f)) { // it's a func - $stack->push($val); - $stack->push(1); - $stack->push('('); - $expecting_op = false; - } else { // it's a var w/ implicit multiplication - $val = $matches[1]; - $output[] = $val; - } - } else { // it's a plain old var or num - $output[] = $val; - } - $index += strlen($val); - //=============== - } elseif ($op == ')') { // miscellaneous error checking - return $this->trigger("unexpected ')'"); - } elseif (in_array($op, $ops) and !$expecting_op) { - return $this->trigger("unexpected operator '$op'"); - } else { // I don't even want to know what you did to get here - return $this->trigger("an unexpected error occured"); - } - if ($index == strlen($expr)) { - if (in_array($op, $ops)) { // did we end with an operator? bad. - return $this->trigger("operator '$op' lacks operand"); - } else { - break; - } - } - while (substr($expr, $index, 1) == ' ') { // step the index past whitespace (pretty much turns whitespace - $index++; // into implicit multiplication if no operator is there) - } - - } - while (!is_null($op = $stack->pop())) { // pop everything off the stack and push onto output - if ($op == '(') return $this->trigger("expecting ')'"); // if there are (s on the stack, ()s were unbalanced - $output[] = $op; - } - return $output; - } - - // evaluate postfix notation - function pfx($tokens, $vars = array()) { - - if ($tokens == false) return false; - - $stack = new EvalMathStack; - - foreach ($tokens as $token) { // nice and easy - // if the token is a binary operator, pop two values off the stack, do the operation, and push the result back on - if (in_array($token, array('+', '-', '*', '/', '^'))) { - if (is_null($op2 = $stack->pop())) return $this->trigger("internal error"); - if (is_null($op1 = $stack->pop())) return $this->trigger("internal error"); - switch ($token) { - case '+': - $stack->push($op1+$op2); break; - case '-': - $stack->push($op1-$op2); break; - case '*': - $stack->push($op1*$op2); break; - case '/': - if ($op2 == 0) return $this->trigger("division by zero"); - $stack->push($op1/$op2); break; - case '^': - $stack->push(pow($op1, $op2)); break; - } - // if the token is a unary operator, pop one value off the stack, do the operation, and push it back on - } elseif ($token == "_") { - $stack->push(-1*$stack->pop()); - // if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on - } elseif (preg_match("/^([a-z]\w*)\($/", $token, $matches)) { // it's a function! - $fnn = $matches[1]; - if (in_array($fnn, $this->fb)) { // built-in function: - if (is_null($op1 = $stack->pop())) return $this->trigger("internal error"); - $fnn = preg_replace("/^arc/", "a", $fnn); // for the 'arc' trig synonyms - if ($fnn == 'ln') $fnn = 'log'; - eval('$stack->push(' . $fnn . '($op1));'); // perfectly safe eval() - } elseif (array_key_exists($fnn, $this->f)) { // user function - // get args - $args = array(); - for ($i = count($this->f[$fnn]['args'])-1; $i >= 0; $i--) { - if (is_null($args[$this->f[$fnn]['args'][$i]] = $stack->pop())) return $this->trigger("internal error"); - } - $stack->push($this->pfx($this->f[$fnn]['func'], $args)); // yay... recursion!!!! - } - // if the token is a number or variable, push it on the stack - } else { - if (is_numeric($token)) { - $stack->push($token); - } elseif (array_key_exists($token, $this->v)) { - $stack->push($this->v[$token]); - } elseif (array_key_exists($token, $vars)) { - $stack->push($vars[$token]); - } else { - return $this->trigger("undefined variable '$token'"); - } - } - } - // when we're out of tokens, the stack should have a single element, the final result - if ($stack->count != 1) return $this->trigger("internal error"); - return $stack->pop(); - } - - // trigger an error, but nicely, if need be - function trigger($msg) { - $this->last_error = $msg; - if (!$this->suppress_errors) trigger_error($msg, E_USER_WARNING); - return false; - } -} - -// for internal use -class EvalMathStack { - - var $stack = array(); - var $count = 0; - - function push($val) { - $this->stack[$this->count] = $val; - $this->count++; - } - - function pop() { - if ($this->count > 0) { - $this->count--; - return $this->stack[$this->count]; - } - return null; - } - - function last($n=1) { - if (isset($this->stack[$this->count-$n])) { - return $this->stack[$this->count-$n]; - } - return; - } -} diff --git a/main/inc/lib/exercise.lib.php b/main/inc/lib/exercise.lib.php index 688ccc56f1..e8e56556b3 100644 --- a/main/inc/lib/exercise.lib.php +++ b/main/inc/lib/exercise.lib.php @@ -38,8 +38,7 @@ class ExerciseLib $show_comment = false, $exercise_feedback = null, $show_answers = false - ) - { + ) { // Change false to true in the following line to enable answer hinting $debug_mark_answer = $show_answers; @@ -63,7 +62,7 @@ class ExerciseLib if (!$only_questions) { $questionDescription = $objQuestionTmp->selectDescription(); if ($show_title) { - Testcategory::displayCategoryAndTitle($objQuestionTmp->id); + TestCategory::displayCategoryAndTitle($objQuestionTmp->id); echo Display::div( $current_item . '. ' . $objQuestionTmp->selectTitle(), array('class' => 'question_title') @@ -77,10 +76,8 @@ class ExerciseLib } } - if (in_array( - $answerType, - array(FREE_ANSWER, ORAL_EXPRESSION) - ) && $freeze + if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION)) && + $freeze ) { return ''; } @@ -160,7 +157,7 @@ class ExerciseLib ); $form->addHtmlEditor("choice[" . $questionId . "]", null, false, false, $config); $form->setDefaults(array("choice[" . $questionId . "]" => $fck_content)); - $s .= $form->return_form(); + $s .= $form->returnForm(); } elseif ($answerType == ORAL_EXPRESSION) { // Add nanog if (api_get_setting('enable_nanogong') == 'true') { @@ -624,7 +621,7 @@ class ExerciseLib ); $size = strlen($student_item); - $attributes['class'] = detectInputAppropriateClass( + $attributes['class'] = self::detectInputAppropriateClass( $size ); @@ -643,7 +640,7 @@ class ExerciseLib // every [xxx] are replaced with an empty input field foreach ($correct_answer_list[0] as $item) { $size = strlen($item); - $attributes['class'] = detectInputAppropriateClass( + $attributes['class'] = self::detectInputAppropriateClass( $size ); $answer = str_replace( @@ -769,7 +766,7 @@ class ExerciseLib api_strlen($studentItem) - 2 ); $size = strlen($studentItem); - $attributes['class'] = detectInputAppropriateClass( + $attributes['class'] = self::detectInputAppropriateClass( $size ); @@ -788,7 +785,7 @@ class ExerciseLib // every [xxx] are replaced with an empty input field foreach ($correctAnswerList[0] as $item) { $size = strlen($item); - $attributes['class'] = detectInputAppropriateClass( + $attributes['class'] = self::detectInputAppropriateClass( $size ); $answer = str_replace( @@ -970,7 +967,7 @@ class ExerciseLib if (!$only_questions) { if ($show_title) { - Testcategory::displayCategoryAndTitle($objQuestionTmp->id); + TestCategory::displayCategoryAndTitle($objQuestionTmp->id); echo '
    ' . $current_item . '. ' . $questionName . '
    '; } //@todo I need to the get the feedback type @@ -2777,6 +2774,7 @@ class ExerciseLib TABLE_STATISTIC_TRACK_E_ATTEMPT ); $courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER); + $courseTable = Database::get_main_table(TABLE_MAIN_COURSE); $courseUserSession = Database::get_main_table( TABLE_MAIN_SESSION_COURSE_USER ); @@ -2789,12 +2787,12 @@ class ExerciseLib if (empty($session_id)) { $courseCondition = " INNER JOIN $courseUser cu - ON cu.course_code = a.course_code AND cu.user_id = exe_user_id"; + ON cu.c_id = c.id AND cu.user_id = exe_user_id"; $courseConditionWhere = " AND relation_type <> 2 AND cu.status = " . STUDENT; } else { $courseCondition = " INNER JOIN $courseUserSession cu - ON cu.course_code = a.course_code AND cu.id_user = exe_user_id"; + ON cu.c_id = c.id AND cu.user_id = exe_user_id"; $courseConditionWhere = " AND cu.status = 0 "; } @@ -2806,6 +2804,8 @@ class ExerciseLib e.c_id = a.c_id AND e.session_id = a.session_id ) + INNER JOIN $courseTable c + ON (c.code = a.course_code) $courseCondition WHERE exe_exo_id = $exercise_id AND @@ -2847,6 +2847,8 @@ class ExerciseLib TABLE_STATISTIC_TRACK_E_HOTSPOT ); $courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER); + $courseTable = Database::get_main_table(TABLE_MAIN_COURSE); + $courseUserSession = Database::get_main_table( TABLE_MAIN_SESSION_COURSE_USER ); @@ -2860,12 +2862,12 @@ class ExerciseLib if (empty($session_id)) { $courseCondition = " INNER JOIN $courseUser cu - ON cu.course_code = a.hotspot_course_code AND cu.user_id = exe_user_id"; + ON cu.c_id = c.id AND cu.user_id = exe_user_id"; $courseConditionWhere = " AND relation_type <> 2 AND cu.status = " . STUDENT; } else { $courseCondition = " INNER JOIN $courseUserSession cu - ON cu.course_code = a.hotspot_course_code AND cu.id_user = exe_user_id"; + ON cu.c_id = c.id AND cu.user_id = exe_user_id"; $courseConditionWhere = " AND cu.status = 0 "; } @@ -2873,6 +2875,8 @@ class ExerciseLib FROM $track_exercises e INNER JOIN $track_hotspot a ON (a.hotspot_exe_id = e.exe_id) + INNER JOIN $courseTable c + ON (hotspot_course_code = c.code) $courseCondition WHERE exe_exo_id = $exercise_id AND @@ -2920,6 +2924,7 @@ class ExerciseLib $track_attempt = Database::get_main_table( TABLE_STATISTIC_TRACK_E_ATTEMPT ); + $courseTable = Database::get_main_table(TABLE_MAIN_COURSE); $courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER); $courseUserSession = Database::get_main_table( TABLE_MAIN_SESSION_COURSE_USER @@ -2946,12 +2951,12 @@ class ExerciseLib if (empty($session_id)) { $courseCondition = " INNER JOIN $courseUser cu - ON cu.course_code = a.course_code AND cu.user_id = exe_user_id"; + ON cu.c_id = c.id AND cu.user_id = exe_user_id"; $courseConditionWhere = " AND relation_type <> 2 AND cu.status = " . STUDENT; } else { $courseCondition = " INNER JOIN $courseUserSession cu - ON cu.course_code = a.course_code AND cu.id_user = exe_user_id"; + ON cu.c_id = a.c_id AND cu.user_id = exe_user_id"; $courseConditionWhere = " AND cu.status = 0 "; } @@ -2963,6 +2968,8 @@ class ExerciseLib e.c_id = a.c_id AND e.session_id = a.session_id ) + INNER JOIN $courseTable c + ON c.code = a.course_code $courseCondition WHERE exe_exo_id = $exercise_id AND @@ -3472,7 +3479,7 @@ class ExerciseLib 'score' => $total_score, 'total' => $total_weight ); - echo Testcategory::get_stats_table_by_attempt( + echo TestCategory::get_stats_table_by_attempt( $objExercise->id, $category_list ); diff --git a/main/inc/lib/export.lib.inc.php b/main/inc/lib/export.lib.inc.php index d68b9031d5..9f33b9eef8 100755 --- a/main/inc/lib/export.lib.inc.php +++ b/main/inc/lib/export.lib.inc.php @@ -1,6 +1,14 @@ $row) { - $line = ''; - if (is_array($row)) { - foreach ($row as $value) { - $line .= '"'.str_replace('"', '""', $value).'";'; - } - } - @fwrite($handle, $line."\n"); - } - } - @fclose($handle); - DocumentManager :: file_send_for_download($file, true, $filename.'.csv'); - - return false; - } - /** * Export tabular data to CSV-file * @param array $data * @param string $filename */ - public static function export_table_csv_utf8($data, $filename = 'export') + public static function arrayToCsv($data, $filename = 'export') { - if(empty($data)) { + if (empty($data)) { return false; } - $path = Chamilo::temp_file(); - $converter = new Utf8Encoder(null, true); - $file = FileWriter::create($path, $converter); - $file = CsvWriter::create($file); - foreach ($data as $row) { - $file->put($row); + + $filePath = api_get_path(SYS_ARCHIVE_PATH).uniqid('').'.csv'; + + $writer = new CsvWriter(); + $writer->setStream(fopen($filePath, 'w')); + + foreach($data as $item) { + $writer->writeItem($item); } - $file->close(); - DocumentManager::file_send_for_download($path, false, $filename.'.csv'); - unlink($path); + $writer->finish(); + + DocumentManager::file_send_for_download($filePath, false, $filename.'.csv'); exit; } @@ -68,20 +52,22 @@ class Export * @param array $data * @param string $filename */ - public static function export_table_xls($data, $filename = 'export', $encoding = 'utf-8') + public static function arrayToXls($data, $filename = 'export', $encoding = 'utf-8') { - $file = api_get_path(SYS_ARCHIVE_PATH).uniqid('').'.xls'; - $handle = fopen($file, 'a+'); - $systemEncoding = api_get_system_encoding(); - foreach ($data as $row) { - $string = implode("\t", $row); - if ($encoding != 'utf-8') { - $string = api_convert_encoding($string, $encoding, $systemEncoding); - } - fwrite($handle, $string."\n"); + $filePath = api_get_path(SYS_ARCHIVE_PATH).uniqid('').'.xls'; + + $file = new \SplFileObject($filePath, 'w'); + $writer = new ExcelWriter($file); + $writer->prepare(); + + foreach ($data as $index => $row) { + $writer->writeItem($row); } - fclose($handle); - DocumentManager::file_send_for_download($file, false, $filename.'.xls'); + + $writer->finish(); + + DocumentManager::file_send_for_download($filePath, false, $filename.'.xls'); + exit; } /** @@ -112,6 +98,7 @@ class Export fclose($handle); DocumentManager::file_send_for_download($file, false, $filename.'.xls'); } + /** * Export tabular data to XML-file * @param array Simple array of data to put in XML @@ -120,7 +107,7 @@ class Export * @param string Name of the root element. A root element should always be given. * @param string Encoding in which the data is provided */ - public static function export_table_xml($data, $filename = 'export', $item_tagname = 'item', $wrapper_tagname = null, $encoding = null) + public static function arrayToXml($data, $filename = 'export', $item_tagname = 'item', $wrapper_tagname = null, $encoding = null) { if (empty($encoding)) { $encoding = api_get_system_encoding(); diff --git a/main/inc/lib/fileDisplay.lib.php b/main/inc/lib/fileDisplay.lib.php index 41e764d5f8..1d23a547d3 100755 --- a/main/inc/lib/fileDisplay.lib.php +++ b/main/inc/lib/fileDisplay.lib.php @@ -196,7 +196,7 @@ function get_total_folder_size($path, $can_see_invisible = false) $session_id, true, true, - 'props.id_session' + 'props.session_id' ); $visibility_rule = ' props.visibility ' . ($can_see_invisible ? '<> 2' : '= 1'); diff --git a/main/inc/lib/fileManage.lib.php b/main/inc/lib/fileManage.lib.php index 610d184b23..f79bb02740 100755 --- a/main/inc/lib/fileManage.lib.php +++ b/main/inc/lib/fileManage.lib.php @@ -25,20 +25,6 @@ function update_db_info($action, $old_path, $new_path = '') $old_path = Database::escape_string($old_path); $to_delete = "WHERE c_id = $course_id AND (path LIKE BINARY '".$old_path."' OR path LIKE BINARY '".$old_path."/%')"; $query = "DELETE FROM $dbTable " . $to_delete; - $result = Database::query("SELECT id FROM $dbTable " . $to_delete); - - if (Database::num_rows($result)) { - require_once api_get_path(INCLUDE_PATH).'../metadata/md_funcs.php'; - $mdStore = new mdstore(TRUE); // create if needed - - $md_type = (substr($dbTable, -13) == 'scormdocument') ? 'Scorm' : 'Document'; - - while ($row = Database::fetch_array($result)) { - $eid = $md_type . '.' . $row['id']; - $mdStore->mds_delete($eid); - $mdStore->mds_delete_offspring($eid); - } - } Database::query($query); break; case 'update': diff --git a/main/inc/lib/fileUpload.lib.php b/main/inc/lib/fileUpload.lib.php index 3ddf33cfec..d6dcfad61d 100755 --- a/main/inc/lib/fileUpload.lib.php +++ b/main/inc/lib/fileUpload.lib.php @@ -1223,11 +1223,14 @@ function add_document( $c_id = $_course['real_id']; $table_document = Database::get_course_table(TABLE_DOCUMENT); - $sql = "INSERT INTO $table_document (c_id, path, filetype, size, title, comment, readonly, session_id) - VALUES ($c_id, '$path','$filetype','$filesize','$title', '$comment', $readonly, $session_id)"; + $sql = "INSERT INTO $table_document (id, c_id, path, filetype, size, title, comment, readonly, session_id) + VALUES (null, $c_id, '$path','$filetype','$filesize','$title', '$comment', $readonly, $session_id)"; if (Database::query($sql)) { $documentId = Database::insert_id(); + $sql = "UPDATE $table_document SET id = iid WHERE iid = $documentId"; + Database::query($sql); + if ($documentId) { if ($save_visibility) { api_set_default_visibility($documentId, TOOL_DOCUMENT, $group_id); diff --git a/main/inc/lib/formvalidator/Element/calendar_popup.php b/main/inc/lib/formvalidator/Element/calendar_popup.php deleted file mode 100755 index 8b141184e5..0000000000 --- a/main/inc/lib/formvalidator/Element/calendar_popup.php +++ /dev/null @@ -1,156 +0,0 @@ - - - - -Calendar - - - - - - - -
    -
    - - diff --git a/main/inc/lib/formvalidator/Element/tbl_change.js.php b/main/inc/lib/formvalidator/Element/tbl_change.js.php deleted file mode 100755 index e999cfd9a7..0000000000 --- a/main/inc/lib/formvalidator/Element/tbl_change.js.php +++ /dev/null @@ -1,198 +0,0 @@ - -var day; -var month; -var year; -var hour; -var minute; -var second; -var clock_set = 0; - -/** - * Opens calendar window. - * - * @param string form name - * @param string field name - */ -function openCalendar(form, field) { - formblock= document.getElementById(form); - forminputs = formblock.getElementsByTagName('select'); - var datevalues = new Array(); - var dateindex = 0; - for (i = 0; i < forminputs.length; i++) { - // regex here to check name attribute - var regex = new RegExp(field, "i"); - if (regex.test(forminputs[i].getAttribute('name'))) { - datevalues[dateindex++] = forminputs[i].value; - } - } - window.open("formvalidator/Element/calendar_popup.php", "calendar", "width=260,height=230,status=no"); - day = datevalues[0]; - month = datevalues[1]; - year = datevalues[2]; - - - month--; - formName = form; - fieldName =field; -} - -/** - * Formats number to two digits. - * - * @param int number to format. - */ -function formatNum2(i, valtype) { - f = (i < 10 ? '0' : '') + i; - if (valtype && valtype != '') { - switch(valtype) { - case 'month': - f = (f > 12 ? 12 : f); - break; - - case 'day': - f = (f > 31 ? 31 : f); - break; - } - } - - return f; -} - -/** - * Formats number to four digits. - * - * @param int number to format. - */ -function formatNum4(i) { - return (i < 1000 ? i < 100 ? i < 10 ? '000' : '00' : '0' : '') + i; -} - -/** - * Initializes calendar window. - */ -function initCalendar() { - if (!year && !month && !day) { - day = window.opener.day; - month = window.opener.month; - year = window.opener.year; - if (isNaN(year) || isNaN(month) || isNaN(day) || day == 0) { - dt = new Date(); - year = dt.getFullYear(); - month = dt.getMonth(); - day = dt.getDate(); - } - } else { - /* Moving in calendar */ - if (month > 11) { - month = 0; - year++; - } - if (month < 0) { - month = 11; - year--; - } - } - - if (document.getElementById) { - cnt = document.getElementById("calendar_data"); - } else if (document.all) { - cnt = document.all["calendar_data"]; - } - - cnt.innerHTML = ""; - - str = "" - - //heading table - str += '
    '; - str += ' '; - str += month_names[month]; - str += ' '; - str += ''; - str += ' '; - str += year; - str += ' '; - str += '
    '; - - str += ''; - for (i = 0; i < 7; i++) { - str += ""; - } - str += ""; - - var firstDay = new Date(year, month, 1).getDay(); - var lastDay = new Date(year, month + 1, 0).getDate(); - - str += ""; - - dayInWeek = 0; - for (i = 0; i < firstDay; i++) { - str += ""; - dayInWeek++; - } - for (i = 1; i <= lastDay; i++) { - if (dayInWeek == 7) { - str += ""; - dayInWeek = 0; - } - - dispmonth = 1 + month; - actVal = formatNum4(year) + "-" + formatNum2(dispmonth, 'month') + "-" + formatNum2(i, 'day'); - if (i == day) { - style = ' class="selected"'; - } else { - style = ''; - } - str += "
    " + i + "
    " - dayInWeek++; - } - for (i = dayInWeek; i < 7; i++) { - str += "
    "; - } - - str += "
    " + day_names[i] + "
     
     
    "; - - cnt.innerHTML = str; -} - -/** - * Returns date from calendar. - * - * @param string date text - */ -function returnDate(d,m,y) { - - formblock= window.opener.document.getElementById(window.opener.formName); - forminputs = formblock.getElementsByTagName('select'); - var datevalues = new Array(); - var dateindex = 0; - for (i = 0; i < forminputs.length; i++) { - // regex here to check name attribute - var regex = new RegExp(window.opener.fieldName, "i"); - if (regex.test(forminputs[i].getAttribute('name'))) { - datevalues[dateindex] = forminputs[i]; - dateindex++; - window.close(); - } - } - datevalues[0].selectedIndex = (d-1) ; - datevalues[1].selectedIndex = m; - - date = new Date(); - - //Selecting the first option of the year - year = datevalues[2].options[0].value; - - datevalues[2].selectedIndex = y - year; - for(i = 0; i<= 3; i++) { - attributes = datevalues[i].attributes; - for (attr=0; attraddElement('DatePicker', $name, $label, $attributes); + } + + /** + * @param string $name + * @param string $label + * @param array $attributes + * @return mixed + */ + public function addDateTimePicker($name, $label, $attributes = []) + { + return $this->addElement('DateTimePicker', $name, $label, $attributes); + } + /** * @param string $name * @param string $value diff --git a/main/inc/lib/glossary.lib.php b/main/inc/lib/glossary.lib.php index 779a33ceac..8b8cbb7d41 100755 --- a/main/inc/lib/glossary.lib.php +++ b/main/inc/lib/glossary.lib.php @@ -120,14 +120,32 @@ class GlossaryManager '".Database::escape_string($session_id)."' )"; $result = Database::query($sql); - if ($result === false) { return false; } + + if ($result === false) { + return false; + } + $id = Database::insert_id(); - //insert into item_property - api_item_property_update(api_get_course_info(), TOOL_GLOSSARY, $id, 'GlossaryAdded', api_get_user_id()); + if ($id) { + + $sql = "UPDATE $t_glossary SET glossary_id = $id WHERE iid = $id"; + Database::query($sql); + + //insert into item_property + api_item_property_update( + api_get_course_info(), + TOOL_GLOSSARY, + $id, + 'GlossaryAdded', + api_get_user_id() + ); + } + $_SESSION['max_glossary_display'] = GlossaryManager::get_max_glossary_item(); // display the feedback message - if ($message) + if ($message) { Display::display_confirmation_message(get_lang('TermAdded')); + } return $id; } @@ -422,23 +440,24 @@ class GlossaryManager //condition for the session $session_id = api_get_session_id(); - $condition_session = api_get_session_condition($session_id, true, true); + $condition_session = api_get_session_condition($session_id, true, true, 'glossary.session_id'); $column = intval($column); if (!in_array($direction,array('DESC', 'ASC'))) { $direction = 'ASC'; } - $from = intval($from); - $number_of_items = intval($number_of_items); + $from = intval($from); + $number_of_items = intval($number_of_items); $sql = "SELECT glossary.name as col0, glossary.description as col1, $col2 - glossary.session_id as session_id + glossary.session_id FROM $t_glossary glossary, $t_item_propery ip - WHERE glossary.glossary_id = ip.ref AND - tool = '".TOOL_GLOSSARY."' $condition_session AND - glossary.c_id = ".api_get_course_int_id()." AND - ip.c_id = ".api_get_course_int_id()." + WHERE + glossary.glossary_id = ip.ref AND + tool = '".TOOL_GLOSSARY."' $condition_session AND + glossary.c_id = ".api_get_course_int_id()." AND + ip.c_id = ".api_get_course_int_id()." ORDER BY col$column $direction LIMIT $from,$number_of_items"; $res = Database::query($sql); diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index 7a464caf43..f107bf2964 100755 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -196,6 +196,9 @@ class GroupManager $lastId = Database::insert_id(); if ($lastId) { + $sql = "UPDATE $table_group SET id = iid WHERE iid = $lastId"; + Database::query($sql); + $desired_dir_name= '/'.replace_dangerous_char($name,'strict').'_groupdocs'; $my_path = api_get_path(SYS_COURSE_PATH) . $currentCourseRepository . '/document'; @@ -314,41 +317,6 @@ class GroupManager } } - /** - * Create groups from all virtual courses in the given course. - * @deprecated - */ - public static function create_groups_from_virtual_courses() - { - self :: delete_category(self::VIRTUAL_COURSE_CATEGORY); - $id = self :: create_category(get_lang('GroupsFromVirtualCourses'), '', self::TOOL_NOT_AVAILABLE, self::TOOL_NOT_AVAILABLE, 0, 0, 1, 1); - $table_group_cat = Database :: get_course_table(TABLE_GROUP_CATEGORY); - $course_id = api_get_course_int_id(); - - $sql = "UPDATE ".$table_group_cat." SET id=".self::VIRTUAL_COURSE_CATEGORY." WHERE c_id = $course_id AND id=$id"; - Database::query($sql); - $course = api_get_course_info(); - $course['code'] = $course['sysCode']; - $course['title'] = $course['name']; - $virtual_courses = CourseManager :: get_virtual_courses_linked_to_real_course($course['sysCode']); - $group_courses = $virtual_courses; - $group_courses[] = $course; - $ids = array (); - foreach ($group_courses as $index => $group_course) { - $users = CourseManager :: get_user_list_from_course_code($group_course['code']); - $members = array (); - foreach ($users as $index => $user) { - if ($user['status'] == 5 && $user['tutor_id'] == 0) { - $members[] = $user['user_id']; - } - } - $id = self :: create_group($group_course['code'], self::VIRTUAL_COURSE_CATEGORY, 0, count($members)); - self :: subscribe_users($members, $id); - $ids[] = $id; - } - return $ids; - } - /** * Create a group for every class subscribed to the current course * @param int $category_id The category in which the groups should be created @@ -446,9 +414,9 @@ class GroupManager $sql = "DELETE FROM ".$forum_table." WHERE c_id = $course_id AND forum_of_group IN ('".implode("' , '", $group_ids)."')"; - Database::query($sql); + $result = Database::query($sql); - return Database::affected_rows(); + return Database::affected_rows($result); } /** @@ -477,7 +445,6 @@ class GroupManager $result['id'] = $db_object->id; $result['name'] = $db_object->name; $result['status'] = $db_object->status; - $result['tutor_id'] = isset($db_object->tutor_id) ? $db_object->tutor_id : null; $result['description'] = $db_object->description; $result['maximum_number_of_students'] = $db_object->max_student; $result['max_student'] = $db_object->max_student; @@ -835,12 +802,18 @@ class GroupManager max_student = '".Database::escape_string($maximum_number_of_students)."' "; Database::query($sql); $categoryId = Database::insert_id(); + + // @todo check if this code do something ... virtual course category? if ($categoryId == self::VIRTUAL_COURSE_CATEGORY) { $sql = "UPDATE ".$table_group_category." SET id = ". ($categoryId +1)." WHERE c_id = $course_id AND id = $categoryId"; Database::query($sql); - return $categoryId +1; + $categoryId = $categoryId +1; } + + $sql = "UPDATE $table_group_category SET id = iid WHERE iid = $categoryId"; + Database::query($sql); + return $categoryId; } @@ -1506,8 +1479,9 @@ class GroupManager $course_id = api_get_course_int_id(); $sql = "SELECT tg.id, u.user_id, u.lastname, u.firstname, u.email - FROM ".$table_user." u, ".$table_group_tutor." tg - WHERE tg.c_id = $course_id AND + FROM ".$table_user." u, ".$table_group_tutor." tg + WHERE + tg.c_id = $course_id AND tg.group_id='".$group_id."' AND tg.user_id=u.user_id".$order_clause; $db_result = Database::query($sql); @@ -1520,7 +1494,7 @@ class GroupManager $member['email'] = $user->email; $users[] = $member; } else { - $users[]=$user->user_id; + $users[] = $user->user_id; } } return $users; @@ -1545,11 +1519,12 @@ class GroupManager $group_id = intval($group_id); $sql = "INSERT INTO ".$table_group_user." (c_id, user_id, group_id) VALUES ('$course_id', '".$user_id."', '".$group_id."')"; - $result &= Database::query($sql); + Database::query($sql); } } } - return $result; + + return true; } /** @@ -1572,7 +1547,7 @@ class GroupManager $group_id = intval($group_id); if (self::can_user_subscribe($user_id, $group_id)) { $sql = "INSERT INTO " . $table_group_tutor . " (c_id, user_id, group_id) - VALUES ('$course_id', '" . $user_id . "', '" . $group_id . "')"; + VALUES ('$course_id', '" . $user_id . "', '" . $group_id . "')"; $result &= Database::query($sql); } } @@ -1709,7 +1684,7 @@ class GroupManager $sql = "SELECT user.user_id AS user_id, user.lastname AS lastname, user.firstname AS firstname FROM ".$user_table." user, ".$course_user_table." cu WHERE cu.user_id=user.user_id - AND cu.tutor_id='1' + AND cu.is_tutor='1' AND cu.c_id='".api_get_course_int_id()."'"; $resultTutor = Database::query($sql); $tutors = array(); @@ -1719,7 +1694,6 @@ class GroupManager return $tutors; } - /** * Is user a tutor in current course * @param int $user_id @@ -1731,10 +1705,10 @@ class GroupManager $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); $user_id = intval($user_id); - $sql = "SELECT tutor_id FROM ".$course_user_table." - WHERE user_id = '".$user_id."' AND c_id ='".api_get_course_int_id()."'"."AND tutor_id=1"; + $sql = "SELECT is_tutor FROM ".$course_user_table." + WHERE user_id = '".$user_id."' AND c_id ='".api_get_course_int_id()."'"." AND is_tutor=1"; $db_result = Database::query($sql); - $result = (Database::num_rows($db_result) > 0); + $result = Database::num_rows($db_result) > 0; return $result; } @@ -1825,7 +1799,7 @@ class GroupManager $firstname = $this_user['firstname']; $status = $this_user['status']; //$role = $this_user['role']; - $tutor_id = $this_user['tutor_id']; + $isTutor = $this_user['is_tutor']; $full_name = api_get_person_name($firstname, $lastname); if ($lastname == "" || $firstname == '') { $full_name = $loginname; @@ -1835,7 +1809,7 @@ class GroupManager $complete_user['firstname'] = $firstname; $complete_user['lastname'] = $lastname; $complete_user['status'] = $status; - $complete_user['tutor_id'] = $tutor_id; + $complete_user['is_tutor'] = $isTutor; $student_number_of_groups = self :: user_in_number_of_groups($user_id, $category['id']); //filter: only add users that have not exceeded their maximum amount of groups if ($student_number_of_groups < $number_of_groups_limit) { @@ -1894,7 +1868,6 @@ class GroupManager { $user_array_out = array(); foreach ($user_array_in as $this_user) { - //if ($this_user['status_rel'] == STUDENT && $this_user['tutor_id'] == 0) { if (api_get_session_id()) { if ($this_user['status_session'] == 0) { $user_array_out[] = $this_user; @@ -1978,8 +1951,6 @@ class GroupManager return true; } elseif (api_is_allowed_to_edit(false, true)) { return true; - } elseif ($groupInfo['tutor_id'] == $user_id) { //this tutor implementation was dropped - return true; } elseif ($groupInfo[$state_key] == self::TOOL_PRIVATE && !$user_is_in_group) { return false; } else { @@ -2214,7 +2185,11 @@ class GroupManager $tutor = api_get_user_info($tutor_id); $username = api_htmlentities(sprintf(get_lang('LoginX'), $tutor['username']), ENT_QUOTES); if (api_get_setting('show_email_addresses') == 'true') { - $tutor_info .= Display::tag('span', Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])), array('title'=>$username)).', '; + $tutor_info .= Display::tag( + 'span', + Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])), + array('title'=>$username) + ).', '; } else { if (api_is_allowed_to_edit()) { $tutor_info .= Display::tag('span', Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])), array('title'=>$username)).', '; diff --git a/main/inc/lib/hook/HookEvent.php b/main/inc/lib/hook/HookEvent.php index 8180b38545..b173b68d06 100644 --- a/main/inc/lib/hook/HookEvent.php +++ b/main/inc/lib/hook/HookEvent.php @@ -23,6 +23,7 @@ abstract class HookEvent implements HookEventInterface /** * Construct Method * @param string $eventName + * * @throws Exception */ protected function __construct($eventName) diff --git a/main/inc/lib/hook/HookObserver.php b/main/inc/lib/hook/HookObserver.php index cedfe483c8..226b1ddacb 100644 --- a/main/inc/lib/hook/HookObserver.php +++ b/main/inc/lib/hook/HookObserver.php @@ -34,7 +34,7 @@ abstract class HookObserver implements HookObserverInterface /** * Return the singleton instance of Hook observer. * If Hook Management plugin is not enabled, will return NULL - * @return static + * @return HookObserver */ public static function create() { @@ -45,6 +45,7 @@ abstract class HookObserver implements HookObserverInterface } else { try { $class = get_called_class(); + return new $class; } catch (Exception $e) { diff --git a/main/inc/lib/import.lib.php b/main/inc/lib/import.lib.php index 52d068b8de..39f3da9372 100755 --- a/main/inc/lib/import.lib.php +++ b/main/inc/lib/import.lib.php @@ -1,6 +1,10 @@ setHeaderRowNumber(0); + } + + return $csvReader; } /** @@ -40,68 +55,17 @@ class Import * * @deprecated use cvs_reader instead */ - static function csv_to_array($filename, $csv_order = 'vertical') { - $result = array(); - - // Encoding detection. - - $handle = fopen($filename, 'r'); - if ($handle === false) { - return $result; - } - $buffer = array(); - $i = 0; - while (!feof($handle) && $i < 200) { - // We assume that 200 lines are enough for encoding detection. - $buffer[] = fgets($handle); - $i++; - } - fclose($handle); - $buffer = implode("\n", $buffer); - $from_encoding = api_detect_encoding($buffer); - unset($buffer); - - // Reading the file, parsing and importing csv data. - - $handle = fopen($filename, 'r'); - if ($handle === false) { - return $result; - } - - if ($csv_order == 'vertical') { - $keys = api_fgetcsv($handle, null, ';'); - foreach ($keys as $key => &$key_value) { - $key_value = api_to_system_encoding($key_value, $from_encoding); - } - } + static function csvToArray($filename) + { + $csvReader = self::csv_reader($filename); + $resultArray = []; - while (($row_tmp = api_fgetcsv($handle, null, ';')) !== false) { - $row = array(); - // Avoid empty lines in csv - if (is_array($row_tmp) && count($row_tmp) > 0 && $row_tmp[0] != '') { - if (!is_null($row_tmp[0])) { - if ($csv_order == 'vertical') { - foreach ($row_tmp as $index => $value) { - $row[$keys[$index]] = api_to_system_encoding($value, $from_encoding); - } - } else { - $first = null; - $count = 1; - foreach ($row_tmp as $index => $value) { - if ($count == 1) { - $first = $value; - } else { - $row[$first][] = api_to_system_encoding($value, $from_encoding); - } - $count++; - } - } - $result[] = $row; - } - } + if ($csvReader) { + $workflow = new Workflow($csvReader); + $writer = new ArrayWriter($resultArray); + $result = $workflow->addWriter($writer)->process(); } - fclose($handle); - return $result; + return $resultArray; } } diff --git a/main/inc/lib/internationalization.lib.php b/main/inc/lib/internationalization.lib.php index 1a49b55b8d..a367f75f9f 100755 --- a/main/inc/lib/internationalization.lib.php +++ b/main/inc/lib/internationalization.lib.php @@ -11,6 +11,8 @@ * @package chamilo.library */ +use Patchwork\Utf8; + /** * Constants */ @@ -3295,10 +3297,11 @@ function api_detect_encoding($string, $language = null) { /** * Checks a string for UTF-8 validity. * - * @deprecated Use Encoding::utf8()->is_valid() instead */ -function api_is_valid_utf8(&$string) { - return Encoding::utf8()->is_valid($string); +function api_is_valid_utf8(&$string) +{ + return Utf8::isUtf8($string); + } /** diff --git a/main/inc/lib/item_property.class.php b/main/inc/lib/item_property.class.php deleted file mode 100755 index 2e59606104..0000000000 --- a/main/inc/lib/item_property.class.php +++ /dev/null @@ -1,603 +0,0 @@ - for the Univesity of Geneva - */ -class ItemProperty -{ - - const VISIBILITY_INVISIBLE = 0; - const VISIBILITY_VISIBLE = 1; - const VISIBILITY_DELETED = 2; - - /** - * - * @return ItemPropertyRepository - */ - public static function repository() - { - return ItemPropertyRepository::instance(); - } - - /** - * - * @param string $where - * @return \ResultSet - */ - public static function query($where) - { - return self::repository()->query($where); - } - - /** - * - * @param id $ref - * @param string $tool - * @return \Model\ItemProperty - */ - public static function get_by_ref($ref, $tool) - { - return self::repository()->get_by_ref($ref, $tool); - } - - /** - * - * @param array|object $data - * @return \Model\ItemProperty - */ - static function create($data) - { - return new self($data); - } - - protected $c_id = 0; - protected $id = 0; - protected $tool = ''; - protected $insert_user_id = 0; - protected $insert_date = 0; - protected $lastedit_date = 0; - protected $ref = ''; - protected $lastedit_type = ''; - protected $lastedit_user_id = 0; - protected $to_group_id = null; - protected $to_user_id = null; - protected $visibility = self::VISIBILITY_VISIBLE; - protected $start_visible = 0; - protected $end_visible = 0; - protected $id_session = 0; - - public function __construct($data) - { - $data = (object) $data; - $this->c_id = (int) $data->c_id; - $this->id = (int) $data->id; - $this->tool = $data->tool; - $this->insert_user_id = (int) $data->insert_user_id; - $this->insert_date = is_numeric($data->insert_date) ? $data->insert_date : strtotime($data->insert_date); - $this->lastedit_date = is_numeric($data->lastedit_date) ? $data->lastedit_date : strtotime($data->lastedit_date); - $this->ref = (int) $data->ref; - $this->lastedit_type = $data->lastedit_type; - $this->lastedit_user_id = (int) $data->lastedit_user_id; - $this->to_group_id = (int) $data->to_group_id; - $this->to_user_id = (int) $data->to_user_id; - $this->visibility = (int) $data->visibility; - $this->start_visible = is_numeric($data->start_visible) ? $data->start_visible : strtotime($data->start_visible); - $this->end_visible = is_numeric($data->end_visible) ? $data->end_visible : strtotime($data->end_visible); - $this->id_session = $data->id_session; - } - - /** - * - * @return int - */ - public function get_c_id() - { - return $this->c_id; - } - - public function set_c_id($value) - { - $this->c_id = (int) $value; - } - - /** - * - * @return int - */ - public function get_id() - { - return $this->id; - } - - public function set_id($value) - { - $this->id = (int) $value; - } - - public function get_tool() - { - return $this->tool; - } - - public function set_tool($value) - { - $this->tool = $value; - } - - /** - * - * @return int - */ - public function get_insert_user_id() - { - return $this->insert_user_id; - } - - public function set_insert_user_id($value) - { - $this->insert_user_id = $value; - } - - /** - * - * @return int - */ - public function get_insert_date() - { - return $this->insert_date; - } - - public function set_insert_date($value) - { - $value = is_numeric($value) ? $value : strtotime($value); - $this->insert_date = $value; - } - - /** - * - * @return int - */ - public function get_lastedit_date() - { - return $this->lastedit_date; - } - - public function set_lastedit_date($value) - { - $value = is_numeric($value) ? $value : strtotime($value); - $this->lastedit_date = $value; - } - - /** - * - * @return int - */ - public function get_ref() - { - return $this->ref; - } - - public function set_ref($value) - { - $this->ref = $value; - } - - /** - * - * @return string - */ - public function get_lastedit_type() - { - return $this->lastedit_type; - } - - public function set_lastedit_type($value) - { - $this->lastedit_type = $value; - } - - /** - * - * @return int - */ - public function get_lastedit_user_id() - { - return $this->lastedit_user_id; - } - - public function set_lastedit_user_id($value) - { - $this->lastedit_user_id = $value; - } - - /** - * - * @return int - */ - public function get_to_group_id() - { - return $this->to_group_id; - } - - public function set_to_group_id($value) - { - $this->to_group_id = $value; - } - - /** - * - * @return int - */ - public function get_to_user_id() - { - return $this->to_user_id; - } - - public function set_to_user_id($value) - { - $this->to_user_id = $value; - } - - /** - * - * @return int - */ - public function get_visibility() - { - return $this->visibility; - } - - public function set_visibility($value) - { - $this->visibility = $value; - } - - /** - * - * @return int - */ - public function get_start_visible() - { - return $this->start_visible; - } - - public function set_start_visible($value) - { - $value = is_numeric($value) ? $value : strtotime($value); - $this->start_visible = $value; - } - - /** - * - * @return int - */ - public function get_end_visible() - { - return $this->end_visible; - } - - public function set_end_visible($value) - { - $value = is_numeric($value) ? $value : strtotime($value); - $this->end_visible = $value; - } - - /** - * - * @return int - */ - public function get_id_session() - { - return $this->id_session; - } - - public function set_id_session($value) - { - $this->id_session = $value; - } - - public function mark_deleted() - { - $this->set_visibility(self::VISIBILITY_DELETED); - - $tool = $this->get_tool(); - $lastedit_type = str_replace('_', '', ucwords($tool)) . 'Deleted'; - $this->set_lastedit_type($lastedit_type); - - $user_id = api_get_user_id(); - $this->set_insert_user_id($user_id); - } - - public function mark_visible() - { - $this->set_visibility(self::VISIBILITY_VISIBLE); - $tool = $this->get_tool(); - - $lastedit_type = str_replace('_', '', ucwords($tool)) . 'Visible'; - $this->set_lastedit_type($lastedit_type); - - $user_id = api_get_user_id(); - $this->set_insert_user_id($user_id); - } - - public function mark_invisible() - { - $this->set_visibility(self::VISIBILITY_INVISIBLE); - $tool = $this->get_tool(); - - $lastedit_type = str_replace('_', '', ucwords($tool)) . 'Invisible'; - $this->set_lastedit_type($lastedit_type); - - $user_id = api_get_user_id(); - $this->set_insert_user_id($user_id); - } - -} - -/** - * - */ -class ItemPropertyRepository -{ - - /** - * - * @return \Model\ItemPropertyRepository - */ - public static function instance() - { - static $result = null; - if (empty($result)) { - $result = new self(); - } - return $result; - } - - /** - * - * @param string $where - * @return \ResultSet - */ - public function query($where) - { - $table = Database::get_course_table(TABLE_ITEM_PROPERTY); - $sql = "SELECT * FROM $table "; - $sql .= $where ? "WHERE $where" : ''; - $result = new ResultSet($sql); - return $result->return_type(__CLASS__); - } - - /** - * - * @param id $ref - * @param string $tool - * @return \Model\ItemProperty - */ - public function get_by_ref($ref, $tool) - { - return $this->query("ref=$ref AND tool = '$tool'")->first(); - } - - /** - * - * @param ItemProperty $item - */ - function save($item) - { - if ($this->exists($item)) { - $this->update($item); - } else { - $this->insert($item); - } - } - - /** - * Returns true if item is not new, false otherwise. - * - * @param ItemProperty $item - * @return bool - */ - public function exists($item) - { - $id = $item->get_id(); - $c_id = $item->get_c_id(); - return !empty($id) && !empty($c_id); - } - - /** - * - * @param ItemProperty $item - * @return bool - */ - public function insert($item) - { - $this->defaults($item); - $user_id = api_get_user_id(); - $item->set_insert_user_id($user_id); - - $c_id = $item->get_c_id(); - $id = $item->get_id(); - $tool = Database::escape_string($item->get_tool()); - $insert_user_id = $item->get_insert_user_id(); - $insert_date = api_get_utc_datetime($item->get_insert_date()); - $lastedit_date = api_get_utc_datetime($item->get_lastedit_date()); - $ref = $item->get_ref(); - $lastedit_type = Database::escape_string($item->get_lastedit_type()); - $last_edit_user_id = $item->get_lastedit_user_id(); - - $to_group_id = $item->get_to_group_id(); - $to_group_id = empty($to_group_id) ? '0' : $to_group_id; - - $to_user_id = $item->get_to_user_id(); - $to_user_id = empty($to_user_id) ? '0' : $to_user_id; - - $visibility = $item->get_visibility(); - $visibility = $visibility ? $visibility : '0'; - - $start_visible = $item->get_start_visible(); - $start_visible = empty($start_visible) ? '0000-00-00 00:00:00' : api_get_utc_datetime($start_visible); - - $end_visible = $item->get_end_visible(); - $end_visible = empty($end_visible) ? '0000-00-00 00:00:00' : api_get_utc_datetime($end_visible); - - $session_id = $item->get_id_session(); - - $TABLE = Database::get_course_table(TABLE_ITEM_PROPERTY); - - - $sql = "INSERT INTO $TABLE_ITEMPROPERTY ( - c_id, - tool, - insert_user_id, - insert_date, - lastedit_date, - ref, - lastedit_type, - lastedit_user_id, - to_group_id, - to_user_id, - visibility, - start_visible, - end_visible, - id_session - ) VALUES ( - $c_id, - '$tool', - $insert_user_id, - '$insert_date', - '$lastedit_date', - $ref, - '$lastedit_type', - $last_edit_user_id, - $to_group_id, - $to_user_id, - $visibility, - '$start_visible', - '$end_visible', - '$session_id' - )"; - - $result = Database::query($sql); - $id = Database::insert_id(); - if ($id) { - $item->set_id($id); - } - return (bool) $result; - } - - /** - * - * @param ItemProperty $item - */ - public function update($item) - { - $this->defaults($item); - $user_id = api_get_user_id(); - $item->set_insert_user_id($user_id); - - $c_id = $item->get_c_id(); - $id = $item->get_id(); - //$tool = Database::escape_string($item->get_tool()); - //$insert_user_id = $item->get_insert_user_id(); - //$insert_date = api_get_utc_datetime($item->get_insert_date()); - $lastedit_date = api_get_utc_datetime($item->get_lastedit_date()); - //$ref = $item->get_ref(); - $lastedit_type = Database::escape_string($item->get_lastedit_type()); - $last_edit_user_id = $item->get_lastedit_user_id(); - - $to_group_id = $item->get_to_group_id(); - $to_group_id = empty($to_group_id) ? '0' : $to_group_id; - - $to_user_id = $item->get_to_user_id(); - $to_user_id = empty($to_user_id) ? '0' : $to_user_id; - - $visibility = $item->get_visibility(); - $visibility = $visibility ? $visibility : '0'; - - $start_visible = $item->get_start_visible(); - $start_visible = empty($start_visible) ? '0000-00-00 00:00:00' : api_get_utc_datetime($start_visible); - - $end_visible = $item->get_end_visible(); - $end_visible = empty($end_visible) ? '0000-00-00 00:00:00' : api_get_utc_datetime($end_visible); - - $session_id = $item->get_id_session(); - - - $TABLE = Database::get_course_table(TABLE_ITEM_PROPERTY); - $sql = "UPDATE - $TABLE - SET - lastedit_date = '$lastedit_date', - lastedit_type = '$lastedit_type', - lastedit_user_id = $last_edit_user_id, - to_group_id = $to_group_id, - to_user_id = $to_user_id, - visibility = $visibility, - start_visible = '$start_visible', - end_visible = '$end_visible', - id_session = $session_id - WHERE - c_id = $c_id AND - id = $id"; - - $result = Database::query($sql); - return (bool) $result; - } - - /** - * - * @param ItemProperty $item - */ - function defaults($item) - { - $now = time(); - $user = api_get_user_id(); - - $value = $item->get_insert_user_id(); - if (empty($value)) { - $item->set_insert_user_id($user); - } - - $value = get_insert_date(); - if (empty($value)) { - $item->set_insert_date($now); - } - - $value = get_lastedit_date(); - if (empty($value)) { - $item->set_lastedit_date($now); - } - - $value = $item->get_lastedit_user_id(); - if (empty($value)) { - $item->set_insert_user_id($user); - } - - $value = $item->get_id_session(); - if (empty($value)) { - $value = api_get_session_id(); - $item->set_session_id($value); - } - } - -} \ No newline at end of file diff --git a/main/inc/lib/javascript.class.php b/main/inc/lib/javascript.class.php deleted file mode 100755 index c61984f711..0000000000 --- a/main/inc/lib/javascript.class.php +++ /dev/null @@ -1,91 +0,0 @@ - for the Univesity of Geneva - */ -class Javascript -{ - - /** - * Minimify Javascript. - * - * If called with a path - * - * input: /dir/dir/file.js - * returns: /dir/dir/file.min.js - * - * Otherwise returns the actual code. - * - * @param string $arg either a path or actual code - * @return string either a path to minified content (ends with min.js) or actual code - */ - public static function minify($arg) - { - if (is_readable($arg)) - { - $path = $arg; - $code = file_get_contents($path); - $code = ClosureCompiler::post($code); - - $min_path = $path; - $min_path = str_replace('.js', '', $min_path); - $min_path .= '.min.js'; - file_put_contents($min_path, $code); - return $min_path; - } - else - { - return ClosureCompiler::post($code); - } - } - - /** - * Returns lang object that contains the translation. - * - * Javascript::get_lang('string1', 'string2', 'string3'); - * - * returns - * - * if(typeof(lang) == "undefined") - * { - * var lang = {}; - * } - * lang.string1 = "..."; - * lang.string2 = "..."; - * lang.string3 = "... - * - * @param type $_ - * @return type - */ - public static function get_lang($_) - { - $result = array(); - $result[] = 'if(typeof(lang) == "undefined")'; - $result[] = '{'; - $result[] = ' var lang = {};'; - $result[] = '}'; - - $keys = func_get_args(); - foreach ($keys as $key) - { - $value = get_lang($key); - $result[] = 'lang.' . $key . ' = "' . $value . '";'; - } - return implode("\n", $result); - } - - public static function tag($src) - { - return ''; - } - - public static function tag_code($code) - { - $new_line = "\n"; - return ''; - } - -} \ No newline at end of file diff --git a/main/inc/lib/link.lib.php b/main/inc/lib/link.lib.php index 729c4670ae..234be58af0 100755 --- a/main/inc/lib/link.lib.php +++ b/main/inc/lib/link.lib.php @@ -192,6 +192,9 @@ class Link extends Model $catlinkstatus = get_lang('LinkAdded'); Database:: query($sql); $link_id = Database:: insert_id(); + // iid + $sql = "UPDATE $tbl_link SET id = iid WHERE iid = $link_id"; + Database:: query($sql); if ($link_id) { api_set_default_visibility($link_id, TOOL_LINK); @@ -345,8 +348,11 @@ class Link extends Model '$session_id' )"; Database:: query($sql); - $linkId = Database:: insert_id(); + // iid + $sql = "UPDATE $tbl_categories SET id = iid WHERE iid = $linkId"; + Database:: query($sql); + if ($linkId) { // add link_category visibility // course ID is taken from context in api_set_default_visibility @@ -790,7 +796,7 @@ class Link extends Model $tblItemProperty = Database:: get_course_table(TABLE_ITEM_PROPERTY); $courseId = intval($courseId); // Condition for the session. - $sessionCondition = api_get_session_condition($sessionId, true, true); + $sessionCondition = api_get_session_condition($sessionId, true, true, 'linkcat.session_id'); // Getting links $sql = "SELECT *, linkcat.id @@ -859,7 +865,7 @@ class Link extends Model // Condition for the session. $session_id = api_get_session_id(); - $condition_session = api_get_session_condition($session_id, true, true); + $condition_session = api_get_session_condition($session_id, true, true, 'link.session_id'); $catid = intval($catid); $course_id = api_get_course_int_id(); diff --git a/main/inc/lib/login.lib.php b/main/inc/lib/login.lib.php index 38c2a0ad2c..4300a96c01 100755 --- a/main/inc/lib/login.lib.php +++ b/main/inc/lib/login.lib.php @@ -1,6 +1,6 @@ , Ghent University */ - public static function send_password_to_user($user, $by_username = false) { - global $_configuration; + public static function send_password_to_user($user, $by_username = false) + { + $email_subject = "[" . api_get_setting('siteName') . "] " . get_lang('LoginRequest'); // SUBJECT if ($by_username) { // Show only for lost password @@ -95,7 +95,7 @@ class Login } $portal_url = api_get_path(WEB_PATH); - if ($_configuration['multiple_access_urls']) { + if (api_is_multiple_url_enabled()) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url = api_get_access_url($access_url_id); @@ -319,7 +319,6 @@ class Login global $_cid; global $_course; global $_real_cid; - global $_courseUser; global $is_courseAdmin; //course teacher global $is_courseTutor; //course teacher - some rights @@ -357,7 +356,6 @@ class Login $_course['path'] = $course_data['directory']; // use as key in path $_course['dbName'] = $course_data['db_name']; // use as key in db list $_course['db_name'] = $course_data['db_name']; // not needed in Chamilo 1.9 - $_course['dbNameGlu'] = $_configuration['table_prefix'] . $course_data['db_name'] . $_configuration['db_glue']; // use in all queries //not needed in Chamilo 1.9 $_course['titular'] = $course_data['tutor_name']; // this should be deprecated and use the table course_rel_user $_course['language'] = $course_data['course_language']; $_course['extLink']['url'] = $course_data['department_url']; @@ -520,28 +518,33 @@ class Login //Check if user is subscribed in a course $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); $sql = "SELECT * FROM $course_user_table - WHERE user_id = '" . $user_id . "' AND relation_type <> " . COURSE_RELATION_TYPE_RRHH . " - AND course_code = '$course_id'"; + WHERE + user_id = '" . $user_id . "' AND + relation_type <> " . COURSE_RELATION_TYPE_RRHH . " AND + course_code = '$course_id'"; $result = Database::query($sql); $cuData = null; - if (Database::num_rows($result) > 0) { // this user have a recorded state for this course + if (Database::num_rows($result) > 0) { + // this user have a recorded state for this course $cuData = Database::fetch_array($result, 'ASSOC'); - $is_courseAdmin = (bool) ($cuData['status'] == 1 ); - $is_courseTutor = (bool) ($cuData['tutor_id'] == 1 ); + $is_courseAdmin = (bool) $cuData['status'] == 1; + $is_courseTutor = (bool) $cuData['is_tutor'] == 1; $is_courseMember = true; - //Checking if the user filled the course legal agreement + // Checking if the user filled the course legal agreement if ($_course['activate_legal'] == 1 && !api_is_platform_admin()) { - $user_is_subscribed = CourseManager::is_user_accepted_legal($user_id, $_course['id'], $session_id); + $user_is_subscribed = CourseManager::is_user_accepted_legal( + $user_id, + $_course['id'], + $session_id + ); if (!$user_is_subscribed) { $url = api_get_path(WEB_CODE_PATH) . 'course_info/legal.php?course_code=' . $_course['code'] . '&session_id=' . $session_id; header('Location: ' . $url); exit; } } - $_courseUser['role'] = $cuData['role']; - Session::write('_courseUser', $_courseUser); } //We are in a session course? Check session permissions @@ -557,20 +560,20 @@ class Login $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); //Session coach, session admin, course coach admin - $sql = "SELECT session.id_coach, session_admin_id, session_rcru.id_user - 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_id' AND - session_rcru.id_session = $session_id AND - session_rcru.status = 2"; + $sql = "SELECT session.id_coach, session_admin_id, session_rcru.user_id + FROM $tbl_session session, $tbl_session_course_user session_rcru + WHERE + session_rcru.session_id = session.id AND + session_rcru.course_code = '$_cid' AND + session_rcru.user_id = '$user_id' AND + session_rcru.session_id = $session_id AND + session_rcru.status = 2"; $result = Database::query($sql); $row = Database::store_result($result); //I'm a session admin? if (isset($row) && isset($row[0]) && $row[0]['session_admin_id'] == $user_id) { - $_courseUser['role'] = 'Professor'; $is_courseMember = false; $is_courseTutor = false; $is_courseAdmin = false; @@ -578,21 +581,21 @@ class Login $is_sessionAdmin = true; } else { //Im a coach or a student? - $sql = "SELECT id_user, status FROM " . $tbl_session_course_user . " - WHERE course_code = '$_cid' AND - id_user = '" . $user_id . "' AND - id_session = '" . $session_id . "' - LIMIT 1"; + $sql = "SELECT user_id, status + FROM " . $tbl_session_course_user . " + WHERE + c_id = '$_cid' AND + user_id = '" . $user_id . "' AND + session_id = '" . $session_id . "' + LIMIT 1"; $result = Database::query($sql); if (Database::num_rows($result)) { $row = Database::fetch_array($result, 'ASSOC'); - $session_course_status = $row['status']; switch ($session_course_status) { case '2': // coach - teacher - $_courseUser['role'] = 'Professor'; $is_courseMember = true; $is_courseTutor = true; $is_courseCoach = true; @@ -603,14 +606,12 @@ class Login } else { $is_courseAdmin = false; } - Session::write('_courseUser', $_courseUser); break; case '0': //student $is_courseMember = true; $is_courseTutor = false; $is_courseAdmin = false; $is_sessionAdmin = false; - Session::write('_courseUser', $_courseUser); break; default: //unregister user @@ -618,7 +619,6 @@ class Login $is_courseTutor = false; $is_courseAdmin = false; $is_sessionAdmin = false; - Session::erase('_courseUser'); break; } } else { @@ -627,7 +627,6 @@ class Login $is_courseTutor = false; $is_courseAdmin = false; $is_sessionAdmin = false; - Session::erase('_courseUser'); } } } @@ -644,7 +643,6 @@ class Login $is_courseTutor = false; $is_courseCoach = false; $is_sessionAdmin = false; - Session::erase('_courseUser'); } //Checking the course access @@ -706,16 +704,13 @@ class Login Session::write('is_allowed_in_course', $is_allowed_in_course); Session::write('is_sessionAdmin', $is_sessionAdmin); - } else { // continue with the previous values - if (isset($_SESSION ['_courseUser'])) { - $_courseUser = $_SESSION ['_courseUser']; - } - - $is_courseAdmin = $_SESSION ['is_courseAdmin']; - $is_courseTutor = $_SESSION ['is_courseTutor']; - $is_courseCoach = $_SESSION ['is_courseCoach']; - $is_courseMember = $_SESSION ['is_courseMember']; - $is_allowed_in_course = $_SESSION ['is_allowed_in_course']; + } else { + // continue with the previous values + $is_courseAdmin = $_SESSION['is_courseAdmin']; + $is_courseTutor = $_SESSION['is_courseTutor']; + $is_courseCoach = $_SESSION['is_courseCoach']; + $is_courseMember = $_SESSION['is_courseMember']; + $is_allowed_in_course = $_SESSION['is_allowed_in_course']; } } diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php index abf209dbca..983752834d 100755 --- a/main/inc/lib/message.lib.php +++ b/main/inc/lib/message.lib.php @@ -224,12 +224,16 @@ class MessageManager // Validating fields if (empty($subject) && empty($group_id)) { - return get_lang('YouShouldWriteASubject'); + Display::addFlash(Display::return_message(get_lang('YouShouldWriteASubject'), 'warning')); + return false; } else if ($total_filesize > intval(api_get_setting('message_max_upload_filesize'))) { - return sprintf( + $warning = sprintf( get_lang("FilesSizeExceedsX"), format_file_size(api_get_setting('message_max_upload_filesize')) ); + + Display::addFlash(Display::return_message($warning , 'warning')); + return false; } $inbox_last_id = null; diff --git a/main/inc/lib/myspace.lib.php b/main/inc/lib/myspace.lib.php index 180875280c..30d5da4bcb 100644 --- a/main/inc/lib/myspace.lib.php +++ b/main/inc/lib/myspace.lib.php @@ -1,9 +1,9 @@ , Beeznest Team */ - public static function display_tracking_lp_progress_overview($sessionId = '', $courseId = '', $date_from, $date_to) { - + public static function display_tracking_lp_progress_overview($sessionId = '', $courseId = '', $date_from, $date_to) + { $course = api_get_course_info_by_id($courseId); /** * Column name @@ -552,6 +575,7 @@ class MySpace $return .= Display::grid_html($tableId); return $return; } + /** * Display a sortable table that contains an overview off all the progress of the user in a session * @param int $sessionId The session ID @@ -764,7 +788,7 @@ class MySpace get_lang('LastName'), ); //add lessons of course - $questions = survey_manager::get_questions($surveyId, $courseId); + $questions = SurveyManager::get_questions($surveyId, $courseId); foreach ($questions as $question) { $columns[] = $question['question']; @@ -1215,6 +1239,7 @@ class MySpace { $course_code = $row[0]; $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; // the table header $return = ''; @@ -1228,7 +1253,7 @@ class MySpace FROM $tbl_user AS u INNER JOIN $tbl_course_rel_user AS cu ON cu.user_id = u.user_id - WHERE cu.course_code = '".$course_code."' AND ISNULL(cu.role);"; + WHERE cu.c_id = '".$courseId."'"; $result = Database::query($sql); $time_spent = 0; $progress = 0; @@ -1377,7 +1402,7 @@ class MySpace FROM $tbl_user AS u INNER JOIN $tbl_course_rel_user AS cu ON cu.user_id = u.user_id - WHERE cu.course_code = '".$course_code."' AND ISNULL(cu.role);"; + WHERE cu.course_code = '".$course_code."'"; $result = Database::query($sql); $time_spent = 0; $progress = 0; @@ -1589,7 +1614,7 @@ class MySpace $sql = "SELECT * FROM $tbl_course AS c INNER JOIN $tbl_session_rel_course AS sc ON sc.course_code = c.code - WHERE sc.id_session = '".$session_id."';"; + WHERE sc.session_id = '".$session_id."';"; $result = Database::query($sql); while ($row = Database::fetch_object($result)) { $courseCode = $row->code; @@ -1599,11 +1624,11 @@ class MySpace // course code $return .= ' '; // get the users in the course - $sql = "SELECT user_id + $sql = "SELECT u.user_id FROM $tbl_user AS u INNER JOIN $tbl_session_rel_course_rel_user AS scu - ON u.user_id = scu.id_user - WHERE scu.id_session = '".$session_id."' AND scu.course_code = '".$courseCode."';"; + ON u.user_id = scu.user_id + WHERE scu.session_id = '".$session_id."' AND scu.c_id = '".$courseId."'"; $result_users = Database::query($sql); $time_spent = 0; $progress = 0; @@ -1749,7 +1774,7 @@ class MySpace $sql = "SELECT * FROM $tbl_course AS c INNER JOIN $tbl_session_rel_course AS sc ON sc.course_code = c.code - WHERE sc.id_session = '".$session_id."';"; + WHERE sc.session_id = '".$session_id."';"; $result = Database::query($sql); while ($row = Database::fetch_object($result)) { $courseInfo = api_get_course_info($row->code); @@ -1758,10 +1783,11 @@ class MySpace $csv_row[] = $session_title; $csv_row[] = $row->title; // get the users in the course - $sql = "SELECT user_id FROM $tbl_user AS u + $sql = "SELECT scu.user_id + FROM $tbl_user AS u INNER JOIN $tbl_session_rel_course_rel_user AS scu - ON u.user_id = scu.id_user - WHERE scu.id_session = '".$session_id."' AND scu.course_code = '".$row->code."';"; + ON u.user_id = scu.user_id + WHERE scu.session_id = '".$session_id."' AND scu.c_id = '".$courseId."'"; $result_users = Database::query($sql); $time_spent = 0; $progress = 0; @@ -1781,14 +1807,28 @@ class MySpace $progress += $progress_tmp[0]; $nb_progress_lp += $progress_tmp[1]; $score_tmp = Tracking :: get_avg_student_score($row_user->user_id, $row->code, array(), $session_id, true); - if(is_array($score_tmp)) { + if (is_array($score_tmp)) { $score += $score_tmp[0]; $nb_score_lp += $score_tmp[1]; } - $nb_messages += Tracking::count_student_messages($row_user->user_id, $row->code, $session_id); - $nb_assignments += Tracking::count_student_assignments($row_user->user_id, $row->code, $session_id); + $nb_messages += Tracking::count_student_messages( + $row_user->user_id, + $row->code, + $session_id + ); - $last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row_user->user_id, $courseId, $session_id, false); + $nb_assignments += Tracking::count_student_assignments( + $row_user->user_id, + $row->code, + $session_id + ); + + $last_login_date_tmp = Tracking:: get_last_connection_date_on_the_course( + $row_user->user_id, + $courseId, + $session_id, + false + ); if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. $last_login_date = $last_login_date_tmp; } else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned. @@ -2070,15 +2110,22 @@ class MySpace while ($row_course = Database::fetch_row($res)) { $course_code = $row_course[0]; $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; $avg_assignments_in_course = $avg_messages_in_course = $nb_students_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = $avg_score_in_exercise = 0; // students directly subscribed to the course if (empty($session_id)) { - $sql = "SELECT user_id FROM $tbl_course_user as course_rel_user - WHERE course_rel_user.status='5' AND course_rel_user.course_code='$course_code'"; + $sql = "SELECT user_id + FROM $tbl_course_user as course_rel_user + WHERE + course_rel_user.status='5' AND + course_rel_user.c_id = '$courseId'"; } else { - $sql = "SELECT id_user as user_id FROM $tbl_session_course_user srcu - WHERE srcu. course_code='$course_code' AND id_session = '$session_id' AND srcu.status<>2"; + $sql = "SELECT user_id FROM $tbl_session_course_user srcu + WHERE + c_id = '$courseId' AND + session_id = '$session_id' AND + status<>2"; } $rs = Database::query($sql); $users = array(); @@ -2281,10 +2328,10 @@ class MySpace /** * Checks whether a username has been already subscribed in a session. * @param string a given username - * @param array the array with the course list codes + * @param array the array with the course list id * @param the session id * @return 0 if the user is not subscribed otherwise it returns the user_id of the given username - * @author Julio Montoya Armas + * @author Julio Montoya */ public static function user_available_in_session($username, $course_list, $id_session) { @@ -2292,15 +2339,17 @@ class MySpace $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $id_session = intval($id_session); $username = Database::escape_string($username); - foreach($course_list as $enreg_course) { - $sql_select = " SELECT u.user_id FROM $tbl_session_rel_course_rel_user rel INNER JOIN $table_user u - ON (rel.id_user=u.user_id) - WHERE - rel.id_session='$id_session' AND - u.status='5' AND - u.username ='$username' AND - rel.course_code='$enreg_course'"; - $rs = Database::query($sql_select); + foreach ($course_list as $courseId) { + $courseId = intval($courseId); + $sql = " SELECT u.user_id FROM $tbl_session_rel_course_rel_user rel + INNER JOIN $table_user u + ON (rel.user_id = u.user_id) + WHERE + rel.session_id='$id_session' AND + u.status='5' AND + u.username ='$username' AND + rel.c_id='$courseId'"; + $rs = Database::query($sql); if (Database::num_rows($rs) > 0) { return Database::result($rs, 0, 0); } else { @@ -2310,14 +2359,19 @@ class MySpace } /** - This function checks whether some users in the uploaded file repeated and creates unique usernames if necesary. - A case: Within the file there is an user repeted twice (Julio Montoya / Julio Montoya) and the username fields are empty. - Then, this function would create unique usernames based on the first and the last name. Two users wiould be created - jmontoya and jmontoya2. - Of course, if in the database there is a user with the name jmontoya, the newly created two users registered would be jmontoya2 and jmontoya3. - @param $users list of users - @author Julio Montoya Armas + * This function checks whether some users in the uploaded file + * repeated and creates unique usernames if necesary. + * A case: Within the file there is an user repeted twice (Julio Montoya / Julio Montoya) + * and the username fields are empty. + * Then, this function would create unique usernames based on the first and the last name. + * Two users wiould be created - jmontoya and jmontoya2. + * Of course, if in the database there is a user with the name jmontoya, + * the newly created two users registered would be jmontoya2 and jmontoya3. + * @param $users list of users + * @author Julio Montoya Armas */ - function check_all_usernames($users, $course_list, $id_session) { + function check_all_usernames($users, $course_list, $id_session) + { $table_user = Database::get_main_table(TABLE_MAIN_USER); $usernames = array(); $new_users = array(); @@ -2356,20 +2410,21 @@ class MySpace } /** - * This functions checks whether there are users that are already registered in the DB by different creator than the current coach. + * This functions checks whether there are users that are already + * registered in the DB by different creator than the current coach. * @param string a given username - * @param array the array with the course list codes + * @param array the array with the course list ids * @param the session id * @author Julio Montoya Armas */ - function get_user_creator($users, $course_list, $id_session) { + public function get_user_creator($users) + { $errors = array(); foreach ($users as $index => $user) { // database table definition $table_user = Database::get_main_table(TABLE_MAIN_USER); $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $username = Database::escape_string($user['UserName']); - //echo "
    "; $sql = "SELECT creator_id FROM $table_user WHERE username='$username' "; $rs = Database::query($sql); @@ -2382,6 +2437,7 @@ class MySpace } } } + return $errors; } @@ -2431,17 +2487,19 @@ class MySpace if (!isset ($user['Password']) || strlen($user['Password']) == 0) { $user['Password'] = api_generate_password(); } + return $user; } /** * Saves imported data. */ - function save_data($users, $course_list, $id_session) { - $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); - $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); - $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); + public function save_data($users, $course_list, $id_session) + { + $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); + $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); + $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); $id_session = intval($id_session); $sendMail = $_POST['sendMail'] ? 1 : 0; @@ -2451,9 +2509,20 @@ class MySpace foreach ($users as $index => $user) { $user = MySpace::complete_missing_data($user); // coach only will registered users - $default_status = '5'; - if ($user['create'] == '1') { - $user['id'] = UserManager :: create_user($user['FirstName'], $user['LastName'], $default_status, $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], api_get_setting('PlatformLanguage'), $user['PhoneNumber'], ''); + $default_status = STUDENT; + if ($user['create'] == COURSEMANAGER) { + $user['id'] = UserManager:: create_user( + $user['FirstName'], + $user['LastName'], + $default_status, + $user['Email'], + $user['UserName'], + $user['Password'], + $user['OfficialCode'], + api_get_setting('PlatformLanguage'), + $user['PhoneNumber'], + '' + ); $user['added_at_platform'] = 1; } else { $user['id'] = $user['create']; @@ -2472,9 +2541,10 @@ class MySpace $enreg_course = Database::escape_string($enreg_course); foreach ($users as $index => $user) { $userid = intval($user['id']); - $sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user) VALUES('$id_session','$enreg_course','$userid')"; + $sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(session_id, c_id, user_id) + VALUES('$id_session','$enreg_course','$userid')"; $course_session = array('course' => $enreg_course, 'added' => 1); - //$user['added_at_session'] = $course_session; + $result = Database::query($sql); if (Database::affected_rows($result)) { $nbr_users++; @@ -2484,23 +2554,23 @@ class MySpace $super_list[] = $new_users; //update the nbr_users field - $sql_select = "SELECT COUNT(id_user) as nbUsers FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code='$enreg_course'"; + $sql_select = "SELECT COUNT(user_id) as nbUsers FROM $tbl_session_rel_course_rel_user + WHERE session_id='$id_session' AND c_id='$enreg_course'"; $rs = Database::query($sql_select); list($nbr_users) = Database::fetch_array($rs); - $sql_update = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'"; + $sql_update = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users + WHERE session_id='$id_session' AND c_id='$enreg_course'"; Database::query($sql_update); $sql_update = "UPDATE $tbl_session SET nbr_users= '$nbr_users' WHERE id='$id_session'"; Database::query($sql_update); } - // We don't delete the users (thoughts while dreaming) - //$sql_delete = "DELETE FROM $tbl_session_rel_user WHERE id_session = '$id_session'"; - //Database::query($sql_delete); $new_users = array(); foreach ($users as $index => $user) { $userid = $user['id']; - $sql_insert = "INSERT IGNORE INTO $tbl_session_rel_user(id_session, id_user) VALUES('$id_session','$userid')"; + $sql_insert = "INSERT IGNORE INTO $tbl_session_rel_user(session_id, user_id) + VALUES ('$id_session','$userid')"; Database::query($sql_insert); $user['added_at_session'] = 1; $new_users[] = $user; @@ -2514,7 +2584,17 @@ class MySpace $i = 0; foreach ($users as $index => $user) { $emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName'); - $emailbody = get_lang('Dear').' '.api_get_person_name($user['FirstName'], $user['LastName']).",\n\n".get_lang('YouAreReg')." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : $user[UserName]\n".get_lang('Pass')." : $user[Password]\n\n".get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is')." : ".api_get_path(WEB_PATH)." \n\n".get_lang('Problem')."\n\n".get_lang('SignatureFormula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n".get_lang('Manager')." ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n".get_lang('Email')." : ".api_get_setting('emailAdministrator').""; + $emailbody = get_lang('Dear').' '. + api_get_person_name($user['FirstName'], $user['LastName']).",\n\n". + get_lang('YouAreReg')." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings')."\n\n". + get_lang('Username')." : $user[UserName]\n". + get_lang('Pass')." : $user[Password]\n\n". + get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is')." : ".api_get_path(WEB_PATH)." \n\n". + get_lang('Problem')."\n\n". + get_lang('SignatureFormula').",\n\n". + api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n". + get_lang('Manager')." ".api_get_setting('siteName')."\nT. ". + api_get_setting('administratorTelephone')."\n".get_lang('Email')." : ".api_get_setting('emailAdministrator'); api_mail_html( api_get_person_name($user['FirstName'], $user['LastName'], null, PERSON_NAME_EMAIL_ADDRESS), @@ -2522,6 +2602,7 @@ class MySpace $emailsubject, $emailbody ); + $userInfo = api_get_user_info($user['id']); if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) { if ($user['added_at_platform'] == 1) { @@ -2533,15 +2614,18 @@ class MySpace if ($user['added_at_session'] == 1) { $addedto .= get_lang('UserInSession'); } - $registered_users .= "".api_get_person_name($user['FirstName'], $user['LastName'])." - ".$addedto.'
    '; } else { $addedto = get_lang('UserNotAdded'); - $registered_users .= "".api_get_person_name($user['FirstName'], $user['LastName'])." - ".$addedto.'
    '; } + + $registered_users .= UserManager::getUserProfileLink($userInfo)." - ".$addedto.'
    '; } } else { $i = 0; foreach ($users as $index => $user) { + + $userInfo = api_get_user_info($user['id']); + if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) { if ($user['added_at_platform'] == 1) { $addedto = get_lang('UserCreatedPlatform'); @@ -2552,19 +2636,15 @@ class MySpace if ($user['added_at_session'] == 1) { $addedto .= ' '.get_lang('UserInSession'); } - - $registered_users .= "".api_get_person_name($user['FirstName'], $user['LastName'])." - ".$addedto.'
    '; } else { $addedto = get_lang('UserNotAdded'); - $registered_users .= "".api_get_person_name($user['FirstName'], $user['LastName'])." - ".$addedto.'
    '; } + $registered_users .= "".api_get_person_name($user['FirstName'], $user['LastName'])." - ".$addedto.'
    '; } } header('Location: course.php?id_session='.$id_session.'&action=show_message&message='.urlencode($registered_users)); - exit (); - - //header('Location: resume_session.php?id_session='.$id_session); + exit; } /** @@ -2573,7 +2653,7 @@ class MySpace * @return array All userinformation read from the file */ function parse_csv_data($file) { - $users = Import :: csv_to_array($file); + $users = Import :: csvToArray($file); foreach ($users as $index => $user) { if (isset ($user['Courses'])) { $user['Courses'] = explode('|', trim($user['Courses'])); diff --git a/main/inc/lib/notebook.lib.php b/main/inc/lib/notebook.lib.php index 6327c6c711..cfa19781c8 100755 --- a/main/inc/lib/notebook.lib.php +++ b/main/inc/lib/notebook.lib.php @@ -71,8 +71,17 @@ class NotebookManager $id = Database::insert_id(); if ($id > 0) { + $sql = "UPDATE $t_notebook SET notebook_id = $id WHERE iid = $id"; + Database::query($sql); + //insert into item_property - api_item_property_update(api_get_course_info(), TOOL_NOTEBOOK, $id, 'NotebookAdded', api_get_user_id()); + api_item_property_update( + api_get_course_info(), + TOOL_NOTEBOOK, + $id, + 'NotebookAdded', + api_get_user_id() + ); } if (!empty($affected_rows)) { diff --git a/main/inc/lib/online.inc.php b/main/inc/lib/online.inc.php index f2e075c4ce..a5e923c6e7 100755 --- a/main/inc/lib/online.inc.php +++ b/main/inc/lib/online.inc.php @@ -17,7 +17,7 @@ * @return void */ -use \ChamiloSession as Session; +use ChamiloSession as Session; function LoginCheck($uid) { global $_course, $_configuration; @@ -38,9 +38,11 @@ function LoginCheck($uid) { // if the $_course array exists this means we are in a course and we have to store this in the who's online table also // to have the x users in this course feature working if (is_array($_course) && count($_course)>0 && !empty($_course['id'])) { - $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) VALUES ($uid,$uid,'$login_date','$user_ip', '".$_course['real_id']."' , '$session_id' , '$access_url_id' )"; + $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) + VALUES ($uid,$uid,'$login_date','$user_ip', '".$_course['real_id']."' , '$session_id' , '$access_url_id' )"; } else { - $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,user_ip, session_id, access_url_id) VALUES ($uid,$uid,'$login_date','$user_ip', '$session_id', '$access_url_id')"; + $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,user_ip, session_id, access_url_id) + VALUES ($uid,$uid,'$login_date','$user_ip', '$session_id', '$access_url_id')"; } @Database::query($query); } @@ -100,7 +102,7 @@ function online_logout($user_id = null, $logout_redirect = false) { $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); if (empty($user_id)) { - $user_id = intval($_GET['uid']); + $user_id = isset($_GET['uid']) ? intval($_GET['uid']) : 0; } //Changing global chat status to offline @@ -110,16 +112,21 @@ function online_logout($user_id = null, $logout_redirect = false) { } // selecting the last login of the user - $sql_last_connection="SELECT login_id, login_date FROM $tbl_track_login WHERE login_user_id=$user_id ORDER BY login_date DESC LIMIT 0,1"; - $q_last_connection=Database::query($sql_last_connection); + $sql = "SELECT login_id, login_date + FROM $tbl_track_login + WHERE login_user_id = $user_id + ORDER BY login_date DESC + LIMIT 0,1"; + $q_last_connection = Database::query($sql); if (Database::num_rows($q_last_connection)>0) { $i_id_last_connection=Database::result($q_last_connection,0,"login_id"); } if (!isset($_SESSION['login_as'])) { $current_date = api_get_utc_datetime(); - $s_sql_update_logout_date="UPDATE $tbl_track_login SET logout_date='".$current_date."' WHERE login_id='$i_id_last_connection'"; - Database::query($s_sql_update_logout_date); + $sql = "UPDATE $tbl_track_login SET logout_date='".$current_date."' + WHERE login_id='$i_id_last_connection'"; + Database::query($sql); } LoginDelete($user_id); //from inc/lib/online.inc.php - removes the "online" status @@ -310,13 +317,13 @@ function who_is_online_count($time_limit = null, $friends = false) $time_limit = intval($time_limit); } $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); - $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); - $table_user = Database::get_main_table(TABLE_MAIN_USER); + $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); + $table_user = Database::get_main_table(TABLE_MAIN_USER); $query = ''; - $online_time = time() - $time_limit*60; - $current_date = api_get_utc_datetime($online_time); + $online_time = time() - $time_limit * 60; + $current_date = api_get_utc_datetime($online_time); if ($friends) { // who friends from social network is online diff --git a/main/inc/lib/page.class.php b/main/inc/lib/page.class.php deleted file mode 100755 index 1b06ef4453..0000000000 --- a/main/inc/lib/page.class.php +++ /dev/null @@ -1,168 +0,0 @@ -title('my_title')->display($content); - * - * $page = Page::create()->title('my_title')->help('help')->content($content); - * $page->display(); - * - * @license see /license.txt - * @author Laurent Opprecht for the Univesity of Geneva - */ -class Page -{ - - protected $title = null; - protected $help = null; - protected $header = null; - protected $content; - protected $breadcrumbs = ''; - protected $message = null; - protected $warning = null; - protected $error = null; - - /** - * - * @return Page - */ - static function create($title = '') - { - return new self($title); - } - - function __construct($title = '') - { - $this->title = $title; - } - - /** - * - * @param $header - * @return Page - */ - function header($header) - { - $this->header = $header; - return $this; - } - - /** - * - * @param string $title - * @return Page - */ - function title($title) - { - $this->title = $title; - return $this; - } - - /** - * - * @param array $crumbs_ - * @return Page - */ - function breadcrumbs($crumbs) - { - $this->breadcrumbs = $crumbs; - return $this; - } - - /** - * - * @param string $help help file name - * @return Page - */ - function help($help) - { - $this->help = $help; - return $this; - } - - /** - * - * @param string $message - * @return Page - */ - function message($message) - { - $this->message = $message; - return $this; - } - - /** - * - * @param string $warning - * @return Page - */ - function warning($warning) - { - $this->warning = $warning; - return $this; - } - - /** - * - * @param string $error - * @return Page - */ - function error($error) - { - $this->error = $error; - return $this; - } - - /** - * - * @param object|string $content - * @return Page - */ - function content($content) - { - $this->content = $content; - return $this; - } - - function __toString() - { - $this->display($this->content); - } - - function display($content = null) - { - $this->display_header(); - $this->display_content($content); - $this->display_footer(); - } - - function display_header() - { - global $interbreadcrumb; - $interbreadcrumb = $this->breadcrumbs; - - Display::display_header($this->title, $this->help, $this->header); - if ($message = $this->message) { - Display::display_confirmation_message($message); - } - if ($warning = $this->warning) { - Display::display_warning_message($warning); - } - if ($error = $this->error) { - Display::display_error_message($error); - } - } - - protected function display_content($content) - { - $content = $content ? $content : $this->content; - echo $content; - } - - function display_footer() - { - Display::display_footer(); - } - -} \ No newline at end of file diff --git a/main/inc/lib/pdf.lib.php b/main/inc/lib/pdf.lib.php index 86ecb0a4fe..7d2dbb462e 100755 --- a/main/inc/lib/pdf.lib.php +++ b/main/inc/lib/pdf.lib.php @@ -112,7 +112,7 @@ class PDF ) { $teacher_list = SessionManager::getCoachesByCourseSessionToString( $this->params['session_info']['id'], - $this->params['course_code'] + $this->params['course_info']['real_id'] ); } else { diff --git a/main/inc/lib/plugin.class.php b/main/inc/lib/plugin.class.php index 56fd584509..55ac27f50b 100755 --- a/main/inc/lib/plugin.class.php +++ b/main/inc/lib/plugin.class.php @@ -438,7 +438,7 @@ class Plugin $result = Database::query($sql); if (!Database::num_rows($result)) { $tool_link = "$plugin_name/start.php"; - $visibility = string2binary(api_get_setting('course_create_active_tools', $plugin_name)); + $visibility = AddCourse::string2binary(api_get_setting('course_create_active_tools', $plugin_name)); $sql = "INSERT INTO $t_tool VALUES ($courseId, NULL, '$plugin_name', '$tool_link', '$plugin_name.png',' ".$visibility."','0', 'squaregrey.gif','NO','_self','plugin','0')"; Database::query($sql); diff --git a/main/inc/lib/plugin.lib.php b/main/inc/lib/plugin.lib.php index a768fa043b..455ed28688 100755 --- a/main/inc/lib/plugin.lib.php +++ b/main/inc/lib/plugin.lib.php @@ -29,7 +29,7 @@ class AppPlugin public $installedPluginListObject = array(); /** - * + * Constructor */ public function __construct() { @@ -183,6 +183,7 @@ class AppPlugin } else { $urlId = intval($urlId); } + // First call the custom uninstall to allow full access to global settings $pluginPath = api_get_path(SYS_PLUGIN_PATH).$pluginName.'/uninstall.php'; if (is_file($pluginPath) && is_readable($pluginPath)) { @@ -271,7 +272,8 @@ class AppPlugin } /** - * Loads the translation files inside a plugin if exists. It loads by default english see the hello world plugin + * Loads the translation files inside a plugin if exists. + * It loads by default english see the hello world plugin * * @param string $plugin_name * @@ -350,11 +352,11 @@ class AppPlugin $_template['plugin_info'] = $plugin_info; } - //Setting the plugin info available in the template if exists + // Setting the plugin info available in the template if exists $template->assign($plugin_name, $_template); - //Loading the Twig template plugin files if exists + // Loading the Twig template plugin files if exists $template_list = array(); if (isset($plugin_info) && isset($plugin_info['templates'])) { $template_list = $plugin_info['templates']; @@ -372,6 +374,7 @@ class AppPlugin } } } + return true; } @@ -422,6 +425,7 @@ class AppPlugin } $plugin_info['settings'] = $settings_filtered; $plugin_data[$plugin_name] = $plugin_info; + return $plugin_info; } } @@ -464,7 +468,19 @@ class AppPlugin public function add_to_region($plugin, $region) { $access_url_id = api_get_current_access_url_id(); - api_add_setting($plugin, $region, $plugin, 'region', 'Plugins', $plugin, null, null, null, $access_url_id, 1); + api_add_setting( + $plugin, + $region, + $plugin, + 'region', + 'Plugins', + $plugin, + null, + null, + null, + $access_url_id, + 1 + ); } /** @@ -516,7 +532,7 @@ class AppPlugin ICON_SIZE_SMALL ); } - //$icon = null; + $form->addElement('html', '

    '.$icon.' '.Security::remove_XSS($pluginTitle).'

    '); $groups = array(); @@ -555,6 +571,7 @@ class AppPlugin $courseSettings = array_merge($courseSettings, $pluginCourseSetting); } } + return $courseSettings; } @@ -591,13 +608,31 @@ class AppPlugin * Get first SMS plugin name * @return string|boolean */ - public function getSMSPluginName() { + public function getSMSPluginName() + { $installedPluginsList = $this->getInstalledPluginListObject(); foreach ($installedPluginsList as $installedPlugin) { if ($installedPlugin->isMailPlugin) { + return get_class($installedPlugin); } } + + return false; + } + + /** + * @return SmsPluginLibraryInterface + */ + public function getSMSPluginLibrary() + { + $className = $this->getSMSPluginName(); + $className = str_replace("Plugin", "", $className); + + if (class_exists($className)) { + return new $className; + } + return false; } } diff --git a/main/inc/lib/portfolio.class.php b/main/inc/lib/portfolio.class.php index 2ce09caefc..e100d9a1fb 100755 --- a/main/inc/lib/portfolio.class.php +++ b/main/inc/lib/portfolio.class.php @@ -2,8 +2,8 @@ /* For licensing terms, see /license.txt */ /* * This file contains several classes related to portfolios management to avoid - * having too much files under the lib/. - * + * having too much files under the lib/. + * * Once external libraries are moved to their own directory it would be worth * moving them to their own files under a common portfolio directory. * @package chamilo.portfolio @@ -16,19 +16,19 @@ use Model\Course; /** * A portfolio is used to present content to other people. In most cases it is - * an external application. - * + * an external application. + * * From the application point of view it is an end point to which the user can send * content. - * + * * Available portfolios are configured in /main/inc/config/portfolio.conf.php - * + * * The Portfolio class serves as an entry point to other portfolio components: - * + * * - portfolio controller * - portfolio share button * - portfolio action - * + * * Note: * @author Laurent Opprecht for the Univesity of Geneva */ @@ -38,12 +38,12 @@ class Portfolio /** * Returns all portfolios available - * + * * @return array */ public static function all() { - $conf = Chamilo::path('/main/inc/conf/portfolio.conf.php'); + $conf = api_get_path(SYS_CODE_PATH).'inc/conf/portfolio.conf.php'; if (!is_readable($conf)) { return array(); } @@ -53,7 +53,7 @@ class Portfolio /** * Returns a portfolio from its name. - * + * * @param string $name * @return Portfolio\Portfolio */ @@ -70,8 +70,8 @@ class Portfolio /** * True if portfolios are enabled. False otherwise. - * - * @return boolean + * + * @return boolean */ public static function is_enabled() { @@ -91,8 +91,8 @@ class Portfolio /** * The controller for portfolio. - * - * @return \PortfolioController + * + * @return \PortfolioController */ public static function controller() { @@ -101,11 +101,11 @@ class Portfolio /** * Returns a share component/button. - * + * * @param string $tool * @param int $id * @param array $attributes - * @return \PortfolioShare + * @return \PortfolioShare */ public static function share($tool, $id, $attributes = array()) { @@ -114,8 +114,8 @@ class Portfolio /** * Returns the list of actions. - * - * @return array + * + * @return array */ public static function actions() { @@ -124,9 +124,9 @@ class Portfolio /** * Returns a temporary url to download files and/or folders. - * + * * @param string|array $ids - * @return string + * @return string */ public static function download_url($ids, $tool) { @@ -143,14 +143,14 @@ class Portfolio /** * The portfolio controller. Responsible to dispatch/process portfolio actions. - * + * * Usage: - * + * * if(Porfolio::contoller()->accept()){ * Portfolio::controller()->run(); * } - * - * + * + * */ class PortfolioController { @@ -166,7 +166,7 @@ class PortfolioController /** * - * @return \PortfolioController + * @return \PortfolioController */ static function instance() { @@ -181,7 +181,7 @@ class PortfolioController protected function __construct() { - + } public static function portfolios() @@ -190,9 +190,9 @@ class PortfolioController } /** - * List of actions for the SortableTable. - * - * @return array + * List of actions for the SortableTable. + * + * @return array */ public static function actions() { @@ -216,10 +216,10 @@ class PortfolioController } /** - * Returns true if the controller accept to process the current request. + * Returns true if the controller accept to process the current request. * Returns false otherwise. - * - * @return boolean + * + * @return boolean */ function accept() { @@ -249,8 +249,8 @@ class PortfolioController /** * Returns the value of the current controller request parameters. That is - * the name of the controller which shall handle the current request. - * + * the name of the controller which shall handle the current request. + * * @return string */ function get_controller() @@ -261,8 +261,8 @@ class PortfolioController /** * Returns the value of the action parameter. That is which action shall be * performed. That is share to send an object to a portfolio. - * - * @return string + * + * @return string */ function get_action() { @@ -272,7 +272,7 @@ class PortfolioController /** * Returns the value of the id parameter: id of object to send. - * + * * @return int */ function get_id() @@ -282,7 +282,7 @@ class PortfolioController /** * The course code (id) to which the object belongs. - * + * * @return string */ function course_code() @@ -292,8 +292,8 @@ class PortfolioController /** * The name of the porfolio where to send. - * - * @return type + * + * @return type */ function get_portfolio() { @@ -302,9 +302,9 @@ class PortfolioController /** * Name of the tool: document, work, etc. Defaults to current_course_tool. - * + * * @global string $current_course_tool - * @return string + * @return string */ function get_tool() { @@ -322,12 +322,12 @@ class PortfolioController } /** - * Execute the controller action as required. If a registered action accept + * Execute the controller action as required. If a registered action accept * the current request the controller calls it. - * + * * If not action is accept the current request and current action is "share" * the controller execute the "send to portfolio" action - * + * * @return PortfolioController */ function run() @@ -373,28 +373,28 @@ class PortfolioController /** * This component is used to display a "send to portfolio" button for a specific - * object. - * - * Note that the component implement the __toString() magic method and can be + * object. + * + * Note that the component implement the __toString() magic method and can be * therefore used in situation where a string is expected: for ex echo $button. - * + * * Usage - * + * * $button = Portfolio::share(...); * echo $button; - * + * */ class PortfolioShare { /** * Create a "send to portfolio" button - * + * * @param string $tool The name of the tool: document, work. * @param int $c_id The id of the course - * @param int $id The id of the object + * @param int $id The id of the object * @param array $attributes Html attributes - * @return \PortfolioShare + * @return \PortfolioShare */ static function factory($tool, $id, $attributes = array()) { @@ -404,8 +404,8 @@ class PortfolioShare /** * Returns the current secuirty token. Used to avoid see surfing attacks. - * - * @return type + * + * @return type */ static function security_token() { @@ -446,8 +446,8 @@ class PortfolioShare } /** - * Html attributes. - * + * Html attributes. + * * @return array */ function get_attributes() @@ -457,7 +457,7 @@ class PortfolioShare /** * Name of the tool. I.e. the type of the id parameter. Can be document, work. - * + * * @return string */ function get_tool() @@ -467,8 +467,8 @@ class PortfolioShare /** * Display the component. - * - * @return string + * + * @return string */ function display() { @@ -503,7 +503,7 @@ class PortfolioShare $parameters[PortfolioController::PARAM_TOOL] = $this->get_tool(); $parameters[PortfolioController::PARAM_ID] = $id; $parameters[PortfolioController::PARAM_TOOL] = $tool; - $url = Chamilo::url('/main/portfolio/share.php', $parameters); + $url = api_get_path(WEB_CODE_PATH).'portfolio/share.php?'; $result[] = '
  • '; $result[] = '' . $portfolio->get_title() . ''; $result[] = '
  • '; @@ -522,15 +522,15 @@ class PortfolioShare } /** - * A "send to this portfolio" action. Actions are used by the SortableTable to + * A "send to this portfolio" action. Actions are used by the SortableTable to * perform actions on a set of objects. An action is composed of - * + * * - a name * - a title (displayed to the user) * - code to execute - * + * * Usage: - * + * * $form_actions = array(); * $form_action['...'] = get_lang('...'); * $portfolio_actions = Portfolio::actions(); @@ -538,7 +538,7 @@ class PortfolioShare * $form_action[$action->get_name()] = $action->get_title(); * } * $table->set_form_actions($form_action, 'path'); - * + * * @see SortableTable */ class PortfolioBulkAction @@ -560,7 +560,7 @@ class PortfolioBulkAction /** * - * @param \Portfolio\Portfolio $portfolio + * @param \Portfolio\Portfolio $portfolio */ public function __construct($portfolio) { diff --git a/main/inc/lib/redirect.class.php b/main/inc/lib/redirect.class.php index 7ceb99ca97..d0bfd1c280 100755 --- a/main/inc/lib/redirect.class.php +++ b/main/inc/lib/redirect.class.php @@ -12,7 +12,7 @@ class Redirect */ public static function www() { - return Uri::www(); + return api_get_path(WEB_PATH); } /** @@ -141,7 +141,6 @@ class Redirect */ protected static function navigate($url) { - //$url = Security::remove_XSS($url); session_write_close(); //should not be neeeded header("Location: $url"); exit; diff --git a/main/inc/lib/response.class.php b/main/inc/lib/response.class.php deleted file mode 100755 index 5d46185765..0000000000 --- a/main/inc/lib/response.class.php +++ /dev/null @@ -1,23 +0,0 @@ - for the Univesity of Geneva - */ -class Response -{ - - public static function not_found() - { - Header::response_code(404); - exit; - } - -} \ No newline at end of file diff --git a/main/inc/lib/result_set.class.php b/main/inc/lib/result_set.class.php deleted file mode 100755 index daa79bdb88..0000000000 --- a/main/inc/lib/result_set.class.php +++ /dev/null @@ -1,194 +0,0 @@ - for the Univesity of Geneva - * @deprecated - */ -class ResultSet implements Countable, Iterator -{ - - /** - * - * @param string $sql - * @return ResultSet - */ - static function create($sql) - { - return new self($sql); - } - - protected $sql = ''; - protected $handle = null; - protected $current = false; - protected $index = -1; - protected $count = false; - protected $limit_count = null; - protected $limit_offset = null; - protected $orderby_column = null; - protected $orderby_direction = null; - protected $return_type = null; - - function __construct($sql, $limit_count = null, $limit_offset = null, $orderby_column = null, $orderby_direction = null, $return_type = null) - { - $this->sql = $sql; - $this->limit_count = $limit_count; - $this->limit_offset = $limit_offset; - $this->orderby_column = $orderby_column; - $this->orderby_direction = $orderby_direction; - $this->return_type = $return_type; - } - - public function sql() - { - $sql = $this->sql; - - $column = $this->orderby_column; - $direction = $this->orderby_direction; - - $offset = $this->limit_offset; - $count = $this->limit_count; - if (is_null($column) && is_null($count) && is_null($offset)) { - return $sql; - } - - if (strpos($sql, ' ORDER ') || strpos($sql, ' LIMIT ') || strpos($sql, ' OFFSET ')) { - $sql = "SELECT * FROM ($sql) AS dat "; - } else { - $sql .= ' '; - } - - if ($column) { - $sql .= "ORDER BY $column $direction "; - } - - if ($count) { - $sql .= "LIMIT $count "; - } - if ($offset) { - $sql .= "OFFSET $offset"; - } - - return $sql; - } - - protected function handle() - { - if (is_null($this->handle)) { - $this->handle = Database::query($this->sql()); - } - - return $this->handle; - } - - public function count() - { - if ($this->count === false) { - $sql = $this->sql(); - $sql = "SELECT COUNT(*) AS alpha FROM ($sql) AS dat "; - $rs = Database :: query($sql); - $data = Database::fetch_array($rs); - $count = $data ? $data['alpha'] : 0; - $this->count = (int) $count; - } - return $this->count; - } - - public function first() - { - foreach ($this as $item) { - return $item; - } - return null; - } - - /** - * - * @param int $count - * @param int $from - * @return ResultSet - */ - public function limit($count, $from = 0) - { - $result = clone($this); - $result->limit_offset = $from; - $result->limit_count = $count; - return $result; - } - - /** - * - * @param int $column - * @param int $dir - * @return ResultSet - */ - public function orderby($column, $dir = 'ASC') - { - $result = clone($this); - $result->orderby_column = $column; - $result->orderby_direction = $dir; - return $result; - } - - public function return_type($value) - { - $result = clone($this); - $result->return_type = $value; - return $result; - } - - public function current() - { - return $this->current; - } - - public function key() - { - return $this->index; - } - - public function next() - { - $data = Database::fetch_assoc($this->handle()); - if (!$data) { - $this->current = $this->return_type ? null : array(); - } else if (empty($this->return_type)) { - $this->current = $data; - } else if ($this->return_type == 'object') { - $this->current = (object) $data; - } else { - $this->current = new $this->return_type($data); - } - $this->index++; - return $this->current; - } - - public function rewind() - { - $this->handle = null; - $this->current = false; - $this->index = -1; - $this->next(); - } - - public function valid() - { - return !empty($this->current); - } - - function __clone() - { - $this->reset(); - } - - function reset() - { - $this->handle = null; - $this->current = false; - $this->index = -1; - $this->count = false; - } - -} diff --git a/main/inc/lib/rights.lib.php b/main/inc/lib/rights.lib.php index e1c614d8a4..5fbca40af0 100755 --- a/main/inc/lib/rights.lib.php +++ b/main/inc/lib/rights.lib.php @@ -1,9 +1,13 @@ + 'show_tabs:reports' => array ( 'type' => 'const', 'const' => 'true' ) @@ -12,7 +16,7 @@ class Rights { // warning the goal of this function is to enforce rights managment in Chamilo // thus default return value is always true public static function hasRight($handler) { - if (array_key_exists($handler, self::$rights_cache)) + if (array_key_exists($handler, self::$rights_cache)) return self::$rights_cache[$handler]; if (!array_key_exists($handler, self::$rights)) @@ -20,7 +24,7 @@ class Rights { if (self::$rights[$handler]['type'] == 'sql') { $result = Database::query(self::$rights[$handler]['sql']); - if (Database::num_rows($result) > 0) + if (Database::num_rows($result) > 0) $result = true; else $result = false; @@ -33,7 +37,7 @@ class Rights { self::$rights_cache[$handler] = $result; return $result; } - + public static function hasRightClosePageWithError($handler) { if (hasRight($handler) == false) die("You are not allowed here"); //FIXME diff --git a/main/inc/lib/session_handler.class.php b/main/inc/lib/session_handler.class.php deleted file mode 100755 index 5bfedfdced..0000000000 --- a/main/inc/lib/session_handler.class.php +++ /dev/null @@ -1,151 +0,0 @@ -lifetime = 60; // 60 minutes - - $this->connection = array( - 'server' => $_configuration['db_host'], - 'login' => $_configuration['db_user'], - 'password' => $_configuration['db_password'], - 'base' => $_configuration['main_database'] - ); - - $this->connection_handler = false; - } - - public function sqlConnect() { - - if (!$this->connection_handler) { - $this->connection_handler = @mysql_connect($this->connection['server'], $this->connection['login'], $this->connection['password'], true); - - // The system has not been designed to use special SQL modes that were introduced since MySQL 5 - @mysql_query("set session sql_mode='';", $this->connection_handler); - - @mysql_select_db($this->connection['base'], $this->connection_handler); - - // Initialization of the database connection encoding to be used. - // The internationalization library should be already initialized. - @mysql_query("SET SESSION character_set_server='utf8';", $this->connection_handler); - @mysql_query("SET SESSION collation_server='utf8_general_ci';", $this->connection_handler); - $system_encoding = api_get_system_encoding(); - if (api_is_utf8($system_encoding)) { - // See Bug #1802: For UTF-8 systems we prefer to use "SET NAMES 'utf8'" statement in order to avoid a bizarre problem with Chinese language. - @mysql_query("SET NAMES 'utf8';", $this->connection_handler); - } else { - @mysql_query("SET CHARACTER SET '" . Database::to_db_encoding($system_encoding) . "';", $this->connection_handler); - } - } - - return $this->connection_handler ? true : false; - } - - public function sqlClose() { - - if ($this->connection_handler) { - mysql_close($this->connection_handler); - $this->connection_handler = false; - return true; - } - - return false; - } - - public function sqlQuery($query, $die_on_error = true) { - - $result = mysql_query($query, $this->connection_handler); - - if ($die_on_error && !$result) { - $this->sqlClose(); - return; - } - - return $result; - } - - public function open($path, $name) { - - $this->session_name = $name; - return true; - } - - public function close() { - return $this->garbage(0) ? true : false; - } - - public function read($sess_id) { - - if ($this->sqlConnect()) { - $result = $this->sqlQuery("SELECT session_value FROM ".$this->connection['base'].".php_session WHERE session_id='$sess_id'"); - - if ($row = mysql_fetch_assoc($result)) { - return $row['session_value']; - } - } - - return ''; - } - - public function write($sess_id, $sess_value) { - $time = time(); - - if ($this->sqlConnect()) { - - $result = $this->sqlQuery("INSERT INTO ".$this->connection['base'].".php_session(session_id,session_name,session_time,session_start,session_value) VALUES('$sess_id','".$this->session_name."','$time','$time','".addslashes($sess_value)."')", false); - - if (!$result) { - $this->sqlQuery("UPDATE ".$this->connection['base'].".php_session SET session_name='".$this->session_name."',session_time='$time',session_value='".addslashes($sess_value)."' WHERE session_id='$sess_id'"); - } - - return true; - } - - return false; - } - - public function destroy($sess_id) { - - if ($this->sqlConnect()) { - $this->sqlQuery("DELETE FROM ".$this->connection['base'].".php_session WHERE session_id='$sess_id'"); - return true; - } - - return false; - } - - public function garbage($lifetime) { - - if ($this->sqlConnect()) { - - $result = $this->sqlQuery("SELECT COUNT(session_id) FROM ".$this->connection['base'].".php_session"); - list($nbr_results) = Database::fetch_row($result); - - if ($nbr_results > 5000) { - $this->sqlQuery("DELETE FROM ".$this->connection['base'].".php_session WHERE session_time<'".strtotime('-'.$this->lifetime.' minutes')."'"); - } - - $this->sqlClose(); - - return true; - } - - return false; - } -} diff --git a/main/inc/lib/session_handler_memcache.class.php b/main/inc/lib/session_handler_memcache.class.php deleted file mode 100644 index 7f7bc5d2eb..0000000000 --- a/main/inc/lib/session_handler_memcache.class.php +++ /dev/null @@ -1,203 +0,0 @@ -memcache = new Memcache; - if (!empty($_configuration['memcache_server'])) { - foreach ($_configuration['memcache_server'] as $serverData) { - $isServerAvailable = @fsockopen($serverData['host'], $serverData['port']); - if (!$isServerAvailable){ - continue; - } - $this->memcache->addServer($serverData['host'], $serverData['port']); - } - } - $this->lifetime = 3600; // 60 minutes - - $this->connection = array ( - 'server' => $_configuration['db_host'], - 'login' => $_configuration['db_user'], - 'password' => $_configuration['db_password'], - 'base' => $_configuration['main_database'] - ); - - $this->connection_handler = false; - } - - public function sqlConnect() - { - if (!$this->connection_handler) { - $this->connection_handler = @mysql_connect($this->connection['server'], $this->connection['login'], $this->connection['password'], true); - - // The system has not been designed to use special SQL modes that were introduced since MySQL 5 - @mysql_query("set session sql_mode='';", $this->connection_handler); - - @mysql_select_db($this->connection['base'], $this->connection_handler); - - // Initialization of the database connection encoding to be used. - // The internationalization library should be already initialized. - @mysql_query("SET SESSION character_set_server='utf8';", $this->connection_handler); - @mysql_query("SET SESSION collation_server='utf8_general_ci';", $this->connection_handler); - $system_encoding = api_get_system_encoding(); - if (api_is_utf8($system_encoding)) { - // See Bug #1802: For UTF-8 systems we prefer to use "SET NAMES 'utf8'" statement in order to avoid a bizarre problem with Chinese language. - @mysql_query("SET NAMES 'utf8';", $this->connection_handler); - } else { - @mysql_query("SET CHARACTER SET '" . Database::to_db_encoding($system_encoding) . "';", $this->connection_handler); - } - } - - return ($this->connection_handler) ? true : false; - } - - public function sqlClose() - { - - if ($this->connection_handler) { - mysql_close($this->connection_handler); - $this->connection_handler = false; - return true; - } - - return false; - } - - public function sqlQuery($query, $dieOnError = true) - { - $result = mysql_query($query, $this->connection_handler); - if ($dieOnError && !$result) { - $this->sqlClose(); - return; - } - - return $result; - } - - public function open($savePath, $sessionName) - { - $sessionID = session_id(); - if ($sessionID !== "") { - $this->initSessionData = $this->read($sessionID); - $this->session_name = $sessionName; - } - return true; - } - - public function close() - { - $this->lifeTime = null; - $this->memcache = null; - $this->initSessionData = null; - - return $this->gc(0) ? true : false; - } - - public function read($sessionID) - { - $data = $this->memcache->get($sessionID); - if (($data === false || empty($data)) && $this->sqlConnect()) { - $result = $this->sqlQuery("SELECT session_value FROM ".$this->connection['base'].".php_session WHERE session_id='$sessionID'"); - if (!empty($result) && $result !== false && $row = Database::fetch_row($result)) { - $data = stripslashes($row[0]); - $this->memcache->set($sessionID, $data); - } else { - $data = false; - } - } else { - $data = stripslashes($data); - } - - return $data; - } - - public function write($sessionID, $data) - { - global $_configuration; - - $this->memcache->set($sessionID, $data); - if ($this->memcache->get('interactions-' . $sessionID) !== false) { - $interactions = $this->memcache->get('interactions-' . $sessionID); - ++$interactions; - if ($_configuration['session_stored_after_n_times'] < $interactions) { - $interactions = 1; - } - $this->memcache->set('interactions-' . $sessionID, $interactions); - } else { - $this->memcache->set('interactions-' . $sessionID, 1); - } - - $interactions = $this->memcache->get('interactions-' . $sessionID); - //$this->initSessionData !== $data #avoid this validation for performance improvements - - if ($_configuration['session_stored_after_n_times'] === $interactions) { - $sessionID = mysql_real_escape_string($sessionID); - $sessionExpirationTS = ($this->lifetime + time()); - $sessionData = mysql_real_escape_string($data); - - if ($this->sqlConnect()) { - $result = $this->sqlQuery("INSERT INTO ".$this->connection['base'].".php_session( - session_id,session_name,session_time,session_start,session_value) - VALUES('$sessionID','".$this->session_name."','$sessionExpirationTS','$sessionExpirationTS','".addslashes($sessionData)."')", false); - - if (!$result) { - $this->sqlQuery("UPDATE ".$this->connection['base'].".php_session - SET session_name='".$this->session_name."',session_time='$sessionExpirationTS',session_value='".addslashes($sessionData)."' - WHERE session_id='$sessionID'"); - } - return true; - } - } - - return false; - } - - public function destroy($sessionID) - { - $this->memcache->delete($sessionID); - if ($this->sqlConnect()) { - $this->sqlQuery("DELETE FROM ".$this->connection['base'].".php_session WHERE session_id='$sessionID'"); - return true; - } - - return false; - } - - public function gc($maxlifetime) - { - if ($this->sqlConnect()) { - $result = $this->sqlQuery("SELECT COUNT(session_id) FROM ".$this->connection['base'].".php_session"); - list($nbr_results) = Database::fetch_row($result); - - if ($nbr_results > 5000) { - $this->sqlQuery("DELETE FROM ".$this->connection['base'].".php_session WHERE session_time<'".strtotime('-'.$this->lifetime.' minutes')."'"); - } - - $this->sqlClose(); - - return true; - } - - return false; - } -} diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index 8023cc571e..a6e5d99e74 100755 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -183,11 +183,14 @@ class SessionManager 'session_admin_id' => api_get_user_id(), '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, 'description' => $description, 'show_description' => intval($showDescription) ); + + if (!empty($id_session_category)) { + $values['session_category_id'] = $id_session_category; + } $session_id = Database::insert($tbl_session, $values); $duration = intval($duration); @@ -276,13 +279,13 @@ class SessionManager ) { $where .= " AND ( s.session_admin_id = $user_id OR - sru.id_user = '$user_id' AND + sru.user_id = '$user_id' AND sru.relation_type = '" . SESSION_RELATION_TYPE_RRHH . "' ) "; $extraJoin = " INNER JOIN $tbl_session_rel_user sru - ON sru.id_session = s.id "; + ON sru.session_id = s.id "; } $today = api_get_utc_datetime(); @@ -311,8 +314,8 @@ class SessionManager if (strpos($where_condition, 'c.id')) { $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); - $courseCondition = " INNER JOIN $table course_rel_session ON (s.id = course_rel_session.id_session) - INNER JOIN $tableCourse c ON (course_rel_session.course_code = c.code) + $courseCondition = " INNER JOIN $table course_rel_session ON (s.id = course_rel_session.session_id) + INNER JOIN $tableCourse c ON (course_rel_session.c_id = c.id) "; } @@ -392,13 +395,13 @@ class SessionManager ) { $where .= " AND ( s.session_admin_id = $user_id OR - sru.id_user = '$user_id' AND + sru.user_id = '$user_id' AND sru.relation_type = '" . SESSION_RELATION_TYPE_RRHH . "' ) "; $extraJoin = " INNER JOIN $tbl_session_rel_user sru - ON sru.id_session = s.id "; + ON sru.session_id = s.id "; } if (api_is_allowed_to_edit() && !api_is_platform_admin()) { @@ -433,8 +436,8 @@ class SessionManager if (strpos($options['where'], 'c.id')) { $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); - $courseCondition = " INNER JOIN $table course_rel_session ON (s.id = course_rel_session.id_session) - INNER JOIN $tableCourse c ON (course_rel_session.course_code = c.code) + $courseCondition = " INNER JOIN $table course_rel_session ON (s.id = course_rel_session.session_id) + INNER JOIN $tableCourse c ON (course_rel_session.c_id = c.id) "; } @@ -597,13 +600,12 @@ class SessionManager $users = CourseManager :: get_student_list_from_course_code($course_code, true, $sessionId); } */ - $sessionCond = 'and id_session = %s'; + $sessionCond = 'and session_id = %s'; if ($sessionId == 'T') { $sessionCond = ""; } - $where = " WHERE course_code = '%s' - AND s.status <> 2 $sessionCond"; + $where = " WHERE c_id = '%s' AND s.status <> 2 $sessionCond"; $limit = null; if (!empty($options['limit'])) { @@ -619,12 +621,14 @@ class SessionManager $order = " ORDER BY " . $options['order']; } - $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.course_code + $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.c_id FROM $session_course_user s - INNER JOIN $user u ON u.user_id = s.id_user - $where $order $limit"; + INNER JOIN $user u ON u.user_id = s.user_id + $where + $order + $limit"; - $sql_query = sprintf($sql, Database::escape_string($course['code']), $sessionId); + $sql_query = sprintf($sql, Database::escape_string($course['real_id']), $sessionId); $rs = Database::query($sql_query); while ($user = Database::fetch_array($rs)) { @@ -683,6 +687,7 @@ class SessionManager } $table[] = $data; } + return $table; } @@ -715,7 +720,7 @@ class SessionManager $course = api_get_course_info_by_id($courseId); - $where = " WHERE course_code = '%s' AND s.status <> 2 AND id_session = %s"; + $where = " WHERE c_id = '%s' AND s.status <> 2 AND session_id = %s"; $limit = null; if (!empty($options['limit'])) { @@ -737,19 +742,19 @@ class SessionManager AND s.avail_till <= '%s'", $date_from, $date_to); } */ - $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.course_code + $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.c_id FROM $session_course_user s - INNER JOIN $user u ON u.user_id = s.id_user + INNER JOIN $user u ON u.user_id = s.user_id $where $order $limit"; - $sql_query = sprintf($sql, Database::escape_string($course['code']), $sessionId); + $sql_query = sprintf($sql, intval($course['real_id']), $sessionId); $rs = Database::query($sql_query); while ($user = Database::fetch_array($rs)) { $users[$user['user_id']] = $user; } //Get survey questions - $questions = survey_manager::get_questions($surveyId, $courseId); + $questions = SurveyManager::get_questions($surveyId, $courseId); //Survey is anonymous? $result = Database::query(sprintf("SELECT anonymous FROM $c_survey WHERE survey_id = %d", $surveyId)); @@ -822,7 +827,6 @@ class SessionManager //tables $session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $user = Database::get_main_table(TABLE_MAIN_USER); - $course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); $workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION); $workTableAssignment = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); $forum = Database::get_course_table(TABLE_FORUM); @@ -844,7 +848,7 @@ class SessionManager // Registered students in session. $users = CourseManager :: get_student_list_from_course_code($course_code, true, $sessionId); } */ - $where = " WHERE course_code = '%s' AND s.status <> 2 "; + $where = " WHERE c_id = '%s' AND s.status <> 2 "; $limit = null; if (!empty($options['limit'])) { @@ -861,23 +865,23 @@ class SessionManager } //TODO, fix create report without session - $queryVariables = array($course['code']); + $queryVariables = array($course['real_id']); if (!empty($sessionId)) { - $where .= ' AND id_session = %s'; + $where .= ' AND session_id = %s'; $queryVariables[] = $sessionId; $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, - u.email, s.course_code, s.id_session + u.email, s.c_id, s.session_id FROM $session_course_user s INNER JOIN $user u - ON u.user_id = s.id_user + ON u.user_id = s.user_id $where $order $limit"; } else { $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, - u.email, s.course_code, s.id_session + u.email, s.c_id, s.session_id FROM $session_course_user s - INNER JOIN $user u ON u.user_id = s.id_user + INNER JOIN $user u ON u.user_id = s.user_id $where $order $limit"; } @@ -895,14 +899,11 @@ class SessionManager $result = Database::query($sql_query); $arrLesson = array(array()); while ($row = Database::fetch_array($result)) { -// if (api_get_item_visibility(api_get_course_info($course['code']), 'learnpath', $row['id'], $row['session_id'])) -// { if (empty($arrLesson[$row['session_id']]['lessons_total'])) { $arrLesson[$row['session_id']]['lessons_total'] = 1; } else { $arrLesson[$row['session_id']]['lessons_total'] ++; } -// } } /** @@ -958,11 +959,11 @@ class SessionManager * Surveys */ $survey_user_list = array(); - $survey_list = survey_manager::get_surveys($course['code'], $sessionId); + $survey_list = SurveyManager::get_surveys($course['code'], $sessionId); $surveys_total = count($survey_list); foreach ($survey_list as $survey) { - $user_list = survey_manager::get_people_who_filled_survey( + $user_list = SurveyManager::get_people_who_filled_survey( $survey['survey_id'], false, $course['real_id'] @@ -1444,7 +1445,9 @@ class SessionManager $values['id_coach'] = $id_coach; $values['nb_days_access_before_beginning'] = $nb_days_acess_before; $values['nb_days_access_after_end'] = $nb_days_acess_after; - $values['session_category_id'] = $id_session_category; + if (!empty($id_session_category)) { + $values['session_category_id'] = $id_session_category; + } $values['description'] = $description; $values['show_description'] = intval($showDescription); $values['visibility'] = $id_visibility; @@ -1470,7 +1473,7 @@ class SessionManager * @param boolean optional, true if the function is called by a webservice, false otherwise. * @return void Nothing, or false on error * */ - public static function delete_session($id_checked, $from_ws = false) + public static function delete($id_checked, $from_ws = false) { $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); @@ -1488,18 +1491,19 @@ class SessionManager } if (!api_is_platform_admin() && !$from_ws) { - $sql = 'SELECT session_admin_id FROM ' . Database :: get_main_table(TABLE_MAIN_SESSION) . ' WHERE id IN (' . $id_checked.')'; + $sql = 'SELECT session_admin_id FROM ' . $tbl_session. ' + WHERE id IN (' . $id_checked.')'; $rs = Database::query($sql); if (Database::result($rs, 0, 0) != $userId) { api_not_allowed(true); } } - Database::query("DELETE FROM $tbl_session WHERE id IN($id_checked)"); - Database::query("DELETE FROM $tbl_session_rel_course WHERE id_session IN($id_checked)"); - Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session IN($id_checked)"); - Database::query("DELETE FROM $tbl_session_rel_user WHERE id_session IN($id_checked)"); + Database::query("DELETE FROM $tbl_session_rel_course WHERE session_id IN($id_checked)"); + Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE session_id IN($id_checked)"); + Database::query("DELETE FROM $tbl_session_rel_user WHERE session_id IN($id_checked)"); Database::query("DELETE FROM $tbl_url_session WHERE session_id IN($id_checked)"); + Database::query("DELETE FROM $tbl_session WHERE id IN ($id_checked)"); $sql_delete_sfv = "DELETE FROM $t_sfv WHERE session_id = '$id_checked'"; Database::query($sql_delete_sfv); @@ -1580,20 +1584,20 @@ class SessionManager } } - $sql = "SELECT id_user FROM $tbl_session_rel_course_rel_user - WHERE id_session = '$id_session' AND status = 0"; + $sql = "SELECT user_id FROM $tbl_session_rel_course_rel_user + WHERE session_id = '$id_session' AND status = 0"; $result = Database::query($sql); $existingUsers = array(); while ($row = Database::fetch_array($result)) { - $existingUsers[] = $row['id_user']; + $existingUsers[] = $row['user_id']; } - $sql = "SELECT course_code FROM $tbl_session_rel_course - WHERE id_session = '$id_session'"; + $sql = "SELECT c_id FROM $tbl_session_rel_course + WHERE session_id = '$id_session'"; $result = Database::query($sql); $course_list = array(); while ($row = Database::fetch_array($result)) { - $course_list[] = $row['course_code']; + $course_list[] = $row['c_id']; } if ($send_email) { @@ -1601,7 +1605,7 @@ class SessionManager if (is_array($user_list) && count($user_list) > 0) { foreach ($user_list as $user_id) { if (!in_array($user_id, $existingUsers)) { - $subject = '[' . get_setting('siteName') . '] ' . get_lang('YourReg') . ' ' . get_setting('siteName'); + $subject = '[' . api_get_setting('siteName') . '] ' . get_lang('YourReg') . ' ' . api_get_setting('siteName'); $user_info = api_get_user_info($user_id); $content = get_lang('Dear') . " " . stripslashes($user_info['complete_name']) . ",\n\n" . sprintf(get_lang('YouAreRegisterToSessionX'), $session_name) . " \n\n" . get_lang('Address') . " " . get_setting('siteName') . " " . get_lang('Is') . " : " . api_get_path(WEB_PATH) . "\n\n" . get_lang('Problem') . "\n\n" . get_lang('SignatureFormula') . ",\n\n" . get_setting('administratorName') . " " . get_setting('administratorSurname') . "\n" . get_lang('Manager') . " " . get_setting('siteName') . "\nT. " . get_setting('administratorTelephone') . "\n" . get_lang('Email') . " : " . get_setting('emailAdministrator'); MessageManager::send_message( @@ -1621,17 +1625,22 @@ class SessionManager } } - foreach ($course_list as $enreg_course) { + foreach ($course_list as $courseId) { // for each course in the session $nbr_users = 0; - $enreg_course = Database::escape_string($enreg_course); + $courseId = intval($courseId); - $sql = "SELECT DISTINCT id_user FROM $tbl_session_rel_course_rel_user - WHERE id_session = '$id_session' AND course_code='$enreg_course' AND status = 0"; + $sql = "SELECT DISTINCT user_id + FROM $tbl_session_rel_course_rel_user + WHERE + session_id = '$id_session' AND + c_id = '$courseId' AND + status = 0 + "; $result = Database::query($sql); $existingUsers = array(); while ($row = Database::fetch_array($result)) { - $existingUsers[] = $row['id_user']; + $existingUsers[] = $row['user_id']; } // Delete existing users @@ -1639,7 +1648,11 @@ class SessionManager foreach ($existingUsers as $existing_user) { if (!in_array($existing_user, $user_list)) { $sql = "DELETE FROM $tbl_session_rel_course_rel_user - WHERE id_session='$id_session' AND course_code='$enreg_course' AND id_user='$existing_user' AND status = 0"; + WHERE + session_id =' $id_session' AND + c_id = '$courseId' AND + user_id = '$existing_user' AND + status = 0 "; $result = Database::query($sql); if (Database::affected_rows($result)) { $nbr_users--; @@ -1653,8 +1666,8 @@ class SessionManager foreach ($user_list as $enreg_user) { if (!in_array($enreg_user, $existingUsers)) { $enreg_user = Database::escape_string($enreg_user); - $sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session, course_code, id_user, visibility, status) - VALUES('$id_session','$enreg_course','$enreg_user','$session_visibility', '0')"; + $sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user (session_id, c_id, user_id, visibility, status) + VALUES('$id_session', '$courseId', '$enreg_user', '$session_visibility', '0')"; $result = Database::query($sql); if (Database::affected_rows($result)) { $nbr_users++; @@ -1663,30 +1676,32 @@ class SessionManager } // Count users in this session-course relation - $sql = "SELECT COUNT(id_user) as nbUsers FROM $tbl_session_rel_course_rel_user - WHERE id_session='$id_session' AND course_code='$enreg_course' AND status<>2"; + $sql = "SELECT COUNT(user_id) as nbUsers + FROM $tbl_session_rel_course_rel_user + WHERE session_id = '$id_session' AND c_id = '$courseId' AND status<>2"; $rs = Database::query($sql); list($nbr_users) = Database::fetch_array($rs); // update the session-course relation to add the users total $sql = "UPDATE $tbl_session_rel_course SET nbr_users = $nbr_users - WHERE id_session='$id_session' AND course_code = '$enreg_course'"; + WHERE session_id ='$id_session' AND c_id = '$courseId'"; Database::query($sql); } // Delete users from the session if ($empty_users === true) { $sql = "DELETE FROM $tbl_session_rel_user - WHERE id_session = $id_session AND relation_type<>" . SESSION_RELATION_TYPE_RRHH . ""; + WHERE session_id = $id_session AND relation_type<>" . SESSION_RELATION_TYPE_RRHH . ""; Database::query($sql); } // Insert missing users into session $nbr_users = 0; + foreach ($user_list as $enreg_user) { $enreg_user = Database::escape_string($enreg_user); $nbr_users++; - $sql = "INSERT IGNORE INTO $tbl_session_rel_user (id_session, id_user) - VALUES ('$id_session', '$enreg_user')"; + $sql = "INSERT IGNORE INTO $tbl_session_rel_user (relation_type, session_id, user_id) + VALUES (0, '$id_session', '$enreg_user')"; Database::query($sql); } @@ -1698,7 +1713,7 @@ class SessionManager WHERE id='$id_session' "; Database::query($sql); } else { - $sql = "UPDATE $tbl_session SET nbr_users= nbr_users + $nbr_users + $sql = "UPDATE $tbl_session SET nbr_users = nbr_users + $nbr_users WHERE id='$id_session'"; Database::query($sql); } @@ -1719,6 +1734,7 @@ class SessionManager ) { $sessionId = intval($sessionId); $courseCode = $courseInfo['code']; + $courseId = $courseInfo['real_id']; if (empty($sessionId) || empty($courseCode)) { return array(); @@ -1732,18 +1748,19 @@ class SessionManager $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); - $sql = "SELECT DISTINCT id_user + $sql = "SELECT DISTINCT user_id FROM $table WHERE - id_session = '$sessionId' AND - course_code='$courseCode' + session_id = '$sessionId' AND + c_id = '$courseId' $statusCondition "; $result = Database::query($sql); $existingUsers = array(); while ($row = Database::fetch_array($result)) { - $existingUsers[] = $row['id_user']; + $existingUsers[] = $row['user_id']; } + return $existingUsers; } @@ -1772,6 +1789,7 @@ class SessionManager } $courseCode = Database::escape_string($courseInfo['code']); + $courseId = $courseInfo['real_id']; $statusCondition = null; if (isset($status) && !is_null($status)) { @@ -1783,9 +1801,9 @@ class SessionManager $userId = intval($userId); $sql = "DELETE FROM $table WHERE - id_session='$sessionId' AND - course_code='$courseCode' AND - id_user='$userId' + session_id='$sessionId' AND + c_id = '$courseId' AND + user_id = '$userId' $statusCondition "; Database::query($sql); @@ -1793,19 +1811,21 @@ class SessionManager if ($updateTotal) { // Count users in this session-course relation - $sql = "SELECT COUNT(id_user) as nbUsers + $sql = "SELECT COUNT(user_id) as nbUsers FROM $table WHERE - id_session='$sessionId' AND - course_code='$courseCode' AND - status<>2"; + session_id ='$sessionId' AND + c_id = '$courseId' AND + status <>2"; $result = Database::query($sql); list($userCount) = Database::fetch_array($result); // update the session-course relation to add the users total - $sql = "UPDATE $tableSessionCourse SET - nbr_users = $userCount - WHERE id_session='$sessionId' AND course_code = '$courseCode'"; + $sql = "UPDATE $tableSessionCourse + SET nbr_users = $userCount + WHERE + session_id ='$sessionId' AND + c_id = '$courseId'"; Database::query($sql); } } @@ -1838,10 +1858,13 @@ class SessionManager $session_id = intval($session_id); $course_code = Database::escape_string($course_code); + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + $session_visibility = intval($session_visibility); if ($removeUsersNotInList) { - $courseInfo = api_get_course_info($course_code); + $currentUsers = self::getUsersByCourseSession($session_id, $courseInfo, 0); if (!empty($user_list)) { @@ -1865,12 +1888,12 @@ class SessionManager foreach ($user_list as $enreg_user) { $enreg_user = intval($enreg_user); // Checking if user exists in session - course - user table. - $sql = "SELECT count(id_user) as count + $sql = "SELECT count(user_id) as count FROM $tbl_session_rel_course_rel_user WHERE - id_session = $session_id AND - course_code = '$course_code' and - id_user = $enreg_user "; + session_id = $session_id AND + c_id = '$courseId' and + user_id = $enreg_user "; $result = Database::query($sql); $count = 0; @@ -1880,8 +1903,8 @@ class SessionManager } if ($count == 0) { - $sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user (id_session, course_code, id_user, visibility) - VALUES ('$session_id','$course_code','$enreg_user','$session_visibility')"; + $sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user (session_id, c_id, user_id, visibility) + VALUES ('$session_id', '$courseId', '$enreg_user', '$session_visibility')"; $result = Database::query($sql); if (Database::affected_rows($result)) { $nbr_users++; @@ -1889,9 +1912,9 @@ class SessionManager } // Checking if user exists in session - user table. - $sql = "SELECT count(id_user) as count + $sql = "SELECT count(user_id) as count FROM $tbl_session_rel_user - WHERE id_session = $session_id AND id_user = $enreg_user "; + WHERE session_id = $session_id AND user_id = $enreg_user "; $result = Database::query($sql); $count = 0; @@ -1902,25 +1925,26 @@ class SessionManager if (empty($count)) { // If user is not registered to a session then add it. - $sql = "INSERT IGNORE INTO $tbl_session_rel_user (id_session, id_user) + $sql = "INSERT IGNORE INTO $tbl_session_rel_user (session_id, user_id) VALUES ('$session_id', '$enreg_user')"; Database::query($sql); $sql = "UPDATE $tbl_session SET nbr_users = nbr_users + 1 - WHERE id='$session_id' "; + WHERE id = '$session_id' "; Database::query($sql); } } // count users in this session-course relation - $sql = "SELECT COUNT(id_user) as nbUsers + $sql = "SELECT COUNT(user_id) as nbUsers FROM $tbl_session_rel_course_rel_user - WHERE id_session='$session_id' AND course_code='$course_code' AND status<>2"; + WHERE session_id ='$session_id' AND c_id='$courseId' AND status<>2"; $rs = Database::query($sql); list($nbr_users) = Database::fetch_array($rs); // update the session-course relation to add the users total - $sql = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users - WHERE id_session='$session_id' AND course_code='$course_code'"; + $sql = "UPDATE $tbl_session_rel_course + SET nbr_users=$nbr_users + WHERE session_id='$session_id' AND c_id = '$courseId'"; Database::query($sql); } @@ -1943,8 +1967,8 @@ class SessionManager $delete_sql = "DELETE FROM $tbl_session_rel_user WHERE - id_session = '$session_id' AND - id_user ='$user_id' AND + session_id = '$session_id' AND + user_id ='$user_id' AND relation_type <> " . SESSION_RELATION_TYPE_RRHH . ""; $result = Database::query($delete_sql); $return = Database::affected_rows($result); @@ -1960,15 +1984,15 @@ class SessionManager if (!empty($course_list)) { foreach ($course_list as $course) { - $course_code = $course['code']; + $courseId = $course['id']; // Delete user from course $sql = "DELETE FROM $tbl_session_rel_course_rel_user - WHERE id_session='$session_id' AND course_code='$course_code' AND id_user='$user_id'"; + WHERE session_id ='$session_id' AND c_id = '$courseId' AND user_id = '$user_id'"; $result = Database::query($sql); if (Database::affected_rows($result)) { // Update number of users in this relation $sql = "UPDATE $tbl_session_rel_course SET nbr_users = nbr_users - 1 - WHERE id_session='$session_id' AND course_code='$course_code'"; + WHERE session_id ='$session_id' AND c_id = '$courseId'"; Database::query($sql); } } @@ -1981,7 +2005,7 @@ class SessionManager * unsubscribes previous users * @author Carlos Vargas from existing code * @param int $sessionId - * @param array $courseList List of courses IDs + * @param array $courseList List of courses int ids * @param bool $removeExistingCoursesUsers Whether to unsubscribe * existing courses and users (true, default) or not (false) * @return void Nothing, or false on error @@ -2002,35 +2026,36 @@ class SessionManager $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); - // get list of courses subscribed to this session - $sql = "SELECT course_code + // Get list of courses subscribed to this session + $sql = "SELECT c_id FROM $tbl_session_rel_course - WHERE id_session=$sessionId"; + WHERE session_id = $sessionId"; $rs = Database::query($sql ); $existingCourses = Database::store_result($rs); $nbr_courses = count($existingCourses); // get list of users subscribed to this session - $sql = "SELECT id_user + $sql = "SELECT user_id FROM $tbl_session_rel_user WHERE - id_session = $sessionId AND + session_id = $sessionId AND relation_type<>" . SESSION_RELATION_TYPE_RRHH . ""; $result = Database::query($sql); $user_list = Database::store_result($result); // Remove existing courses from the session. - if ($removeExistingCoursesWithUsers === true) { + if ($removeExistingCoursesWithUsers === true && !empty($existingCourses)) { + foreach ($existingCourses as $existingCourse) { - if (!in_array($existingCourse['course_code'], $courseList)) { - $courseInfo = api_get_course_info($existingCourse['course_code']); + if (!in_array($existingCourse['c_id'], $courseList)) { + $courseInfo = api_get_course_info($existingCourse['c_id']); $sql = "DELETE FROM $tbl_session_rel_course - WHERE course_code='" . $existingCourse['course_code'] . "' AND id_session=$sessionId"; + WHERE c_id = '" . $existingCourse['c_id'] . "' AND session_id = $sessionId"; Database::query($sql); $sql = "DELETE FROM $tbl_session_rel_course_rel_user - WHERE course_code='" . $existingCourse['course_code'] . "' AND id_session=$sessionId"; + WHERE c_id = '" . $existingCourse['c_id'] . "' AND session_id = $sessionId"; Database::query($sql); CourseManager::remove_course_ranking( @@ -2044,32 +2069,33 @@ class SessionManager } // Pass through the courses list we want to add to the session - foreach ($courseList as $enreg_course) { - $enreg_course = Database::escape_string($enreg_course); + foreach ($courseList as $courseId) { + $exists = false; // check if the course we want to add is already subscribed foreach ($existingCourses as $existingCourse) { - if ($enreg_course == $existingCourse['course_code']) { + if ($courseId == $existingCourse['c_id']) { $exists = true; } } if (!$exists) { //if the course isn't subscribed yet - $sql = "INSERT INTO $tbl_session_rel_course (id_session, course_code) - VALUES ('$sessionId','$enreg_course')"; + $sql = "INSERT INTO $tbl_session_rel_course (session_id, c_id) + VALUES ('$sessionId', '$courseId')"; Database::query($sql); - //We add the current course in the existing courses array, to avoid adding another time the current course - $existingCourses[] = array('course_code' => $enreg_course); + // We add the current course in the existing courses array, + // to avoid adding another time the current course + $existingCourses[] = array('c_id' => $courseId); $nbr_courses++; // subscribe all the users from the session to this course inside the session $nbr_users = 0; foreach ($user_list as $enreg_user) { - $enreg_user_id = intval($enreg_user['id_user']); - $sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user (id_session, course_code, id_user) - VALUES ($sessionId,'$enreg_course',$enreg_user_id)"; + $enreg_user_id = intval($enreg_user['user_id']); + $sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user (session_id, c_id, user_id) + VALUES ($sessionId, '$courseId', $enreg_user_id)"; $result = Database::query($sql); if (Database::affected_rows($result)) { $nbr_users++; @@ -2077,7 +2103,7 @@ class SessionManager } $sql = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users - WHERE id_session='$sessionId' AND course_code='$enreg_course'"; + WHERE session_id ='$sessionId' AND c_id='$courseId'"; Database::query($sql); } } @@ -2106,6 +2132,7 @@ class SessionManager // Get course code $course_code = CourseManager::get_course_code_from_course_id($course_id); + $course_id = intval($course_id); if (empty($course_code)) { return false; @@ -2113,12 +2140,12 @@ class SessionManager // Unsubscribe course $sql = "DELETE FROM $tbl_session_rel_course - WHERE course_code='$course_code' AND id_session='$session_id'"; + WHERE c_id = '$course_id' AND session_id='$session_id'"; $result = Database::query($sql); $nb_affected = Database::affected_rows($result); $sql = "DELETE FROM $tbl_session_rel_course_rel_user - WHERE course_code='$course_code' AND id_session='$session_id'"; + WHERE c_id = '$course_id' AND session_id='$session_id'"; Database::query($sql); if ($nb_affected > 0) { @@ -2256,17 +2283,17 @@ class SessionManager /** * Checks the relationship between a session and a course. * @param int $session_id - * @param string $course_id (course code) + * @param int $courseId * @return bool Returns TRUE if the session and the course are related, FALSE otherwise. * */ - public static function relation_session_course_exist($session_id, $course_id) + public static function relation_session_course_exist($session_id, $courseId) { $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $return_value = false; - $sql = "SELECT course_code FROM $tbl_session_course + $sql = "SELECT c_id FROM $tbl_session_course WHERE - id_session = " . intval($session_id) . " AND - course_code = '" . Database::escape_string($course_id) . "'"; + session_id = " . intval($session_id) . " AND + c_id = '" . intval($courseId) . "'"; $result = Database::query($sql); $num = Database::num_rows($result); if ($num > 0) { @@ -2442,9 +2469,9 @@ class SessionManager $session_id = $rows['id']; if ($delete_session) { if ($from_ws) { - SessionManager::delete_session($session_id, true); + SessionManager::delete($session_id, true); } else { - SessionManager::delete_session($session_id); + SessionManager::delete($session_id); } } } @@ -2498,8 +2525,8 @@ class SessionManager INNER JOIN $user_table u ON s.id_coach = u.user_id INNER JOIN $table_access_url_rel_session ar ON ar.session_id = s.id LEFT JOIN $session_category_table sc ON s.session_category_id = sc.id - LEFT JOIN $session_course_table sco ON (sco.id_session = s.id) - INNER JOIN $course_table c ON sco.course_code = c.code + LEFT JOIN $session_course_table sco ON (sco.session_id = s.id) + INNER JOIN $course_table c ON sco.c_id = c.id WHERE ar.access_url_id = $access_url_id "; $availableFields = array( @@ -2595,14 +2622,14 @@ class SessionManager * Assign a coach to course in session with status = 2 * @param int - user id * @param int - session id - * @param string - course code + * @param int - $courseId * @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 */ public static function set_coach_to_course_session( $user_id, $session_id = 0, - $course_code = '', + $courseId = '', $nocoach = false ) { // Definition of variables @@ -2614,10 +2641,10 @@ class SessionManager $session_id = api_get_session_id(); } - if (!empty($course_code)) { - $course_code = Database::escape_string($course_code); + if (!empty($courseId)) { + $courseId = intval($courseId); } else { - $course_code = api_get_course_id(); + $courseId = api_get_course_id(); } // Table definition @@ -2626,7 +2653,8 @@ class SessionManager $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'"; + $sql = "SELECT * FROM $tbl_user + WHERE status='1' AND user_id = '$user_id'"; $rs_check_user = Database::query($sql); @@ -2634,16 +2662,22 @@ class SessionManager if ($nocoach) { // check if user_id exists in session_rel_user (if the user is // subscribed to the session in any manner) - $sql = "SELECT id_user FROM $tbl_session_rel_user - WHERE id_session = '$session_id' AND id_user = '$user_id'"; + $sql = "SELECT user_id FROM $tbl_session_rel_user + WHERE + session_id = '$session_id' AND + user_id = '$user_id' "; $res = Database::query($sql); if (Database::num_rows($res) > 0) { // The user is already subscribed to the session. Change the // record so the user is NOT a coach for this course anymore // and then exit - $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' "; + $sql = "UPDATE $tbl_session_rel_course_rel_user + SET status = 0 + WHERE + session_id = '$session_id' AND + c_id = '$courseId' AND + user_id = '$user_id' "; $result = Database::query($sql); if (Database::affected_rows($result) > 0) return true; @@ -2654,7 +2688,10 @@ class SessionManager // he isn't subscribed to a course in this session either // and then exit $sql = "DELETE FROM $tbl_session_rel_course_rel_user - WHERE id_session = '$session_id' AND course_code = '$course_code' AND id_user = '$user_id' "; + WHERE + session_id = '$session_id' AND + c_id = '$courseId' AND + user_id = '$user_id' "; $result = Database::query($sql); if (Database::affected_rows($result) > 0) return true; @@ -2664,14 +2701,20 @@ class SessionManager } else { // Assign user as a coach to course // First check if the user is registered to 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'"; + $sql = "SELECT user_id FROM $tbl_session_rel_course_rel_user + WHERE + session_id = '$session_id' AND + c_id = '$courseId' AND + user_id = '$user_id'"; $rs_check = Database::query($sql); // 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' "; + WHERE + session_id = '$session_id' AND + c_id = '$courseId' AND + user_id = '$user_id' "; $result = Database::query($sql); if (Database::affected_rows($result) > 0) { return true; @@ -2679,8 +2722,8 @@ class SessionManager 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)"; + $sql = "INSERT INTO $tbl_session_rel_course_rel_user(session_id, c_id, user_id, status) + VALUES('$session_id', '$courseId', '$user_id', 2)"; $result = Database::query($sql); if (Database::affected_rows($result) > 0) { return true; @@ -2728,16 +2771,16 @@ class SessionManager // Deleting assigned sessions to hrm_id. if ($removeOldConnections) { if (api_is_multiple_url_enabled()) { - $sql = "SELECT id_session + $sql = "SELECT session_id FROM $tbl_session_rel_user s - INNER JOIN $tbl_session_rel_access_url a ON (a.session_id = s.id_session) + INNER JOIN $tbl_session_rel_access_url a ON (a.session_id = s.session_id) WHERE - id_user = $userId AND + s.user_id = $userId AND relation_type=" . SESSION_RELATION_TYPE_RRHH . " AND access_url_id = " . api_get_current_access_url_id() . ""; } else { - $sql = "SELECT id_session FROM $tbl_session_rel_user s - WHERE id_user = $userId AND relation_type=" . SESSION_RELATION_TYPE_RRHH . ""; + $sql = "SELECT session_id FROM $tbl_session_rel_user s + WHERE user_id = $userId AND relation_type=" . SESSION_RELATION_TYPE_RRHH . ""; } $result = Database::query($sql); @@ -2745,8 +2788,8 @@ class SessionManager while ($row = Database::fetch_array($result)) { $sql = "DELETE FROM $tbl_session_rel_user WHERE - id_session = {$row['id_session']} AND - id_user = $userId AND + session_id = {$row['session_id']} AND + user_id = $userId AND relation_type=" . SESSION_RELATION_TYPE_RRHH . " "; Database::query($sql); } @@ -2757,7 +2800,7 @@ class SessionManager foreach ($sessions_list as $session_id) { $session_id = intval($session_id); - $sql = "INSERT IGNORE INTO $tbl_session_rel_user (id_session, id_user, relation_type) + $sql = "INSERT IGNORE INTO $tbl_session_rel_user (session_id, user_id, relation_type) VALUES ($session_id, $userId, '" . SESSION_RELATION_TYPE_RRHH . "')"; Database::query($sql); $affected_rows++; @@ -2793,11 +2836,11 @@ class SessionManager $select = " SELECT * "; if (api_is_multiple_url_enabled()) { $sql = " $select FROM $tbl_session s - INNER JOIN $tbl_session_rel_user sru ON (sru.id_session = s.id) + INNER JOIN $tbl_session_rel_user sru ON (sru.session_id = s.id) LEFT JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id) WHERE - sru.id_user = '$userId' AND - sru.id_session = '$sessionId' AND + sru.user_id = '$userId' AND + sru.session_id = '$sessionId' AND sru.relation_type = '" . SESSION_RELATION_TYPE_RRHH . "' AND access_url_id = " . api_get_current_access_url_id() . " "; @@ -2805,18 +2848,21 @@ class SessionManager $sql = "$select FROM $tbl_session s INNER JOIN $tbl_session_rel_user sru ON - sru.id_session = s.id AND - sru.id_user = '$userId' AND - sru.id_session = '$sessionId' AND + sru.session_id = s.id AND + sru.user_id = '$userId' AND + sru.session_id = '$sessionId' AND sru.relation_type = '" . SESSION_RELATION_TYPE_RRHH . "' - "; + "; } + $result = Database::query($sql); if (Database::num_rows($result)) { $row = Database::fetch_array($result, 'ASSOC'); $row['course_list'] = self::get_course_list_by_session_id($sessionId); + return $row; } + return array(); } @@ -2918,27 +2964,27 @@ class SessionManager switch ($status) { case DRH: - $sessionQuery = "SELECT sru.id_session + $sessionQuery = "SELECT sru.session_id FROM $tbl_session_rel_user sru WHERE sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."' AND - sru.id_user = $userId"; + sru.user_id = $userId"; break; case COURSEMANAGER: $courseSessionQuery = " - SELECT scu.id_session as id + SELECT scu.session_id as id FROM $tbl_session_rel_course_rel_user scu - WHERE (scu.status = 2 AND scu.id_user = $userId)"; + WHERE (scu.status = 2 AND scu.user_id = $userId)"; $whereConditions = " OR (s.id_coach = $userId) "; break; default: - $sessionQuery = "SELECT sru.id_session + $sessionQuery = "SELECT sru.session_id FROM $tbl_session_rel_user sru WHERE - sru.id_user = $userId"; + sru.user_id = $userId"; break; } @@ -2985,6 +3031,7 @@ class SessionManager $sessions[$row['id']] = $row; } } + return $sessions; } @@ -3014,10 +3061,10 @@ class SessionManager } // select the courses - $sql = "SELECT * FROM $tbl_course c + $sql = "SELECT *, c.id as real_id FROM $tbl_course c INNER JOIN $tbl_session_rel_course src - ON c.code = src.course_code - WHERE src.id_session = '$session_id' "; + ON c.id = src.c_id + WHERE src.session_id = '$session_id' "; if (!empty($course_name)) { $course_name = Database::escape_string($course_name); @@ -3050,6 +3097,7 @@ class SessionManager $courses[$row['id']] = $row; } } + return $courses; } @@ -3107,9 +3155,9 @@ class SessionManager $sql = "$select FROM $tbl_course c INNER JOIN $tbl_session_rel_course src - ON c.code = src.course_code + ON c.id = src.c_id WHERE - src.id_session IN ($sessionsSQL) + src.session_id IN ($sessionsSQL) $keywordCondition "; if ($getCount) { @@ -3133,6 +3181,7 @@ class SessionManager $courses[$row['id']] = $row; } } + return $courses; } @@ -3153,8 +3202,8 @@ class SessionManager // select the courses $sql = "SELECT * FROM $tbl_course c INNER JOIN $tbl_session_rel_course src - ON c.code = src.course_code - WHERE src.id_session LIKE '$session_id'"; + ON c.id = src.c_id + WHERE src.session_id LIKE '$session_id'"; if (!empty($course_name)) { $sql .= " AND UPPER(c.title) LIKE UPPER('%$course_name%') "; } @@ -3168,6 +3217,7 @@ class SessionManager $courses[$row['id']] = $row; } } + return $courses; } @@ -3187,8 +3237,8 @@ class SessionManager $sql = "SELECT COUNT(c.code) count FROM $tbl_course c INNER JOIN $tbl_session_rel_course src - ON c.code = src.course_code - WHERE src.id_session = '$session_id' "; + ON c.id = src.c_id + WHERE src.session_id = '$session_id' "; $keywordCondition = null; if (!empty($keyword)) { @@ -3203,6 +3253,7 @@ class SessionManager $row = Database::fetch_array($result,'ASSOC'); return $row['count']; } + return null; } @@ -3251,12 +3302,19 @@ class SessionManager $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); $table_access_url_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); - $sql = "SELECT u.user_id, lastname, firstname, username, relation_type, access_url_id + $sql = "SELECT + u.user_id, + lastname, + firstname, + username, + relation_type, + access_url_id FROM $tbl_user u INNER JOIN $tbl_session_rel_user - ON u.user_id = $tbl_session_rel_user.id_user AND - $tbl_session_rel_user.id_session = $id - LEFT OUTER JOIN $table_access_url_user uu ON (uu.user_id = u.user_id) + ON u.user_id = $tbl_session_rel_user.user_id AND + $tbl_session_rel_user.session_id = $id + LEFT OUTER JOIN $table_access_url_user uu + ON (uu.user_id = u.user_id) "; $urlId = api_get_current_access_url_id(); @@ -3269,12 +3327,15 @@ class SessionManager $sql .= " ORDER BY relation_type, "; $sql .= api_sort_by_first_name() ? ' firstname, lastname' : ' lastname, firstname'; + $result = Database::query($sql); - $return_array = array(); + + $return = array(); while ($row = Database::fetch_array($result, 'ASSOC')) { - $return_array[] = $row; + $return[] = $row; } - return $return_array; + + return $return; } /** @@ -3304,6 +3365,7 @@ class SessionManager } $sql .= ' ORDER by name'; $result = Database::query($sql); + return Database::store_result($result, 'ASSOC'); } @@ -3320,20 +3382,20 @@ class SessionManager /** * @param int $user_id - * @param string $course_code + * @param int $courseId * @param int $session_id * @return array|bool */ - public static function get_user_status_in_course_session($user_id, $course_code, $session_id) + public static function get_user_status_in_course_session($user_id, $courseId, $session_id) { $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $sql = "SELECT session_rcru.status 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($session_id) . "' AND - session_rcru.course_code ='" . Database::escape_string($course_code) . "' AND + session_rcru.user_id = user.user_id AND + session_rcru.session_id = '" . intval($session_id) . "' AND + session_rcru.c_id ='" . intval($courseId) . "' AND user.user_id = " . intval($user_id); $result = Database::query($sql); @@ -3342,29 +3404,30 @@ class SessionManager $status = Database::fetch_row($result); $status = $status['0']; } + return $status; } /** * Gets user status within a session - * @param $user_id - * @param $course_code + * @param int $user_id + * @param int $courseId * @param $session_id * @return int * @assert (null,null,null) === false */ - public static function get_user_status_in_session($user_id, $course_code, $session_id) + public static function get_user_status_in_session($user_id, $courseId, $session_id) { - if (empty($user_id) or empty($course_code) or empty($session_id)) { + if (empty($user_id) or empty($courseId) or empty($session_id)) { return false; } $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $sql = "SELECT session_rcru.status 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($session_id) . "' AND - session_rcru.course_code ='" . Database::escape_string($course_code) . "' AND + WHERE session_rcru.user_id = user.user_id AND + session_rcru.session_id = '" . intval($session_id) . "' AND + session_rcru.c_id ='" . intval($courseId) . "' AND user.user_id = " . intval($user_id); $result = Database::query($sql); $status = false; @@ -3494,7 +3557,16 @@ class SessionManager $params['skip_lp_dates'] = true; foreach ($short_courses as $course_data) { - $course_info = CourseManager::copy_course_simple($course_data['title'] . ' ' . get_lang('CopyLabelSuffix'), $course_data['course_code'], $id, $sid, $params); + $course_info = CourseManager::copy_course_simple( + $course_data['title'].' '.get_lang( + 'CopyLabelSuffix' + ), + $course_data['course_code'], + $id, + $sid, + $params + ); + if ($course_info) { //By default new elements are invisible if ($set_exercises_lp_invisible) { @@ -3512,12 +3584,12 @@ class SessionManager $sql = "UPDATE $quiz_table SET active = 0 WHERE c_id = $course_id "; $result = Database::query($sql); } - $new_short_courses[] = $course_info['code']; + $new_short_courses[] = $course_info['real_id']; } } } else { foreach ($short_courses as $course_data) { - $new_short_courses[] = $course_data['code']; + $new_short_courses[] = $course_data['id']; } } @@ -3617,19 +3689,20 @@ class SessionManager } /** - * @param string $course_code + * @param int $courseId * @return array */ - public static function get_session_by_course($course_code) + public static function get_session_by_course($courseId) { $table_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $table_session = Database::get_main_table(TABLE_MAIN_SESSION); - $course_code = Database::escape_string($course_code); + $courseId = intval($courseId); $sql = "SELECT name, s.id FROM $table_session_course sc - INNER JOIN $table_session s ON (sc.id_session = s.id) - WHERE sc.course_code = '$course_code' "; + INNER JOIN $table_session s ON (sc.session_id = s.id) + WHERE sc.c_id = '$courseId' "; $result = Database::query($sql); + return Database::store_result($result); } @@ -3640,14 +3713,15 @@ class SessionManager */ public static function get_sessions_by_user($user_id, $ignore_visibility_for_admins = false) { - $session_categories = UserManager::get_sessions_by_category( + $sessionCategories = UserManager::get_sessions_by_category( $user_id, false, $ignore_visibility_for_admins ); - $session_array = array(); - if (!empty($session_categories)) { - foreach ($session_categories as $category) { + + $sessionArray = array(); + if (!empty($sessionCategories)) { + foreach ($sessionCategories as $category) { if (isset($category['sessions'])) { foreach ($category['sessions'] as $session) { $session_array[] = $session; @@ -3655,7 +3729,8 @@ class SessionManager } } } - return $session_array; + + return $sessionArray; } /** @@ -3835,6 +3910,11 @@ class SessionManager } } + $sessionCondition = ''; + if (!empty($session_category_id)) { + $sessionCondition = "session_category_id = '$session_category_id',"; + } + // Creating the session. $sql = "INSERT IGNORE INTO $tbl_session SET name = '" . $session_name . "', @@ -3842,7 +3922,7 @@ class SessionManager date_start = '$date_start', date_end = '$date_end', visibility = '$visibilityAfterExpirationPerSession', - session_category_id = '$session_category_id', + $sessionCondition session_admin_id = " . intval($defaultUserId) . $extraParameters . $extraSessionParameters; Database::query($sql); @@ -3903,19 +3983,19 @@ class SessionManager // Delete session-user relation only for students $sql = "DELETE FROM $tbl_session_user - WHERE id_session = '$session_id' AND relation_type <> " . SESSION_RELATION_TYPE_RRHH; + WHERE session_id = '$session_id' AND relation_type <> " . SESSION_RELATION_TYPE_RRHH; Database::query($sql); - $sql = "DELETE FROM $tbl_session_course WHERE id_session = '$session_id'"; + $sql = "DELETE FROM $tbl_session_course WHERE session_id = '$session_id'"; Database::query($sql); // Delete session-course-user relationships students and coaches. if ($updateCourseCoaches) { - $sql = "DELETE FROM $tbl_session_course_user WHERE id_session = '$session_id' AND status in ('0', '2')"; + $sql = "DELETE FROM $tbl_session_course_user WHERE session_id = '$session_id' AND status in ('0', '2')"; Database::query($sql); } else { // Delete session-course-user relation ships *only* for students. - $sql = "DELETE FROM $tbl_session_course_user WHERE id_session = '$session_id' AND status <> 2"; + $sql = "DELETE FROM $tbl_session_course_user WHERE session_id = '$session_id' AND status <> 2"; Database::query($sql); } } @@ -3989,21 +4069,21 @@ class SessionManager // Delete session-user relation only for students $sql = "DELETE FROM $tbl_session_user - WHERE id_session = '$session_id' AND relation_type <> " . SESSION_RELATION_TYPE_RRHH; + WHERE session_id = '$session_id' AND relation_type <> " . SESSION_RELATION_TYPE_RRHH; Database::query($sql); - $sql = "DELETE FROM $tbl_session_course WHERE id_session = '$session_id'"; + $sql = "DELETE FROM $tbl_session_course WHERE session_id = '$session_id'"; Database::query($sql); // Delete session-course-user relationships students and coaches. if ($updateCourseCoaches) { $sql = "DELETE FROM $tbl_session_course_user - WHERE id_session = '$session_id' AND status in ('0', '2')"; + WHERE session_id = '$session_id' AND status in ('0', '2')"; Database::query($sql); } else { // Delete session-course-user relation ships *only* for students. $sql = "DELETE FROM $tbl_session_course_user - WHERE id_session = '$session_id' AND status <> 2"; + WHERE session_id = '$session_id' AND status <> 2"; Database::query($sql); } } else { @@ -4030,8 +4110,8 @@ class SessionManager $userList[] = $user_id; // Insert new users. $sql = "INSERT IGNORE INTO $tbl_session_user SET - id_user = '$user_id', - id_session = '$session_id'"; + user_id = '$user_id', + session_id = '$session_id'"; Database::query($sql); if ($debug) { $logger->addInfo("Sessions - Adding User #$user_id ($user) to session #$session_id"); @@ -4082,14 +4162,14 @@ class SessionManager if (CourseManager::course_exists($course_code)) { $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; // Adding the course to a session. $sql = "INSERT IGNORE INTO $tbl_session_course - SET course_code = '$course_code', id_session='$session_id'"; + SET c_id = '$courseId', session_id='$session_id'"; Database::query($sql); - $course_info = api_get_course_info($course_code); - SessionManager::installCourse($session_id, $course_info['real_id']); + SessionManager::installCourse($session_id, $courseInfo['real_id']); if ($debug) { $logger->addInfo("Sessions - Adding course '$course_code' to session #$session_id"); @@ -4152,7 +4232,7 @@ class SessionManager $coach_id = UserManager::get_user_id_from_username($course_coach); if ($coach_id !== false) { // Just insert new coaches - SessionManager::updateCoaches($session_id, $course_code, array($coach_id), false); + SessionManager::updateCoaches($session_id, $courseId, array($coach_id), false); if ($debug) { $logger->addInfo("Sessions - Adding course coach: user #$coach_id ($course_coach) to course: '$course_code' and session #$session_id"); @@ -4191,7 +4271,7 @@ class SessionManager } if (!empty($teacherToAdd)) { - SessionManager::updateCoaches($session_id, $course_code, array($teacherToAdd), true); + SessionManager::updateCoaches($session_id, $courseId, array($teacherToAdd), true); CourseManager::subscribe_user( $teacherToAdd, $course_code, @@ -4241,7 +4321,7 @@ class SessionManager // Continue default behaviour. if ($onlyAddFirstCoachOrTeacher == false) { // Checking one more time see BT#6449#note-149 - $coaches = SessionManager::getCoachesByCourseSession($session_id, $course_code); + $coaches = SessionManager::getCoachesByCourseSession($session_id, $courseId); // Update coaches if only there's 1 course see BT#6449#note-189 if (empty($coaches) || count($courses) == 1) { foreach ($course_coaches as $course_coach) { @@ -4251,7 +4331,7 @@ class SessionManager // Just insert new coaches SessionManager::updateCoaches( $session_id, - $course_code, + $courseId, array($coach_id), false ); @@ -4290,8 +4370,7 @@ class SessionManager } } - $course_info = CourseManager::get_course_information($course_code); - $inserted_in_course[$course_code] = $course_info['title']; + $inserted_in_course[$course_code] = $courseInfo['title']; } } $access_url_id = api_get_current_access_url_id(); @@ -4310,19 +4389,19 @@ class SessionManager /** * @param int $sessionId - * @param string $courseCode + * @param int $courseId * @return array */ - public static function getCoachesByCourseSession($sessionId, $courseCode) + public static function getCoachesByCourseSession($sessionId, $courseId) { $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $sessionId = intval($sessionId); - $courseCode = Database::escape_string($courseCode); + $courseId = intval($courseId); - $sql = "SELECT id_user FROM $table + $sql = "SELECT user_id FROM $table WHERE - id_session = '$sessionId' AND - course_code = '$courseCode' AND + session_id = '$sessionId' AND + c_id = '$courseId' AND status = 2"; $result = Database::query($sql); @@ -4332,19 +4411,20 @@ class SessionManager $coaches[] = $row[0]; } } + return $coaches; } /** * @param int $sessionId - * @param string $courseCode + * @param int $courseId * @return string */ public static function getCoachesByCourseSessionToString( $sessionId, - $courseCode + $courseId ) { - $coaches = self::getCoachesByCourseSession($sessionId, $courseCode); + $coaches = self::getCoachesByCourseSession($sessionId, $courseId); $list = array(); if (!empty($coaches)) { foreach ($coaches as $coachId) { @@ -4369,15 +4449,15 @@ class SessionManager $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $sessionId = intval($sessionId); - $sql = "SELECT DISTINCT id_user + $sql = "SELECT DISTINCT user_id FROM $table - WHERE id_session = '$sessionId' AND status = 2"; + WHERE session_id = '$sessionId' AND status = 2"; $result = Database::query($sql); $coaches = array(); if (Database::num_rows($result) > 0) { while ($row = Database::fetch_array($result)) { - $coaches[] = $row['id_user']; + $coaches[] = $row['user_id']; } } @@ -4552,8 +4632,8 @@ class SessionManager $sql = "$masterSelect ( ($select FROM $tbl_session s - INNER JOIN $tbl_session_rel_course_rel_user su ON (s.id = su.id_session) - INNER JOIN $tbl_user u ON (u.user_id = su.id_user AND s.id = id_session) + INNER JOIN $tbl_session_rel_course_rel_user su ON (s.id = su.session_id) + INNER JOIN $tbl_user u ON (u.user_id = su.user_id) INNER JOIN $tbl_session_rel_access_url url ON (url.session_id = s.id) $where $sessionConditions @@ -4561,9 +4641,9 @@ class SessionManager UNION ( $select FROM $tbl_course c - INNER JOIN $tbl_course_user cu ON (cu.course_code = c.code) + INNER JOIN $tbl_course_user cu ON (cu.c_id = c.id) INNER JOIN $tbl_user u ON (u.user_id = cu.user_id) - INNER JOIN $tbl_course_rel_access_url url ON (url.course_code = c.code) + INNER JOIN $tbl_course_rel_access_url url ON (url.c_id = c.id) $where $courseConditions ) @@ -4594,21 +4674,21 @@ class SessionManager /** * @param int $sessionId - * @param string $courseCode + * @param int $courseId * @param array $coachList * @param bool $deleteCoachesNotInList */ public static function updateCoaches( $sessionId, - $courseCode, + $courseId, $coachList, $deleteCoachesNotInList = false ) { - $currentCoaches = self::getCoachesByCourseSession($sessionId, $courseCode); + $currentCoaches = self::getCoachesByCourseSession($sessionId, $courseId); if (!empty($coachList)) { foreach ($coachList as $userId) { - self::set_coach_to_course_session($userId, $sessionId, $courseCode); + self::set_coach_to_course_session($userId, $sessionId, $courseId); } } @@ -4624,7 +4704,7 @@ class SessionManager self::set_coach_to_course_session( $userId, $sessionId, - $courseCode, + $courseId, true ); } @@ -4838,9 +4918,9 @@ class SessionManager // Select the teachers. $sql = "SELECT DISTINCT(cu.user_id) FROM $course c - INNER JOIN $sessionCourse src ON c.code = src.course_code - INNER JOIN $courseUser cu ON (cu.course_code = c.code) - WHERE src.id_session IN ('$sessionToString') AND cu.status = 1"; + INNER JOIN $sessionCourse src ON c.id = src.c_id + INNER JOIN $courseUser cu ON (cu.c_id = c.id) + WHERE src.session_id IN ('$sessionToString') AND cu.status = 1"; $result = Database::query($sql); $teacherListId = array(); while($row = Database::fetch_array($result, 'ASSOC')) { @@ -5120,17 +5200,17 @@ class SessionManager /** * @param string $direction (up/down) * @param int $sessionId - * @param string $courseCode + * @param int $courseId * @return bool */ - public static function move($direction, $sessionId, $courseCode) + public static function move($direction, $sessionId, $courseId) { if (!self::orderCourseIsEnabled()) { return false; } $sessionId = intval($sessionId); - $courseCode = Database::escape_string($courseCode); + $courseId = intval($courseId); $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $courseList = self::get_course_list_by_session_id($sessionId, null, 'position'); @@ -5145,7 +5225,7 @@ class SessionManager $position[$course['code']] = $course['position']; // Saving current order. $sql = "UPDATE $table SET position = $count - WHERE id_session = $sessionId AND course_code = '".$course['code']."'"; + WHERE session_id = $sessionId AND c_id = '".$course['real_id']."'"; Database::query($sql); $count++; } @@ -5165,24 +5245,24 @@ class SessionManager foreach ($courseList as $course) { if ($found) { - $nextId = $course['code']; + $nextId = $course['real_id']; $nextOrder = $course['position']; break; } - if ($courseCode == $course['code']) { - $thisCourseCode = $course['code']; + if ($courseId == $course['real_id']) { + $thisCourseCode = $course['real_id']; $thisOrder = $course['position']; $found = true; } } $sql1 = "UPDATE $table SET position = '".intval($nextOrder)."' - WHERE id_session = $sessionId AND course_code = '".$thisCourseCode."'"; + WHERE session_id = $sessionId AND c_id = '".$thisCourseCode."'"; + Database::query($sql1); $sql2 = "UPDATE $table SET position = '".intval($thisOrder)."' - WHERE id_session = $sessionId AND course_code = '".$nextId."'"; - Database::query($sql1); + WHERE session_id = $sessionId AND c_id = '".$nextId."'"; Database::query($sql2); return true; @@ -5190,12 +5270,12 @@ class SessionManager /** * @param int $sessionId - * @param string $courseCode + * @param int $courseId * @return bool */ - public static function moveUp($sessionId, $courseCode) + public static function moveUp($sessionId, $courseId) { - return self::move('up', $sessionId, $courseCode); + return self::move('up', $sessionId, $courseId); } /** @@ -5275,7 +5355,7 @@ class SessionManager $table = Database::get_main_table(TABLE_MAIN_SESSION_USER); $parameters = array('duration' => $duration); - $where = array('id_session = ? AND id_user = ? ' => array($sessionId, $userId)); + $where = array('session_id = ? AND user_id = ? ' => array($sessionId, $userId)); Database::update($table, $parameters, $where); } @@ -5295,7 +5375,8 @@ class SessionManager } $table = Database::get_main_table(TABLE_MAIN_SESSION_USER); - $sql = "SELECT * FROM $table WHERE id_session =$sessionId AND id_user = $userId"; + $sql = "SELECT * FROM $table + WHERE session_id =$sessionId AND user_id = $userId"; $result = Database::query($sql); $values = array(); if (Database::num_rows($result)) { @@ -5320,8 +5401,11 @@ class SessionManager // COUNT(1) actually returns the number of rows from the table (as if // counting the results from the first column) - $sql = "SELECT COUNT(1) AS qty FROM $sessionRelUserTable " - . "WHERE id_session = $sessionId AND id_user = $userId AND relation_type = 0"; + $sql = "SELECT COUNT(1) AS qty FROM $sessionRelUserTable + WHERE + session_id = $sessionId AND + user_id = $userId AND + relation_type = 0"; $result = Database::fetch_assoc(Database::query($sql)); @@ -5422,10 +5506,11 @@ class SessionManager $courseTable = Database::get_main_table(TABLE_MAIN_COURSE); $sessionRelCourseTable = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); - $sql = "SELECT COUNT(1) AS qty FROM $courseTable c + $sql = "SELECT COUNT(1) AS qty + FROM $courseTable c INNER JOIN $sessionRelCourseTable src - ON c.code = src.course_code - WHERE src.id_session = $sessionId + ON c.id = src.c_id + WHERE src.session_id = $sessionId AND c.code = '$courseCode' "; $result = Database::query($sql); @@ -5452,7 +5537,7 @@ class SessionManager $scuTable = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $userTable = Database::get_main_table(TABLE_MAIN_USER); - $idResult = Database::select('DISTINCT id_user', $scuTable, array( + $idResult = Database::select('DISTINCT user_id', $scuTable, array( 'where' => array( 'status = ?' => 2 ) @@ -5462,7 +5547,7 @@ class SessionManager foreach ($idResult as $idData) { $userResult = Database::select('user_id, lastname, firstname, username', $userTable, array( 'where' => array( - 'user_id = ?' => $idData['id_user'] + 'user_id = ?' => $idData['user_id'] ) ), 'first'); @@ -5528,7 +5613,7 @@ class SessionManager $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); return Database::select('*', $table, array( 'where' => array( - 'id_user = ? AND ' => $coachId, + 'user_id = ? AND ' => $coachId, 'status = ?' => 2 ) )); @@ -5541,11 +5626,13 @@ class SessionManager */ public static function getTotalUserCoursesInSession($sessionId) { - $sql = "SELECT COUNT(1) as count, u.user_id, scu.status status_in_session, u.status user_status " - . "FROM session_rel_course_rel_user scu " - . "INNER JOIN user u ON scu.id_user = u.user_id " - . "WHERE scu.id_session = " . intval($sessionId) . " " - . "GROUP BY u.user_id"; + $tableUser = Database::get_main_table(TABLE_MAIN_USER); + $tableSessionRelCourseRelUser = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); + $sql = "SELECT COUNT(1) as count, u.user_id, scu.status status_in_session, u.status user_status + FROM $tableSessionRelCourseRelUser scu + INNER JOIN $tableUser u ON scu.user_id = u.user_id + WHERE scu.session_id = " . intval($sessionId) ." + GROUP BY u.user_id"; $result = Database::query($sql); @@ -5747,14 +5834,19 @@ class SessionManager } } // Query used to find course-coaches from sessions - $sql = "SELECT scu.id_session AS session_id, c.id AS course_id, c.code AS course_code," . - " c.title AS course_title, u.username AS coach_username, u.firstname AS coach_firstname, " . - " u.lastname AS coach_lastname " . - "FROM $courseTable c " . - "INNER JOIN $sessionCourseUserTable scu ON c.code = scu.course_code " . - "INNER JOIN $userTable u ON scu.id_user = u.user_id " . - "WHERE scu.status = 2 AND scu.id_session IN $sessionIdsString " . - "ORDER BY scu.id_session ASC "; + $sql = "SELECT + scu.session_id, + c.id AS course_id, + c.code AS course_code, + c.title AS course_title, + u.username AS coach_username, + u.firstname AS coach_firstname, + u.lastname AS coach_lastname + FROM $courseTable c + INNER JOIN $sessionCourseUserTable scu ON c.id = scu.c_id + INNER JOIN $userTable u ON scu.user_id = u.user_id + WHERE scu.status = 2 AND scu.session_id IN $sessionIdsString + ORDER BY scu.session_id ASC "; $res = Database::query($sql); $sessionCourseList = Database::store_result($res, 'ASSOC'); // Check if course list had result diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index f9b0b8460f..1bb51f9d6b 100755 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -553,11 +553,12 @@ class SocialManager extends UserManager if (!$nosession) { $session = ''; $active = false; - if (!empty($my_course['session_name'])) { + if (!empty($my_course['session_name']) && !empty($my_course['id_session'])) { // Request for the name of the general coach $sql = 'SELECT lastname, firstname - FROM '.$tbl_session.' ts LEFT JOIN '.$main_user_table.' tu + FROM '.$tbl_session.' ts + LEFT JOIN '.$main_user_table.' tu ON ts.id_coach = tu.user_id WHERE ts.id='.(int) $my_course['id_session'].' LIMIT 1'; $rs = Database::query($sql); @@ -585,7 +586,7 @@ class SocialManager extends UserManager } else { $output = array($my_course['user_course_cat'], $result); } - //$my_course['creation_date']; + return $output; } @@ -928,15 +929,7 @@ class SocialManager extends UserManager $course_url = '&cidReq='.Security::remove_XSS($_GET['cidReq']); } - if ($wrap) { - if ($add_row) { - $html .='
    '; - } - - $html .= '
    '; - - $html .= '
      '; - } + $html .= '
      '; foreach ($user_list as $uid) { $user_info = api_get_user_info($uid); @@ -965,16 +958,26 @@ class SocialManager extends UserManager } $img = ''.$name.''; - $name = ''.$status_icon.$user_status.$name.'
      '; - $html .= '
    • '.$img.'
      '.$name.'
    • '; + $name = ''.$status_icon.$user_status.$name.''; + + $html .= '
      +
      +
      '.$img.'
      +
      + '.$name.' +
      +
      +
      '; + } $counter = $_SESSION['who_is_online_counter']; if ($wrap) { - $html .= '
    '; + $html .= '
    '; } if (count($user_list) >= 9) { - $html .= ''; + $html .= ''; } if ($wrap && $add_row) { $html .= '
    '; diff --git a/main/inc/lib/statistics.lib.php b/main/inc/lib/statistics.lib.php index 819bd474fe..f23872df49 100644 --- a/main/inc/lib/statistics.lib.php +++ b/main/inc/lib/statistics.lib.php @@ -36,10 +36,11 @@ class Statistics public static function countCourses($categoryCode = null) { $course_table = Database :: get_main_table(TABLE_MAIN_COURSE); - $access_url_rel_course_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); + $access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $current_url_id = api_get_current_access_url_id(); if (api_is_multiple_url_enabled()) { - $sql = "SELECT COUNT(*) AS number FROM ".$course_table." as c, ".$access_url_rel_course_table." as u WHERE u.course_code=c.code AND access_url_id='".$current_url_id."'"; + $sql = "SELECT COUNT(*) AS number FROM ".$course_table." as c, ".$access_url_rel_course_table." as u + WHERE u.c_id = c.id AND access_url_id='".$current_url_id."'"; if (isset ($categoryCode)) { $sql .= " AND category_code = '".Database::escape_string($categoryCode)."'"; } @@ -69,7 +70,7 @@ class Statistics $current_url_id = api_get_current_access_url_id(); if (api_is_multiple_url_enabled()) { $sql = "SELECT COUNT(*) AS number FROM ".$course_table." as c, ".$access_url_rel_course_table." as u - WHERE u.course_code=c.code AND access_url_id='".$current_url_id."'"; + WHERE u.c_id = c.id AND access_url_id='".$current_url_id."'"; if (isset ($visibility)) { $sql .= " AND visibility = ".intval($visibility); } @@ -95,9 +96,9 @@ class Statistics public static function countUsers($status = null, $categoryCode = null, $countInvisibleCourses = true, $onlyActive = false) { // Database table definitions - $course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - $course_table = Database :: get_main_table(TABLE_MAIN_COURSE); - $user_table = Database :: get_main_table(TABLE_MAIN_USER); + $course_user_table = Database:: get_main_table(TABLE_MAIN_COURSE_USER); + $course_table = Database:: get_main_table(TABLE_MAIN_COURSE); + $user_table = Database:: get_main_table(TABLE_MAIN_USER); $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $current_url_id = api_get_current_access_url_id(); $active_filter = $onlyActive?' AND active=1':''; @@ -106,22 +107,33 @@ class Statistics if (api_is_multiple_url_enabled()) { $sql = "SELECT COUNT(DISTINCT(u.user_id)) AS number FROM $user_table as u, $access_url_rel_user_table as url - WHERE u.user_id=url.user_id - AND access_url_id='".$current_url_id."' + WHERE + u.user_id = url.user_id AND + access_url_id = '".$current_url_id."' $status_filter $active_filter"; if (isset ($categoryCode)) { $sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number FROM $course_user_table cu, $course_table c, $access_url_rel_user_table as url - WHERE c.code = cu.course_code - AND c.category_code = '".Database::escape_string($categoryCode)."' - AND cu.user_id=url.user_id AND access_url_id='".$current_url_id."' - $status_filter $active_filter"; + WHERE + c.id = cu.c_id AND + c.category_code = '".Database::escape_string($categoryCode)."' AND + cu.user_id = url.user_id AND + access_url_id='".$current_url_id."' + $status_filter $active_filter"; } } else { - $sql = "SELECT COUNT(DISTINCT(user_id)) AS number FROM $user_table WHERE 1=1 $status_filter $active_filter"; + $sql = "SELECT COUNT(DISTINCT(user_id)) AS number + FROM $user_table WHERE 1=1 $status_filter $active_filter"; if (isset ($categoryCode)) { $status_filter = isset($status)?' AND status = '.intval($status):''; - $sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number FROM $course_user_table cu, $course_table c WHERE c.code = cu.course_code AND c.category_code = '".Database::escape_string($categoryCode)."' $status_filter $active_filter"; + $sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number + FROM $course_user_table cu, $course_table c + WHERE + c.id = cu.c_id AND + c.category_code = '".Database::escape_string($categoryCode)."' + $status_filter + $active_filter + "; } } @@ -467,7 +479,7 @@ class Statistics public static function printToolStats() { $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); - $access_url_rel_course_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); + $access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $current_url_id = api_get_current_access_url_id(); $tools = array( @@ -501,16 +513,18 @@ class Statistics GROUP BY access_tool "; } else { - $sql = "SELECT access_tool, count( access_id ) ". - "AS number_of_logins FROM $table ". - "WHERE access_tool IN ('".implode("','", $tools)."') ". - "GROUP BY access_tool "; + $sql = "SELECT access_tool, count( access_id ) AS number_of_logins + FROM $table + WHERE access_tool IN ('".implode("','", $tools)."') + GROUP BY access_tool "; } + $res = Database::query($sql); $result = array(); while ($obj = Database::fetch_object($res)) { $result[$tool_names[$obj->access_tool]] = $obj->number_of_logins; } + Statistics::printStats(get_lang('PlatformToolAccess'), $result, true); } @@ -520,16 +534,18 @@ class Statistics public static function printCourseByLanguageStats() { $table = Database :: get_main_table(TABLE_MAIN_COURSE); - $access_url_rel_course_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); + $access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $current_url_id = api_get_current_access_url_id(); if (api_is_multiple_url_enabled()) { - $sql = "SELECT course_language, count( c.code ) AS number_of_courses ". - "FROM $table as c, $access_url_rel_course_table as u - WHERE u.course_code=c.code AND access_url_id='".$current_url_id."' - GROUP BY course_language ORDER BY number_of_courses DESC"; + $sql = "SELECT course_language, count( c.code ) AS number_of_courses + FROM $table as c, $access_url_rel_course_table as u + WHERE u.c_id = c.id AND access_url_id='".$current_url_id."' + GROUP BY course_language + ORDER BY number_of_courses DESC"; } else { - $sql = "SELECT course_language, count( code ) AS number_of_courses ". - "FROM $table GROUP BY course_language ORDER BY number_of_courses DESC"; + $sql = "SELECT course_language, count( code ) AS number_of_courses + FROM $table GROUP BY course_language + ORDER BY number_of_courses DESC"; } $res = Database::query($sql); $result = array(); @@ -624,7 +640,7 @@ class Statistics */ public static function printCourseLastVisit() { - $access_url_rel_course_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); + $access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $current_url_id = api_get_current_access_url_id(); $columns[0] = 'c_id'; @@ -665,10 +681,10 @@ class Statistics HAVING c_id <> '' AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ". $date_diff; } else { - $sql = "SELECT * FROM $table ". - "GROUP BY c_id ". - "HAVING c_id <> '' ". - "AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ". $date_diff; + $sql = "SELECT * FROM $table + GROUP BY c_id + HAVING c_id <> '' + AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ". $date_diff; } $res = Database::query($sql); $sql .= ' ORDER BY '.$columns[$column].' '.$sql_order[$direction]; @@ -682,15 +698,21 @@ class Statistics $courseInfo = api_get_course_info_by_id($obj->c_id); $course = array (); $course[]= ''.$courseInfo['code'].' '; - //Allow sort by date hiding the numerical date + // Allow sort by date hiding the numerical date $course[] = ''.$obj->access_date.''.api_convert_and_format_date($obj->access_date); $courses[] = $course; } $parameters['date_diff'] = $date_diff; $parameters['report'] = 'courselastvisit'; - $table_header[] = array (get_lang("CourseCode"), true); - $table_header[] = array (get_lang("LastAccess"), true); - Display :: display_sortable_table($table_header, $courses, array ('column'=>$column,'direction'=>$direction), array (), $parameters); + $table_header[] = array(get_lang("CourseCode"), true); + $table_header[] = array(get_lang("LastAccess"), true); + Display:: display_sortable_table( + $table_header, + $courses, + array('column' => $column, 'direction' => $direction), + array(), + $parameters + ); } else { echo get_lang('NoSearchResults'); } diff --git a/main/inc/lib/stats.lib.inc.php b/main/inc/lib/stats.lib.inc.php deleted file mode 100755 index 560bb305ed..0000000000 --- a/main/inc/lib/stats.lib.inc.php +++ /dev/null @@ -1,593 +0,0 @@ - - * @desc uses $TABLETRACK_OPEN to split recorded - information, to count occurences (for os, provider,...) - and to increment the number of occurrences of each - different element into the corresponding tables - */ -function decodeOpenInfos() { - global $TABLETRACK_OPEN; - // record initial value of ignore_user_abort - $ignore = ignore_user_abort(); - // prevent script from being stopped while executing, the following can be considered - // as a transaction - ignore_user_abort(1) ; - // we take the last event id to prevent miss of some recorded event - // only processed record have to be cleaned - $now = api_get_utc_datetime(); - $sql = "SELECT open_id - FROM $TABLETRACK_OPEN - WHERE open_date <= '$now' - ORDER BY open_id DESC - LIMIT 1"; - //$processBegin = StatsUtils::getOneResult($sql); - $query = Database::query($sql); - $res = @Database::fetch_array($query); - $processBegin = $res[0]; - // process - - //--Providers And Countries-------------------------------------------// - - $sql = "SELECT open_remote_host - FROM $TABLETRACK_OPEN - WHERE open_remote_host != '' - AND open_id <= '".$processBegin."' "; - $query = Database::query($sql); - - if(Database::num_rows($query) != 0) { - // load list of countries - $list_countries = loadCountries(); - - while ($row = Database::fetch_row ($query)) { - $remote_host = $row[0]; - /*****Provider*****/ - //extract provider - $provider = extractProvider( $remote_host ); - // add or increment provider in the providers array - $providers_array = addProvider( $provider,$providers_array ); - - /*****Countries*****/ - // extract country - $country = extractCountry( $remote_host, $list_countries ); - // increment country in the countries table - $countries_array = addCountry( $country, $countries_array ); - } - // update tables - fillProvidersTable( $providers_array ); - fillCountriesTable( $countries_array ); - } - // provider and countries done - //--Browsers and OS---------------------------------------------------// - $sql = "SELECT open_agent - FROM $TABLETRACK_OPEN - WHERE open_remote_host != '' - AND open_id <= '".$processBegin."' "; - $query =Database::query( $sql ); - if(Database::num_rows($query) != 0) { - // load lists - // of browsers - $list_browsers = loadBrowsers(); - // of OS - $list_os = loadOs(); - while ($row = Database::fetch_row ($query)) { - $agent = $row[0]; - /*****Browser and OS*****/ - // extract browser and OS - list( $browser,$os ) = split( "[|]",extractAgent( $agent , $list_browsers , $list_os ) ); - // increment browser and OS in the corresponding arrays - $browsers_array = addBrowser( $browser , $browsers_array ); - $os_array = addOs( $os , $os_array ); - } - fillBrowsersTable( $browsers_array ); - fillOsTable( $os_array ); - } - // browsers and OS done - - //--Referers----------------------------------------------------------// - - $sql = "SELECT open_referer - FROM $TABLETRACK_OPEN - WHERE open_referer != '' - AND open_id <= '".$processBegin."' "; - $query = Database::query( $sql ); - - if(Database::num_rows($query) != 0) { - $i=0; - while ($row = Database::fetch_row ($query)) { - $ref = $row[0]; - $referers_array = addReferer( $ref , $referers_array ); - } - fillReferersTable( $referers_array ); - } - // referers done - //-------------------------------------------------------------------// - // end of process - // cleaning of $TABLETRACK_OPEN table - cleanProcessedRecords($processBegin); - // reset to the initial value - ignore_user_abort($ignore); -} - -/* - * - * Utils - * - */ - -/** - * @author Sebastien Piraux - * @param limit : all records BEFORE $limit will be affected - * @desc this function will delete the remote_host, user_agent - and referer rows from the track_open table recorded before - the date $limit. OPTIMIZE is called to get back the memory - espaces deleted - */ -function cleanProcessedRecords( $limit ) { - global $TABLETRACK_OPEN; - $limit = Database::escape_string($limit); - $sql = "UPDATE $TABLETRACK_OPEN - SET open_remote_host = '', - open_agent = '', - open_referer ='' - WHERE open_id <= '".$limit."'"; - $query = Database::query( $sql ); - Database::query("OPTIMIZE TABLE $TABLETRACK_OPEN"); -} - -/** - * Provider - * - **/ - -/** - * @author Sebastien Piraux - * @param remhost : must be @getHostByAddr($_SERVER['REMOTE_ADDR'] - * @desc this function will extract the provider name from a given - remote host and record this occurence in the corresponding - table - */ -function extractProvider($remhost) { - if($remhost == "Unknown") - return $remhost; - $explodedRemhost = explode(".", $remhost); - $provider = $explodedRemhost[sizeof( $explodedRemhost )-2] - ."." - .$explodedRemhost[sizeof( $explodedRemhost )-1]; - - if($provider == "co.uk" || $provider == "co.jp") - return $explodedRemhost[sizeof( $explodedRemhost )-3].$provider; - else return $provider; -} - - -/** - * @author Sebastien Piraux - * @param provider : name of the provider - * @param providers_array : list of providers and their counter - * @desc this function will : - - if the provider is already in the array it will increment - the corresponding value - - if the provider doesn't exist it will be added and set to 1 - */ -function addProvider($provider,$providers_array) { - if(isset($providers_array[$provider])) { - // add one unity to this provider occurrences - $providers_array[$provider] = $providers_array[$provider] + 1; - } else { - // first occurrence of this provider - $providers_array[$provider] = 1; - } - return $providers_array; -} - -/** - * @author Sebastien Piraux - * @param providers_array : list of providers and their counter - * @desc update the providers'table with new values - */ -function fillProvidersTable($providers_array) { - global $TABLESTATS_PROVIDERS; - - if(is_array($providers_array)) { - foreach ( $providers_array as $prov=>$number ) { - $sql = "SELECT counter - FROM ".$TABLESTATS_PROVIDERS." - WHERE provider = '".$prov."'"; - $res = Database::query($sql); - - // if this provider already exists in the DB - if($row = Database::num_rows($res)) { - // update - $sql2 = "UPDATE $TABLESTATS_PROVIDERS - SET counter = counter + '$number' - WHERE provider = '".$prov."'"; - } else { - // insert - $sql2 = "INSERT INTO $TABLESTATS_PROVIDERS - (provider,counter) - VALUES ('".$prov."','".$number."')"; - } - Database::query($sql2);; - } - } -} - -/*************************************************************************** - * - * Country - * - ***************************************************************************/ - -/** - * @author Sebastien Piraux - * @return a 2D array filled with code and name of countries - * @desc This function is used to build an array containing - countries informations - */ -function loadCountries() { - global $TABLESTATS_COUNTRIES; - $sql = "SELECT code, country - FROM $TABLESTATS_COUNTRIES"; - $res = Database::query($sql); - $i = 0 ; - if (Database::num_rows($res) > 0){ - while ($row = Database::fetch_array($res)) { - $list_countries[$i][0] = $row["code"]; - $list_countries[$i][1] = $row["country"]; - $i++; - } - } - Database::free_result($res); - return $list_countries; -} - -/** - * @author Sebastien Piraux - * @param remhost : must be @getHostByAddr($_SERVER['REMOTE_ADDR'] - * @param list_countries : list of countries -__- - * @return Name of the country or "Unknown" if not found - * @desc this function will extract the country from a given remote - host and increment the good value in the corresponding table - */ -function extractCountry($remhost,$list_countries) { - if($remhost == "Unknown") - return $remhost; - // country code is the last value of remote host - $explodedRemhost = explode(".",$remhost); - $countryCode = $explodedRemhost[sizeof( $explodedRemhost )-1]; - for($i = 0 ; $i < sizeof( $list_countries );$i++) { - if($list_countries[$i][0] == $countryCode) - return $list_countries[$i][1]; - } -} - -/** - * @author Sebastien Piraux - * @param country : name of the country or 'Unknown' - * @param countries_array : list of countries and their - number of occurence - * @desc this function will increment number of occurrence - for $country in the countries' tables - */ -function addCountry($country,$countries_array) { - if(isset($countries_array[$country])) { - // add one unity to this provider occurrences - $countries_array[$country] = $countries_array[$country] + 1; - } else { - // first occurrence of this provider - $countries_array[$country] = 1; - } - return $countries_array; -} - -/** - * @author Sebastien Piraux - * @param countries_array : list of countries and their counter - * @desc update the countries'table with new values - */ -function fillCountriesTable($countries_array) { - global $TABLESTATS_COUNTRIES; - if(is_array($countries_array)) { - foreach ( $countries_array as $country=>$number ) { - // update - $sql = "UPDATE $TABLESTATS_COUNTRIES - SET counter = counter + '$number' - WHERE country = '".$country."'"; - Database::query($sql); - } - } -} - -/*************************************************************************** - * - * Agent : Browser and OS - * - ***************************************************************************/ - -/** - * @author Sebastien Piraux - * @return a 2D array filled with code and name of browsers - * @desc This function is used to build an array containing - browser informations - */ -function loadBrowsers() { - - $buffer = split ("#","Gecko|Gecko#Mozilla/3|Mozilla 3.x#Mozilla/4.0|Mozilla 4.0x#Mozilla/4.5|Mozilla 4.5x#Mozilla/4.6|Mozilla 4.6x#Mozilla/4.7|Mozilla 4.7x#Mozilla/5.0|Mozilla 5.0x#MSIE 1.2|MSIE 1.2#MSIE 3.01|MSIE 3.x#MSIE 3.02|MSIE 3.x#MSIE 4.0|MSIE 4.x#MSIE 4.01|MSIE 4.x#MSIE 4.5|MSIE 4.5#MSIE 5.0b1|MSIE 5.0x#MSIE 5.0b2|MSIE 5.0x#MSIE 5.0|MSIE 5.0x#MSIE 5.01|MSIE 5.0x#MSIE 5.1|MSIE 5.1#MSIE 5.1b1|MSIE 5.1#MSIE 5.5|MSIE 5.5#MSIE 5.5b1|MSIE 5.5#MSIE 5.5b2|MSIE 5.5#MSIE 6.0|MSIE 6#MSIE 6.0b|MSIE 6#MSIE 6.5a|MSIE 6.5#Lynx/2.8.0|Lynx 2#Lynx/2.8.1|Lynx 2#Lynx/2.8.2|Lynx 2#Lynx/2.8.3|Lynx 2#Lynx/2.8.4|Lynx 2#Lynx/2.8.5|Lynx 2#HTTrack 3.0x|HTTrack#OmniWeb/4.0.1|OmniWeb#Opera 3.60|Opera 3.60#Opera 4.0|Opera 4#Opera 4.01|Opera 4#Opera 4.02|Opera 4#Opera 5|Opera 5#Opera/3.60|Opera 3.60#Opera/4|Opera 4#Opera/5|Opera 5#Opera/6|Opera 6#Opera 6|Opera 6#Netscape6|NS 6#Netscape/6|NS 6#Netscape7|NS 7#Netscape/7|NS 7#Konqueror/2.0|Konqueror 2#Konqueror/2.0.1|Konqueror 2#Konqueror/2.1|Konqueror 2#Konqueror/2.1.1|Konqueror 2#Konqueror/2.1.2|Konqueror 2#Konqueror/2.2|Konqueror 2#Teleport Pro|Teleport Pro#WebStripper|WebStripper#WebZIP|WebZIP#Netcraft Web|NetCraft#Googlebot|Googlebot#WebCrawler|WebCrawler#InternetSeer|InternetSeer#ia_archiver|ia archiver"); - - //$list_browser[x][0] is the name of browser as in $_SERVER['HTTP_USER_AGENT'] - //$list_browser[x][1] is the name of browser that will be used in display and tables - $i=0; - foreach( $buffer as $buffer1 ) { - list ( $list_browsers[$i][0], $list_browsers[$i][1]) = split ('[|]', $buffer1 ); - $i++; - } - return $list_browsers; -} - -/** - * @author Sebastien Piraux - * @return a 2D array filled with code and name of OS - * @desc This function is used to build an array containing - OS informations - */ -function loadOs() { - $buffer = split ("#","Windows 95|Win 95#Windows_95|Win 95#Windows 98|Win 98#Windows NT|Win NT#Windows NT 5.0|Win 2000#Windows NT 5.1|Win XP#Windows 2000|Win 2000#Windows XP|Win XP#Windows ME|Win Me#Win95|Win 95#Win98|Win 98#WinNT|Win NT#linux-2.2|Linux 2#Linux|Linux#Linux 2|Linux 2#Macintosh|Mac#Mac_PPC|Mac#Mac_PowerPC|Mac#SunOS 5|SunOS 5#SunOS 6|SunOS 6#FreeBSD|FreeBSD#beOS|beOS#InternetSeer|InternetSeer#Googlebot|Googlebot#Teleport Pro|Teleport Pro"); - $i=0; - foreach( $buffer as $buffer1 ) { - list ( $list_os[$i][0], $list_os[$i][1]) = split ('[|]', $buffer1 ); - $i+=1; - } - return $list_os; -} - -/** - * @author Sebastien Piraux - * @param remhost : must be $_SERVER['HTTP_USER_AGENT'] - * @param list_browsers : browsers list :x - * @param list_os : os list :x - * @return a string formatted like : browser|OS - browser and OS are the 'viewable' names - * @desc this function will extract browser and OS from - $_SERVER['HTTP_USER_AGENT'] - */ -function extractAgent( $user_agent, $list_browsers, $list_os ) { - // default values, if nothing corresponding found - $viewable_browser = "Unknown"; - $viewable_os = "Unknown"; - - // search for corresponding pattern in $_SERVER['HTTP_USER_AGENT'] - // for browser - for($i = 0; $i < count( $list_browsers ); $i++) { - $pos = strpos( $user_agent, $list_browsers[$i][0] ); - if( $pos !== false ) { - $viewable_browser = $list_browsers[$i][1]; - } - } - - // for os - for($i = 0; $i < count($list_os); $i++) { - $pos = strpos( $user_agent, $list_os[$i][0] ); - if( $pos !== false ) { - $viewable_os = $list_os[$i][1]; - } - } - return $viewable_browser."|".$viewable_os; - -} - -/** - * @author Sebastien Piraux - * @param browser : name of the browser or 'Unknown' - * @param browsers_array : - * @desc this function will : - - if the browser is already in the table it will increment - the corresponding value - - if the browser doesn't exist it will be added and set to 1 - */ -function addBrowser($browser,$browsers_array) { - if(isset( $browsers_array[$browser])) { - // add one unity to this provider occurrences - $browsers_array[$browser] = $browsers_array[$browser] + 1; - } else { - // first occurrence of this provider - $browsers_array[$browser] = 1; - } - return $browsers_array; -} - -/** - * @author Sebastien Piraux - * @param os : name of the OS or 'Unknown' - * @param os_array : list of os and number of occurences - * @desc this function will : - - if the os is already in the table it will increment - the corresponding value - - if the os doesn't exist it will be added and set to 1 - */ -function addOs($os,$os_array) { - if(isset($os_array[$os])) { - // add one unity to this provider occurrences - $os_array[$os] = $os_array[$os] + 1; - } else { - // first occurrence of this provider - $os_array[$os] = 1; - } - return $os_array; -} - -/** - * @author Sebastien Piraux - * @param browsers_array : list of browsers and their counter - * @desc update the browsers'table with new values - */ -function fillBrowsersTable($browsers_array) { - global $TABLESTATS_BROWSERS; - if (is_array($browsers_array)) { - foreach ( $browsers_array as $browser=>$number ) { - $sql = "SELECT counter - FROM $TABLESTATS_BROWSERS - WHERE browser = '".$browser."'"; - $res = Database::query($sql); - - // if this provider already exists in the DB - if($row = Database::num_rows($res)) { - // update - $sql2 = "UPDATE $TABLESTATS_BROWSERS - SET counter = counter + '$number' - WHERE browser = '".$browser."'"; - } else { - // insert - $sql2 = "INSERT INTO $TABLESTATS_BROWSERS - (browser,counter) - VALUES ('".$browser."','".$number."')"; - } - Database::query($sql2); - } - } -} - -/** - * @author Sebastien Piraux - * @param os_array : list of os and their counter - * @desc update the os'table with new values - */ -function fillOsTable($os_array) { - global $TABLESTATS_OS; - if (is_array($os_array)) { - foreach ($os_array as $os=>$number) { - $sql = "SELECT counter - FROM $TABLESTATS_OS - WHERE os = '".$os."'"; - $res = Database::query($sql); - - // if this provider already exists in the DB - if($row = Database::num_rows($res)) { - // update - $sql2 = "UPDATE $TABLESTATS_OS - SET counter = counter + '$number' - WHERE os = '".$os."'"; - } else { - // insert - $sql2 = "INSERT INTO $TABLESTATS_OS - (os,counter) - VALUES ('".$os."','".$number."')"; - } - Database::query($sql2); - } - } -} - -/*************************************************************************** - * - * Referers - * - ***************************************************************************/ - -/** - * @author Sebastien Piraux - * @param referer : name of the referer - * @param referers_array : list of referer and number of occurences - * @desc this function will : - - if the referer is already in the table it will increment - the corresponding value - - if the referer doesn't exist it will be added and set to 1 -*/ -function addReferer($referer,$referers_array) { - if(isset($referers_array[$referer])) { - // add one unity to this provider occurrences - $referers_array[$referer] = $referers_array[$referer] + 1; - } else { - // first occurrence of this provider - $referers_array[$referer] = 1; - } - return $referers_array; -} - -/** - * @author Sebastien Piraux - * @param referers_array : list of referers and their counter - * @desc update the referers'table with new values -*/ -function fillReferersTable($referers_array) { - global $TABLESTATS_REFERERS; - if (is_array($referers_array)) { - foreach ( $referers_array as $referer=>$number ) { - $sql = "SELECT counter - FROM $TABLESTATS_REFERERS - WHERE referer = '".$referer."'"; - $res = Database::query($sql); - - // if this provider already exists in the DB - if($row = Database::num_rows($res)) { - // update - $sql2 = "UPDATE $TABLESTATS_REFERERS - SET counter = counter + '$number' - WHERE referer = '".$referer."'"; - } else { - // insert - $sql2 = "INSERT INTO $TABLESTATS_REFERERS - (referer,counter) - VALUES ('".$referer."','".$number."')"; - } - Database::query($sql2); - } - } -} diff --git a/main/inc/lib/student_publication.class.php b/main/inc/lib/student_publication.class.php deleted file mode 100755 index 35b19eb031..0000000000 --- a/main/inc/lib/student_publication.class.php +++ /dev/null @@ -1,487 +0,0 @@ - for the Univesity of Geneva - */ -class StudentPublication -{ - - public static function void() - { - static $result = null; - if ($result) { - return $result; - } - - $result = new self(); - return $result; - } - - /** - * @return Model\StudentPublicationRepository - */ - public static function repository() - { - return StudentPublicationRepository::instance(); - } - - /** - * - * @param string $where - * @return \ResultSet - */ - public static function query($where) - { - return self::repository()->query($where); - } - - /** - * - * @param int|Course $c_id - * @param int $id - * @return \Model\StudentPublication - */ - public static function get_by_id($c_id, $id) - { - return self::repository()->get_by_id($c_id, $id); - } - - protected $c_id = 0; - protected $id = 0; - protected $url = ''; - protected $title = ''; - protected $description = ''; - protected $author = ''; - protected $active = null; - protected $accepted = false; - protected $post_group_id = 0; - protected $sent_date = 0; - protected $filetype = ''; - protected $has_properties = 0; - protected $view_properties = null; - protected $qualification = 0; - protected $date_of_qualification = 0; - protected $parent_id = 0; - protected $qualificator_id = 0; - protected $weight = 0; - protected $session_id = 0; - protected $user_id = null; - protected $allow_text_assignment = 0; - protected $contains_file = 0; - protected $course = null; - protected $item_property = null; - - public function __construct($data) - { - $data = (object) $data; - $this->c_id = (int) $data->c_id; - $this->id = (int) $data->id; - $this->url = $data->url; - $this->title = $data->title; - $this->description = $data->description; - $this->author = $data->author; - $this->active = $data->active; - $this->accepted = $data->accepted; - $this->post_group_id = $data->post_group_id; - $this->sent_date = $data->sent_date; - $this->filetype = $data->filetype; - $this->has_properties = $data->has_properties; - $this->view_properties = $data->view_properties; - $this->qualification = $data->qualification; - $this->date_of_qualification = $data->date_of_qualification; - $this->parent_id = $data->parent_id; - $this->qualificator_id = $data->qualificator_id; - $this->weight = $data->weight; - $this->session_id = $data->session_id; - $this->user_id = $data->user_id; - $this->allow_text_assignment = $data->allow_text_assignment; - $this->contains_file = $data->contains_file; - $this->course = $data->course; - $this->item_property = $data->item_property; - - $this->course = null; - - if (isset($data->property_id)) { - $property = (array) $data; - $property = (object) $property; - $property->id = $property->property_id; - $this->item_property = ItemProperty::create($property); - } else { - $this->item_property = null; - } - } - - public function get_c_id() - { - return $this->c_id; - } - - public function set_c_id($value) - { - $this->c_id = $value; - } - - public function get_id() - { - return $this->id; - } - - public function set_id($value) - { - $this->id = $value; - } - - public function get_url() - { - return $this->url; - } - - public function set_url($value) - { - $this->url = $value; - } - - public function get_title() - { - return $this->title; - } - - public function set_title($value) - { - $this->title = $value; - } - - public function get_description() - { - return $this->description; - } - - public function set_description($value) - { - $this->description = $value; - } - - public function get_author() - { - return $this->author; - } - - public function set_author($value) - { - $this->author = $value; - } - - public function get_active() - { - return $this->active; - } - - public function set_active($value) - { - $this->active = $value; - } - - public function get_accepted() - { - return $this->accepted; - } - - public function set_accepted($value) - { - $this->accepted = $value; - } - - public function get_post_group_id() - { - return $this->post_group_id; - } - - public function set_post_group_id($value) - { - $this->post_group_id = $value; - } - - public function get_sent_date() - { - return $this->sent_date; - } - - public function set_sent_date($value) - { - $this->sent_date = $value; - } - - public function get_filetype() - { - return $this->filetype; - } - - public function set_filetype($value) - { - $this->filetype = $value; - } - - public function get_has_properties() - { - return $this->has_properties; - } - - public function set_has_properties($value) - { - $this->has_properties = $value; - } - - public function get_view_properties() - { - return $this->view_properties; - } - - public function set_view_properties($value) - { - $this->view_properties = $value; - } - - public function get_qualification() - { - return $this->qualification; - } - - public function set_qualification($value) - { - $this->qualification = $value; - } - - public function get_date_of_qualification() - { - return $this->date_of_qualification; - } - - public function set_date_of_qualification($value) - { - $this->date_of_qualification = $value; - } - - public function get_parent_id() - { - return $this->parent_id; - } - - public function set_parent_id($value) - { - $this->parent_id = $value; - } - - public function get_qualificator_id() - { - return $this->qualificator_id; - } - - public function set_qualificator_id($value) - { - $this->qualificator_id = $value; - } - - public function get_weight() - { - return $this->weight; - } - - public function set_weight($value) - { - $this->weight = $value; - } - - public function get_session_id() - { - return $this->session_id; - } - - public function set_session_id($value) - { - $this->session_id = $value; - } - - public function get_user_id() - { - return $this->user_id; - } - - public function set_user_id($value) - { - $this->user_id = $value; - } - - public function get_allow_text_assignment() - { - return $this->allow_text_assignment; - } - - public function set_allow_text_assignment($value) - { - $this->allow_text_assignment = $value; - } - - public function get_contains_file() - { - return $this->contains_file; - } - - public function set_contains_file($value) - { - $this->contains_file = $value; - } - - public function is_folder() - { - return $this->filetype == 'folder'; - } - - public function is_file() - { - return $this->filetype == 'file'; - } - - public function is_visible() - { - $this->get_item_property()->get_visibility() == 1; - } - - public function is_accessible($user = null) - { - $user_id = $user ? $user : api_get_user_id(); - $result = $this->is_visible() || $this->get_user_id() == $user_id || api_is_allowed_to_edit(); - return $result; - } - - public function get_absolute_path() - { - return api_get_path(SYS_COURSE_PATH) . api_get_course_path() . '/' . $this->get_url(); - } - - /** - * - * @return \Model\ItemProperty - */ - public function get_item_property() - { - if ($this->item_property && $this->item_property->get_c_id() == $this->c_id && $this->item_property->get_ref() == $this->id) { - return $this->item_property; - } - - $this->item_property = ItemProperty::get_by_ref($this->id, TOOL_DOCUMENT); - return $this->item_property; - } - - /** - * - * @param bool $all - * @return ResultSet|array - */ - public function get_children() - { - if (!$this->is_folder()) { - return array(); - } - $id = $this->id; - $c_id = $this->c_id; - $where = "pub.c_id = $c_id AND pub.parent_id = $id"; - return self::query($where); - } - -} - -class StudentPublicationRepository -{ - - /** - * - * @staticvar null $result - * @return StudentPublicationRepository - */ - public static function instance() - { - static $result = null; - if (empty($result)) { - $result = new self(); - } - return $result; - } - - /** - * - * @param string $where - * @return \ResultSet - */ - public function query($where) - { - $table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); - $table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); - $tool = 'work'; - - $sql = "SELECT pub.*, - prop.id AS property_id, - prop.tool, - prop.insert_user_id, - prop.insert_date, - prop.lastedit_date, - prop.ref, - prop.lastedit_type, - prop.lastedit_user_id, - prop.to_group_id, - prop.to_user_id, - prop.visibility, - prop.start_visible, - prop.end_visible, - prop.id_session - FROM - $table AS pub, - $table_item_property AS prop - WHERE - (pub.id = prop.ref AND - pub.c_id = prop.c_id AND - prop.tool = '$tool')"; - - $sql .= $where ? "AND ($where)" : ''; - $result = new ResultSet($sql); - return $result->return_type(__CLASS__); - } - - /** - * - * @param int|Course $c_id - * @param int $id - * @return \Model\StudentPublication - */ - public function get_by_id($c_id, $id) - { - $c_id = is_object($c_id) ? $c_id->get_id() : (int) $c_id; - return $this->query("pub.c_id = $c_id AND pub.id = $id")->first(); - } - - public function update($pub) - { - - } - -} \ No newline at end of file diff --git a/main/inc/lib/surveymanager.lib.php b/main/inc/lib/surveymanager.lib.php index 3871d8a8f1..733de3900e 100755 --- a/main/inc/lib/surveymanager.lib.php +++ b/main/inc/lib/surveymanager.lib.php @@ -1,5 +1,6 @@ for the Univesity of Geneva - * @see http://closure-compiler.appspot.com/home - * @see https://developers.google.com/closure/compiler/ - * - */ -class ClosureCompiler -{ - - const PARAM_OUTPUT_FORMAT = 'output_format'; - const PARAM_OUTPUT_INFO = 'output_info'; - const PARAM_COMPILATION_LEVEL = 'compilation_level'; - const PARAM_JS_CODE = 'js_code'; - const LEVEL_SIMPLE = 'SIMPLE_OPTIMIZATIONS'; - const LEVEL_WHITESPACE = 'WHITESPACE_ONLY'; - const LEVEL_ADVANCED = 'ADVANCED_OPTIMIZATIONS'; - const OUTPUT_FORMAT_TEXT = 'text'; - const OUTPUT_INFO_CODE = 'compiled_code'; - - /** - * Url of the service - * - * @return string - */ - public static function url() - { - return 'closure-compiler.appspot.com/compile'; - } - - /** - * Post data the closure compiler service. By default it returns minimized code - * with the simple option. - * - * @param string $code Javascript code to minimify - * @param array $params parameters to pass to the service - * @return string minimified code - */ - public static function post($code, $params = array()) - { - if (!isset($params[self::PARAM_OUTPUT_FORMAT])) - { - $params[self::PARAM_OUTPUT_FORMAT] = self::OUTPUT_FORMAT_TEXT; - } - if (!isset($params[self::PARAM_OUTPUT_INFO])) - { - $params[self::PARAM_OUTPUT_INFO] = self::OUTPUT_INFO_CODE; - } - if (!isset($params[self::PARAM_COMPILATION_LEVEL])) - { - $params[self::PARAM_JS_CODE] = $code; - } - - $params[self::PARAM_COMPILATION_LEVEL] = self::LEVEL_SIMPLE; - - $fields = array(); - foreach ($params as $key => $value) - { - $fields[] = $key . '=' . urlencode($value); - } - $fields = implode('&', $fields); - - $headers = array("Content-type: application/x-www-form-urlencoded"); - - $url = self::url(); - - $ch = curl_init(); - - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); - //curl_setopt($ch, CURLOPT_HEADER, false); - //curl_setopt($ch, CURLOPT_VERBOSE, true); - - $content = curl_exec($ch); - $error = curl_error($ch); - $info = curl_getinfo($ch); - - curl_close($ch); - - return $content; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/code_utilities.class.php b/main/inc/lib/system/code_utilities.class.php deleted file mode 100755 index 377674adf1..0000000000 --- a/main/inc/lib/system/code_utilities.class.php +++ /dev/null @@ -1,92 +0,0 @@ - for the Univesity of Geneva - */ -class CodeUtilities -{ - - const CLASS_PATTERN = '/(?:\s+class\s+[a-zA-Z_0-9\x7f-\xff]+\s*{)|(?:\s+class\s+[a-zA-Z_0-9\x7f-\xff]+\s*extends)|(?:\s+class\s+[a-zA-Z_0-9\x7f-\xff]+\s*implements)|(?:\s+interface\s+[a-zA-Z_0-9\x7f-\xff]+\s*{)|(?:\s+interface\s+[a-zA-Z_0-9\x7f-\xff]+\s*extends)/mi'; - const INLINE_COMMENT_PATTERN = '#//.*$#m'; - const MULTILINE_COMMENT_PATTERN = '#/\*.*?\*/#ms'; - const NAMESPACE_PATTERN = '/namespace\s*(.*);/'; - const IDENTIFIER_PATTERN = '/^[a-zA-Z_][a-zA-Z0-9_]*$/'; - - static function remove_comments($content) - { - $content = preg_replace(self::INLINE_COMMENT_PATTERN, '', $content); - $content = preg_replace(self::MULTILINE_COMMENT_PATTERN, '', $content); - return $content; - } - - /** - * Returns the name of classes and interfaces contained in content. - * - * @param text $content - * @return array - */ - static function get_classes($content) - { - $result = array(); - $cls_pattern = self::CLASS_PATTERN; - - $content = self::remove_comments($content); //comments may contains class declaration we don't want to capture. - - $matches = array(); - if (preg_match_all($cls_pattern, $content, $matches)) { - $matches = reset($matches); - foreach ($matches as $match) { - $match = str_replace("\n", ' ', $match); - $match = str_replace('{', ' ', $match); - $words = explode(' ', $match); - foreach ($words as $word) { - $word = trim($word); - //we capture the interface/class name with the current pattern - if (strtolower($word) != 'class' && strtolower($word) != 'interface' && strtolower($word) != 'implements' && strtolower($word) != 'extends' && !empty($word)) { - $result[] = $word; - break; //we only take the first name as we don't want to capture the name of the interface or of the parent class name - } - } - } - } - return $result; - } - - static function get_namespace($content) - { - $namespace_pattern = self::NAMESPACE_PATTERN; - if (preg_match($namespace_pattern, $content, $matches)) { - $result = end($matches); - return trim($result); - } else { - return false; - } - } - - static function is_valid_identifier($name) - { - $pattern = self::IDENTIFIER_PATTERN; - $r = preg_match($pattern, $name); - return $r; - } - - /** - * Make path relative to root. - * - * @param string $root - * @param string $path - * @return string - */ - static function relative_path($root, $path) - { - $path = realpath($path); - $root = realpath($root); - $path = str_ireplace($root, '', $path); - $path = str_ireplace('\\', '/', $path); - return $path; - } - -} diff --git a/main/inc/lib/system/io/csv_object_writer.class.php b/main/inc/lib/system/io/csv_object_writer.class.php deleted file mode 100755 index 4765ff486d..0000000000 --- a/main/inc/lib/system/io/csv_object_writer.class.php +++ /dev/null @@ -1,129 +0,0 @@ -property_name_1 = 'name 1'; - * $object->property_name_2 = 'name 2'; - * - * $map = array( 'property_name_1' => 'Header title 1', - * 'property_name_2' => 'Header title 2'); - * - * $writer = CsvObjectWriter::create($map, 'temp'); - * $writer->add($object); - * - * Output - * - * "Header title 1";"Header title 2" - * "name 1";"name 2" - * - * @license /licence.txt - * @author Laurent Opprecht - */ -class CsvObjectWriter extends CsvWriter -{ - - /** - * - * @param string|object $stream - * @return CsvWriter - */ - static function create($stream, $map = '*', $delimiter = ';', $enclosure = '"') - { - return new self($stream, $map = '*', $map, $delimiter, $enclosure); - } - - protected $map = '*'; - protected $headers_written = false; - - function __construct($stream, $map = '*', $delimiter = ';', $enclosure = '"') - { - parent::__construct($stream, $delimiter, $enclosure); - $this->map = $map; - } - - public function get_map() - { - return $this->map; - } - - /** - * - * @param object $item - * @return boolean - */ - public function put($item) - { - $data = $this->convert($item); - if (empty($data)) { - return false; - } - $this->writer_headers(); - parent::put($data); - return true; - } - - /** - * Convert object to array of data - * @param object $object - * @return array - */ - protected function convert($item) - { - $result = array(); - $map = $this->map; - if ($map == '*') { - return (array) $item; - } - foreach ($map as $key => $value) { - $result[$key] = isset($item->{$key}) ? $item->{$key} : ''; - } - return $result; - } - - /** - * - * @param array $items - */ - public function add_all($items) - { - foreach ($items as $item) { - $this->add($item); - } - } - - /** - * - * @param array|object $item - */ - public function add($item) - { - if (is_array($item)) { - $this->add_all($item); - return; - } - $this->put($item); - } - - protected function writer_headers() - { - if ($this->headers_written) { - return; - } - $this->headers_written = true; - - $map = $this->map; - if (!is_array($map)) { - return; - } - - $headers = array(); - foreach ($map as $key => $value) { - $headers[] = $value; - } - parent::put($headers); - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/io/csv_reader.class.php b/main/inc/lib/system/io/csv_reader.class.php deleted file mode 100755 index 5a0ffd9265..0000000000 --- a/main/inc/lib/system/io/csv_reader.class.php +++ /dev/null @@ -1,170 +0,0 @@ -$value){ - * echo "$key : $value"; - * } - * } - * - * - * - * @copyright (c) 2012 University of Geneva - * @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html - * @author Laurent Opprecht - */ -class CsvReader implements Iterator -{ - - /** - * - * @param string|FileReader $stream - * @param string $delimiter - * @param string $enclosure - * @return CsvReader - */ - static function create($stream, $delimiter = ';', $enclosure = '"') - { - return new self($stream, $delimiter, $enclosure); - } - - protected $stream = null; - protected $headers = array(); - protected $delimiter = ''; - protected $enclosure = ''; - protected $current = false; - protected $index = -1; - - function __construct($stream, $delimiter = ';', $enclosure = '"') - { - $this->stream = $stream; - $this->delimiter = $delimiter ? substr($delimiter, 0, 1) : ';'; - $this->enclosure = $enclosure ? substr($enclosure, 0, 1) : '"'; - } - - function get_delimiter() - { - return $this->delimiter; - } - - function get_enclosure() - { - return $this->enclosure; - } - - function headers() - { - return $this->headers; - } - - /** - * @return FileReader - */ - function stream() - { - if (is_string($this->stream)) { - $this->stream = new FileReader($this->stream); - } - return $this->stream; - } - - protected function decode($line) - { - if (empty($line)) { - return array(); - } - $data = api_str_getcsv($line, $this->get_delimiter(), $this->get_enclosure()); - if ($this->headers) { - $result = array(); - foreach ($data as $index => $value) { - $key = isset($this->headers[$index]) ? $this->headers[$index] : false; - if ($key) { - $result[$key] = $value; - } else { - $result[] = $value; - } - } - } else { - $result = $data; - } - return $result; - } - - /** - * Returns the next non empty line - * - * @return boolean|string - */ - protected function next_line() - { - while (true) { - $line = $this->stream()->next(); - if ($line === false) { - return false; - } else if ($line) { - return $line; - } - } - return false; - } - - public function current() - { - return $this->current; - } - - public function key() - { - return $this->index; - } - - public function next() - { - if (empty($this->headers)) { - $line = $this->next_line(); - $this->headers = $this->decode($line); - } - $line = $this->next_line(); - if ($line) { - $this->current = $this->decode($line); - $this->index++; - } else { - $this->current = false; - } - return $this->current; - } - - public function rewind() - { - $this->stream()->rewind(); - $line = $this->stream()->current(); - if (empty($line)) { - $line = $this->next_line(); - } - $this->headers = $this->decode($line); - $this->index = -1; - $this->next(); - } - - public function valid() - { - return $this->current !== false; - } - - function __clone() - { - $this->stream()->rewind(); - $this->current = false; - $this->index = -1; - $this->headers = array(); - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/io/csv_writer.class.php b/main/inc/lib/system/io/csv_writer.class.php deleted file mode 100755 index b2737332d6..0000000000 --- a/main/inc/lib/system/io/csv_writer.class.php +++ /dev/null @@ -1,100 +0,0 @@ -put($headers); - * $writer->put($line_1); - * $writer->put($line_2); - * - * @copyright (c) 2012 University of Geneva - * @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html - * @author Laurent Opprecht - */ -class CsvWriter -{ - - /** - * - * @param string|object $stream - * @return CsvWriter - */ - static function create($stream, $delimiter = ';', $enclosure = '"') - { - return new self($stream, $delimiter, $enclosure); - } - - protected $stream = null; - protected $delimiter = ''; - protected $enclosure = ''; - - function __construct($stream, $delimiter = ';', $enclosure = '"') - { - $this->stream = $stream; - $this->delimiter = $delimiter ? substr($delimiter, 0, 1) : ';';; - $this->enclosure = $enclosure ? substr($enclosure, 0, 1) : '"';; - } - - function get_delimiter() - { - return $this->delimiter; - } - - function get_enclosure() - { - return $this->enclosure; - } - - function get_stream(){ - return $this->stream; - } - - /** - * - * @return FileWriter - */ - protected function stream() - { - if (is_string($this->stream)) { - $this->stream = new FileWriter($this->stream); - } - return $this->stream; - } - - function write($items) - { - $items = is_array($items) ? $items : func_get_args(); - $this->put($items); - } - - function writeln($items) - { - $items = is_array($items) ? $items : func_get_args(); - $this->put($items); - } - - function put($items) - { - $items = is_array($items) ? $items : func_get_args(); - $enclosure = $this->enclosure; - $fields = array(); - foreach ($items as $item) { - $fields[] = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $item) . $enclosure; - } - - $delimiter = $this->delimiter; - $line = implode($delimiter, $fields); - $this->stream()->writeln($line); - } - - function close() - { - if (is_object($this->stream)) { - $this->stream->close(); - } - $this->stream = null; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/io/file_reader.class.php b/main/inc/lib/system/io/file_reader.class.php deleted file mode 100755 index 7673da2ca1..0000000000 --- a/main/inc/lib/system/io/file_reader.class.php +++ /dev/null @@ -1,182 +0,0 @@ - - */ -class FileReader implements Iterator -{ - - const EOL = "\n"; - - /** - * - * @param string $path - * @return FileReader - */ - static function create($path, $converter = null) - { - return new self($path, $converter); - } - - /** - * Returns the file encoding - * - * @return Encoding - */ - static function detect_encoding($path) - { - $abstract = array(); - // We assume that 200 lines are enough for encoding detection. - // here we must get at the raw data so we don't use other functions - // it's not possible to read x chars as this would not be safe with utf - // (chars may be split in the middle) - $handle = fopen($path, 'r'); - - $i = 0; - while (($line = fgets($handle)) !== false && $i < 200) { - $i++; - $abstract[] = $line; - } - fclose($handle); - $abstract = implode($abstract); - return Encoding::detect_encoding($abstract); - } - - protected $path = ''; - protected $handle = null; - protected $current = false; - protected $index = -1; - protected $converter = null; - - function __construct($path, $converter = null) - { - if (empty($converter)) { - $encoding = self::detect_encoding($path); - $converter = $encoding->decoder(); - } - $this->path = $path; - $this->converter = $converter; - } - - /** - * - * @return Converter - */ - function get_converter() - { - return $this->converter; - } - - function handle() - { - if (is_null($this->handle)) { - $this->handle = fopen($this->path, 'r'); - } - return $this->handle; - } - - /** - * Read at most $count lines. - * - * @param int $count - * @return array - */ - function read_lines($count) - { - $result; - $i = 0; - foreach ($this as $line) { - if ($i >= $count) { - return $result; - } - $i++; - $result[] = $line; - } - return $result; - } - - function read_line() - { - return $this->next(); - } - - function close() - { - if (is_resource($this->handle)) { - fclose($this->handle); - } - $this->handle = null; - } - - protected function convert($text) - { - return $this->converter->convert($text); - } - - public function current() - { - return $this->current; - } - - public function key() - { - return $this->index; - } - - public function next() - { - $handle = $this->handle(); - if($handle === false) - { - $this->current = false; - return false; - } - $line = fgets($handle); - if ($line !== false) { - $line = rtrim($line, "\r\n"); - $line = $this->convert($line); - $this->index++; - } - $this->current = $line; - return $this->current; - } - - public function rewind() - { - $this->converter->reset(); - if ($handle = $this->handle()) { - rewind($handle); - } - $this->current = false; - $this->index = -1; - $this->next(); - } - - public function valid() - { - return $this->current !== false; - } - - function __clone() - { - $this->handle = null; - $this->current = false; - $this->index = -1; - $this->converter->reset(); - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/io/file_writer.class.php b/main/inc/lib/system/io/file_writer.class.php deleted file mode 100755 index 0a56aa0e72..0000000000 --- a/main/inc/lib/system/io/file_writer.class.php +++ /dev/null @@ -1,81 +0,0 @@ - - */ -class FileWriter -{ - - /** - * - * @param string $path - * @param Converter $converter - * @return FileWriter - */ - static function create($path, $converter = null) - { - return new self($path, $converter); - } - - const EOL = "\n"; - - protected $path = ''; - protected $handle = null; - protected $converter = null; - - /** - * - * @param string $path - * @param Encoding $encoding - */ - function __construct($path, $converter = null) - { - $this->path = $path; - $this->converter = $converter ? $converter : Encoding::utf8()->encoder(); - } - - /** - * - * @return Converter - */ - function get_converter() - { - return $this->converter; - } - - protected function handle() - { - if (is_null($this->handle)) { - $this->handle = fopen($this->path, 'a+'); - } - return $this->handle; - } - - function write($text) - { - fwrite($this->handle(), $this->convert($text)); - } - - function writeln($text) - { - fwrite($this->handle(), $this->convert($text) . self::EOL); - } - - function close() - { - if (is_resource($this->handle)) { - fclose($this->handle); - } - $this->handle = null; - } - - protected function convert($text) - { - return $this->converter->convert($text); - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/io/temp.class.php b/main/inc/lib/system/io/temp.class.php deleted file mode 100755 index 5d5308fee5..0000000000 --- a/main/inc/lib/system/io/temp.class.php +++ /dev/null @@ -1,164 +0,0 @@ - - */ -class Temp -{ - - protected static $files = array(); - - /** - * Returns the list of temporary files opened by the script. - * This is mostly due to pin temporary files and prevent garbage collection. - * This ensure files are not unlinked while still using it to send data in - * an upload. - * - * @return array - */ - public static function files() - { - return self::$files; - } - - /** - * Recursively delete files and/or folders. - * - * @param string $path - * @return boolean - */ - public static function delete($path) - { - if (!file_exists($path)) { - return false; - } - - if (is_readable($path)) { - unlink($path); - return true; - } - - if (is_dir($path)) { - $files = scandir($path); - $files = array_diff($files, array('.', '..')); - foreach ($files as $file) { - self::delete($file); - } - rmdir($path); - } - } - - private static $temp_root = ''; - - /** - * Set the temp root directory. Temporary files are by default created in this directory. - * Defaults to sys_get_temp_dir(). - * - * @param string $value - */ - public static function set_temp_root($value) - { - self::$temp_root = $value; - } - - public static function get_temp_root() - { - if (empty(self::$temp_root)) { - self::$temp_root = sys_get_temp_dir(); - } - - return self::$temp_root; - } - - /** - * Returns a path to a non-existing temporary file located under temp_dir. - * - * @return string - */ - public static function get_temporary_name() - { - $result = self::get_temp_root() . '/' . md5(uniqid('tmp', true)); - while (file_exists($result)) { - $result = self::get_temp_root() . '/' . md5(uniqid('tmp', true)); - } - return $result; - } - - /** - * - * @param string $path - * @return Temp - */ - public static function file($path = '') - { - $path = $path ? $path : self::get_temporary_name(); - return new self($path); - } - - /** - * - * @param string $path - * @return Temp - */ - public static function dir($path = '') - { - $path = $path ? $path : self::get_temporary_name(); - if (!file_exists($path)) { - mkdir($path, 0777, $true); - } - return new self($path); - } - - /** - * - * @param string $path - * @return Temp - */ - public static function create($path = '') - { - $path = $path ? $path : self::get_temporary_name(); - return new self($path); - } - - protected $path = ''; - - function __construct($path = '') - { - self::$files[] = $this; - $this->path = $path; - } - - function get_path() - { - return $this->path; - } - - function __toString() - { - return $this->path; - } - - function __destruct() - { - $path = $this->path; - self::delete($path); - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/__README.txt b/main/inc/lib/system/media/renderer/__README.txt deleted file mode 100755 index da33a4f0af..0000000000 --- a/main/inc/lib/system/media/renderer/__README.txt +++ /dev/null @@ -1 +0,0 @@ -Used to extract metadata from external resources : youtube, dailymotion, etc \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/asset_aggregated_renderer.class.php b/main/inc/lib/system/media/renderer/asset_aggregated_renderer.class.php deleted file mode 100755 index a36c91d812..0000000000 --- a/main/inc/lib/system/media/renderer/asset_aggregated_renderer.class.php +++ /dev/null @@ -1,56 +0,0 @@ -renderers = $renderers; - } - - /** - * - * @return array - */ - public function renderers() - { - return $this->renderers; - } - - /** - * - * @param HttpResource $asset - * @return array - */ - public function render($asset) - { - $result = array(); - $plugins = self::plugins(); - foreach ($this->renderers as $renderer) - { - $data = $renderer->render($asset); - $data = $data ? $data : array(); - foreach ($data as $key => $value) - { - if (!isset($result[$key]) && !empty($value)) - { - $result[$key] = $value; - } - } - } - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/asset_renderer.class.php b/main/inc/lib/system/media/renderer/asset_renderer.class.php deleted file mode 100755 index 3173e0518d..0000000000 --- a/main/inc/lib/system/media/renderer/asset_renderer.class.php +++ /dev/null @@ -1,107 +0,0 @@ -render($asset); - $result['url'] = $url; - return $result; - } - - static function plugins() - { - static $result = array(); - if (!empty($result)) - { - return $result; - } - - /* - * We make sure we load them from most specialized to less specialized. - * The first that provides a value for a field wins. - */ - $protocols = array( - 'oembed', - 'og', - 'image', - 'media', - 'rss', - 'google_map', - 'google_document', - 'google_document_viewer', - 'google_widget', - 'mediaserver', - 'scratch', - 'page'); - - foreach ($protocols as $protocol) - { - $file = "asset_{$protocol}_renderer.class.php"; - require_once dirname(__FILE__) . '/protocol/' . $file; - - $class = "asset_{$protocol}_renderer"; - $class = explode('_', $class); - $class = array_map('ucfirst', $class); - $class = implode($class); - - $result[] = new $class(); - } - return $result; - } - - /** - * Renderer function. Take a http asset as input and return an array containing - * various properties: metadata, html snippet, etc. - * - * @param HttpResource $asset - * @return array - */ - public function render($asset) - { - $result = array(); - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/http_resource.class.php b/main/inc/lib/system/media/renderer/http_resource.class.php deleted file mode 100755 index 591da048eb..0000000000 --- a/main/inc/lib/system/media/renderer/http_resource.class.php +++ /dev/null @@ -1,662 +0,0 @@ -url = $url; - $this->config = $config; - } - - public function config($key = '', $default = null) - { - return isset($this->config[$key]) ? $this->config[$key] : $default; - } - - /** - * Url of the resource - * - * @return string - */ - public function url() - { - return $this->url; - } - - public function url_domain() - { - $url = $this->url(); - $url = trim($url, '/'); - if (strpos($url, '//') !== false) - { - $parts = explode('//', $url); - $url = end($parts); - } - $parts = explode('/', $url); - $result = reset($parts); - return $result; - } - - /** - * - * @param array|string $part - * @return boolean - */ - public function url_match($part) - { - $params = func_get_args(); - $params = is_array($params) ? $params : array($params); - - $url = strtolower($this->url()); - foreach ($params as $param) - { - if (strpos($url, strtolower($param)) !== false) - { - return true; - } - } - return false; - } - - public function url_params() - { - if (!is_null($this->url_params)) - { - return $this->url_params; - } - - $url = $this->url(); - if (strpos($url, '?') === false) - { - return $this->url_params = array(); - } - - $result = array(); - $params = explode('?', $url); - $params = end($params); - $params = explode('&', $params); - foreach ($params as $param) - { - list($key, $val) = explode('=', $param); - $result[$key] = $val; - } - - return $this->url_params = $result; - } - - public function url_param($name, $default = false) - { - $params = $this->url_params(); - return isset($params[$name]) ? $params[$name] : $default; - } - - /** - * The name of the resource. I.e. the last part of the url without the ext - * - * @return string - */ - public function name() - { - $url = $this->url(); - $url = explode('/', $url); - $title = end($url); - $title = explode('.', $title); - $title = reset($title); - return $title; - } - - /** - * Extention of the url - * - * @return string - */ - public function ext() - { - $url = $this->url(); - $url = explode('.', $url); - $ext = end($url); - $ext = strtolower($ext); - return $ext; - } - - /** - * Return true if the object has one of the extentions. Overloaded: - * - * $res->has_ext('pdf'); - * $res->has_ext('pdf', 'doc'); - * $res->has_ext(array('pdf', 'doc')); - * - * @param array|string $_ - * @return boolean true if the resource has one of the extentions passed - */ - public function has_ext($_) - { - if (is_array($_)) - { - $params = $_; - } - else - { - $params = func_get_args(); - $params = is_array($params) ? $params : array($params); - } - $ext = $this->ext(); - foreach ($params as $param) - { - if (strtolower($param) == $ext) - { - return true; - } - } - return false; - } - - public function charset() - { - $info = $this->info(); - - $content_type = isset($info['content_type']) ? $info['content_type'] : ''; - if (empty($content_type)) - { - return null; - } - $items = explode(';', $content_type); - foreach ($items as $item) - { - $parts = explode('=', $item); - if (count($parts) == 2 && reset($parts) == 'charset') - { - return strtolower(end($parts)); - } - } - return null; - } - - /** - * The mime type of the resource or the empty string if none has been specified - * - * @return string - */ - public function mime() - { - if (!is_null($this->mime)) - { - return $this->mime; - } - $info = $this->info(); - - $content_type = isset($info['content_type']) ? $info['content_type'] : ''; - if ($content_type) - { - $result = reset(explode(';', $content_type)); - $result = strtolower($result); - return $this->mime = $result; - } - - return $this->mime = ''; - } - - public function is_xml() - { - $mime = $this->mime(); - if (!empty($mime)) - { - return strpos($mime, 'xml') !== false; - } - return $this->ext() == 'xml'; - } - - public function is_image() - { - $mime = $this->mime(); - if ($mime) - { - return strpos($mime, 'image') !== false; - } - - $ext = $this->ext(); - $formats = array('gif', 'jpeg', 'jpg', 'jpe', 'pjpeg', 'png', 'svg', 'tiff', 'ico'); - foreach ($formats as $format) - { - if ($format == $ext) - { - return true; - } - } - return false; - } - - public function is_video() - { - $mime = $this->mime(); - if ($mime) - { - return strpos($mime, 'video') !== false; - } - - $ext = $this->ext(); - $formats = array('mpeg', 'mp4', 'ogg', 'wmv', 'mkv'); - foreach ($formats as $format) - { - if ($format == $ext) - { - return true; - } - } - return false; - } - - public function is_audio() - { - $mime = $this->mime(); - if ($mime) - { - return strpos($mime, 'audio') !== false; - } - - $ext = $this->ext(); - $formats = array('mp3'); - foreach ($formats as $format) - { - if ($format == $ext) - { - return true; - } - } - return false; - } - - public function is_rss() - { - if (!$this->is_xml()) - { - return false; - } - - $doc = $this->doc(); - $nodes = $doc->getElementsByTagName('rss'); - return $nodes->length != 0; - } - - public function is_gadget() - { - if (!$this->is_xml()) - { - return false; - } - - $doc = $this->doc(); - $nodes = $doc->getElementsByTagName('ModulePrefs'); - return $nodes->length != 0; - } - - public function canonic_url($src) - { - if (strpos($src, '//') === 0) - { - $src = "http:$src"; - } - else if (strpos($src, '/') === 0) //relative url to the root - { - $url = $this->url(); - $protocol = reset(explode('://', $url)); - $domain = end(explode('://', $url)); - $domain = reset(explode('/', $domain)); - $src = "$protocol://$domain/$src"; - } - else if (strpos($src, 'http') !== 0) //relative url to the document - { - $url = $this->url(); - $tail = end(explode('/', $url)); - $base = str_replace($tail, '', $url); - - $src = $base . $src; - } - return $src; - } - - /** - * Content of the resource. - * - * @return string - */ - public function source() - { - if (!is_null($this->source)) - { - return $this->source; - } - $info = $this->info(); - - return $this->source = $info['content']; - } - - /** - * Array of arrays containing the page's metadata. - * - * @return array - */ - public function metadata() - { - if (!is_null($this->metadata)) - { - return $this->metadata; - } - return $this->metadata = $this->get_metadata(); - } - - public function title() - { - if (!is_null($this->title)) - { - return $this->title; - } - return $this->title = $this->get_title(); - } - - /** - * - * @return DOMDocument|boolean - */ - public function doc() - { - if (!is_null($this->doc)) - { - return $this->doc; - } - return $this->doc = $this->get_doc($this->source()); - } - - function get_meta($name) - { - $metadata = $this->metadata(); - $name = strtolower($name); - foreach ($metadata as $attributes) - { - $key = isset($attributes['name']) ? $attributes['name'] : false; - $key = $key ? strtolower($key) : $key; - if ($name == $key) - { - return $attributes['content']; - } - $key = isset($attributes['property']) ? $attributes['property'] : false; - $key = $key ? strtolower($key) : $key; - if ($name == $key) - { - return isset($attributes['content']) ? $attributes['content'] : false; - } - } - return false; - } - - function get_link($key, $value) - { - $links = $this->links(); - $key = strtolower($key); - $value = strtolower($value); - foreach ($links as $attributes) - { - $a = isset($attributes[$key]) ? $attributes[$key] : false; - $a = $a ? strtolower($a) : $a; - if ($a == $value) - { - return $attributes; - } - } - return false; - } - - public function links() - { - if (!is_null($this->links)) - { - return $this->links; - } - return $this->links = $this->get_links(); - } - - /** - * - * @param string $xpath dom xpath - * @return string - */ - public function findx($query) - { - $doc = $this->doc(); - if (empty($doc)) - { - return array(); - } - $xpath = new DOMXpath($doc); - $nodes = $xpath->query($query); - if ($nodes->length > 0) - { - return $doc->saveXML($nodes->item(0)); - } - else - { - return ''; - } - } - - protected function info() - { - if (!is_null($this->info)) - { - return $this->info; - } - return $this->info = self::fetch($this->url()); - } - - /** - * - * @param string $source - * @return boolean|DOMDocument - */ - protected function get_doc($source) - { - if ($source == false) - { - return false; - } - $source = $this->source(); - $result = new DOMDocument(); - libxml_clear_errors(); - libxml_use_internal_errors(true); - if ($this->is_xml()) - { - $success = $result->loadXML($source); - } - else - { - $success = $result->loadHTML($source); - } - //$e = libxml_get_errors(); - return $result ? $result : false; - } - - protected function get_metadata() - { - $result = array(); - - $doc = $this->doc(); - if ($doc == false) - { - return array(); - } - $metas = $doc->getElementsByTagName('meta'); - if ($metas->length == 0) - { - return $result; - } - foreach ($metas as $meta) - { - $values = array(); - $attributes = $meta->attributes; - $length = $attributes->length; - for ($i = 0; $i < $length; ++$i) - { - $name = $attributes->item($i)->name; - $value = $attributes->item($i)->value; - $value = $attributes->item($i)->value; - $values[$name] = $value; - } - $result[] = $values; - } - return $result; - } - - protected function get_title() - { - $doc = $this->doc(); - if ($doc == false) - { - return ''; - } - $titles = $doc->getElementsByTagName('title'); - if ($titles->length == 0) - { - return false; - } - $result = $titles->item(0)->nodeValue; - return $result; - } - - protected function get_links() - { - $doc = $this->doc(); - if ($doc == false) - { - return array(); - } - $result = array(); - - $metas = $doc->getElementsByTagName('link'); - if ($metas->length == 0) - { - return $result; - } - foreach ($metas as $meta) - { - $values = array(); - $attributes = $meta->attributes; - $length = $attributes->length; - for ($i = 0; $i < $length; ++$i) - { - $name = $attributes->item($i)->name; - $value = $attributes->item($i)->value; - $values[$name] = $value; - } - $result[] = $values; - } - return $result; - } - -} diff --git a/main/inc/lib/system/media/renderer/lab/asset_google_calendar_renderer.class.php b/main/inc/lib/system/media/renderer/lab/asset_google_calendar_renderer.class.php deleted file mode 100755 index 8787b16ba6..0000000000 --- a/main/inc/lib/system/media/renderer/lab/asset_google_calendar_renderer.class.php +++ /dev/null @@ -1,113 +0,0 @@ -url(); - $url = str_replace('http://', '', $url); - $url = str_replace('https://', '', $url); - - $domain = reset(split('/', $url)); - return strpos($domain, 'google.com/calendar') !== false; - } - - /** - * - * @param string $url - */ - public function explode_url_parameters($url = null) - { - if (strpos($url, '?') === false) - { - return array(); - } - - $result = array(); - $params = explode('?', $url); - $params = end($params); - $params = explode('&', $params); - foreach ($params as $param) - { - list($key, $val) = explode('=', $param); - $result[$key] = $val; - } - - return $result; - } - - public function implode_url_parameters($params) - { - $result = array(); - foreach ($params as $key => $value) - { - if ($value) - { - $result[] = "$key=$value"; - } - } - return join('&', $result); - } - - protected function url($base = 'http:://map.google.com/', $params = array()) - { - $head = reset(explode('?', $base)); - $items = $this->explode_url_parameters($base); - foreach ($params as $key => $value) - { - $items[$key] = $value; - } - $tail = $this->implode_url_parameters($items); - $tail = empty($tail) ? '' : "?$tail"; - return $head . $tail; - } - - /** - * - * @param HttpResource $asset - */ - public function render($asset) - { - if (!$this->accept($asset)) - { - return; - } - $params = array('output' => 'embed'); - - $base = $asset->url(); - $url = $this->url($base, $params); - - $title = $asset->title(); - $description = $asset->get_meta('description'); - - $keywords = $asset->get_meta('keywords'); - - $embed = << -EOT; - - - $result = array(); - $result[self::EMBED_SNIPPET] = $embed; - $result[self::TITLE] = $title; - $result[self::THUMBNAIL] = $image_src; - $result[self::DESCRIPTION] = $description; - $result[self::TAGS] = $keywords; - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/lab/asset_mahara_group_renderer.class.php b/main/inc/lib/system/media/renderer/lab/asset_mahara_group_renderer.class.php deleted file mode 100755 index 85e0a6c1bc..0000000000 --- a/main/inc/lib/system/media/renderer/lab/asset_mahara_group_renderer.class.php +++ /dev/null @@ -1,57 +0,0 @@ -url(); - $group_id = self::get_group_id($url); - if (empty($group_id)) - { - return false; - } - - $data = get_record('group', 'id', $group_id); - - $result = array(); - safe_require('blocktype', 'ple/group'); - $result[self::EMBED_SNIPPET] = PluginBlocktypeGroup::render_preview($group_id); - $result[self::THUMBNAIL] = PluginBlocktypeGroup::get_thumbnail($group_id); - $result[self::TITLE] = $data->name; - $result[self::DESCRIPTION] = $data->description; - - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/lab/asset_mahara_person_renderer.class.php b/main/inc/lib/system/media/renderer/lab/asset_mahara_person_renderer.class.php deleted file mode 100755 index a264885ad0..0000000000 --- a/main/inc/lib/system/media/renderer/lab/asset_mahara_person_renderer.class.php +++ /dev/null @@ -1,63 +0,0 @@ -id; - } - //user id - if ($val = intval($ref)) - { - return $val; - } - - return false; - } - - /** - * - * @param HttpResource $asset - */ - public function render($asset) - { - $url = $asset->url(); - $id = self::get_user_id($url); - if (empty($id)) - { - return false; - } - - $data = get_record('usr', 'id', $id); - - $result = array(); - safe_require('blocktype', 'ple/person'); - $result[self::EMBED_SNIPPET] = PluginBlocktypePerson::render_preview($id); - $result[self::THUMBNAIL] = PluginBlocktypePerson::get_thumbnail($id); - $result[self::TITLE] = $data->prefferedname ? $data->prefferedname : $data->firstname . ' ' . $data->lastname; - $result[self::DESCRIPTION] = isset($data->description) ? $data->description : ''; - - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/lab/asset_wiki_renderer.class.php b/main/inc/lib/system/media/renderer/lab/asset_wiki_renderer.class.php deleted file mode 100755 index b110cdab07..0000000000 --- a/main/inc/lib/system/media/renderer/lab/asset_wiki_renderer.class.php +++ /dev/null @@ -1,46 +0,0 @@ -url_match('wikipedia.org/wiki', 'mediawiki.org/wiki'); - } - - /** - * - * @param HttpResource $asset - * - */ - public function render($asset) - { - if (!$this->accept($asset)) - { - return; - } - - $domain = $asset->url_domain(); - $description = $asset->findx('//div[@id="bodyContent"]/p'); - $result = array(); - $result[self::EMBED_SNIPPET] = $description; - $result[self::TITLE] = $title; - $result[self::DESCRIPTION] = $description; - $result[self::TAGS] = $keywords; - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/protocol/asset_google_document_renderer.class.php b/main/inc/lib/system/media/renderer/protocol/asset_google_document_renderer.class.php deleted file mode 100755 index f8e26995c2..0000000000 --- a/main/inc/lib/system/media/renderer/protocol/asset_google_document_renderer.class.php +++ /dev/null @@ -1,75 +0,0 @@ -url(); - - return strpos($url, 'docs.google.com/document/pub') !== false; - } - - /** - * - * @param HttpResource $asset - */ - public function render($asset) - { - if (!$this->accept($asset)) - { - return; - } - - $url = $asset->url(); - - $title = $asset->title(); - $description = $asset->get_meta('description'); - $keywords = $asset->get_meta('keywords'); - - $size = (int) $asset->config('size'); - $size = (24 <= $size && $size <= 800) ? $size : 300; - - $embed = << - -
    - -EOT; - - - $result = array(); - $result[self::EMBED_SNIPPET] = $embed; - $result[self::TITLE] = $title; - $result[self::DESCRIPTION] = $description; - $result[self::TAGS] = $keywords; - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/protocol/asset_google_document_viewer_renderer.class.php b/main/inc/lib/system/media/renderer/protocol/asset_google_document_viewer_renderer.class.php deleted file mode 100755 index fc9197a92a..0000000000 --- a/main/inc/lib/system/media/renderer/protocol/asset_google_document_viewer_renderer.class.php +++ /dev/null @@ -1,95 +0,0 @@ -has_ext($supported_extentions); - } - - protected function url($document_url) - { - return 'https://docs.google.com/viewer?embedded=true&url=' . urlencode($document_url); - } - - /** - * - * @param HttpResource $asset - */ - public function render($asset) - { - if (!$this->accept($asset)) - { - return; - } - - $url = $this->url($asset->url()); - - $title = $asset->title(); - $description = $asset->get_meta('description'); - - $keywords = $asset->get_meta('keywords'); - - $size = (int) $asset->config('size'); - $size = (24 <= $size && $size <= 800) ? $size : 300; - - $embed = << - - - -EOT; - - - $result = array(); - $result[self::EMBED_SNIPPET] = $embed; - $result[self::TITLE] = $title; - //$result[self::THUMBNAIL] = $image_src; - $result[self::DESCRIPTION] = $description; - $result[self::TAGS] = $keywords; - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/protocol/asset_google_map_renderer.class.php b/main/inc/lib/system/media/renderer/protocol/asset_google_map_renderer.class.php deleted file mode 100755 index c49eee8dd4..0000000000 --- a/main/inc/lib/system/media/renderer/protocol/asset_google_map_renderer.class.php +++ /dev/null @@ -1,129 +0,0 @@ -url(); - $url = str_replace('http://', '', $url); - $url = str_replace('https://', '', $url); - - $domain = reset(explode('/', $url)); - return strpos($domain, 'maps.google') !== false; - } - - /** - * - * @param string $url - */ - public function explode_url_parameters($url = null) - { - if (strpos($url, '?') === false) - { - return array(); - } - - $result = array(); - $params = explode('?', $url); - $params = end($params); - $params = explode('&', $params); - foreach ($params as $param) - { - list($key, $val) = explode('=', $param); - $result[$key] = $val; - } - - return $result; - } - - public function implode_url_parameters($params) - { - $result = array(); - foreach ($params as $key => $value) - { - if ($value) - { - $result[] = "$key=$value"; - } - } - return join('&', $result); - } - - protected function url($base = 'http:://map.google.com/', $params = array()) - { - $head = reset(explode('?', $base)); - $items = $this->explode_url_parameters($base); - foreach ($params as $key => $value) - { - $items[$key] = $value; - } - $tail = $this->implode_url_parameters($items); - $tail = empty($tail) ? '' : "?$tail"; - return $head . $tail; - } - - /** - * - * @param HttpResource $asset - */ - public function render($asset) - { - if (!$this->accept($asset)) - { - return; - } - - $params = array('output' => 'embed'); - - $base = $asset->url(); - $url = $this->url($base, $params); - - $title = $asset->title(); - $description = $asset->get_meta('description'); - - $keywords = $asset->get_meta('keywords'); - - $size = (int) $asset->config('size'); - $size = (24 <= $size && $size <= 800) ? $size : 300; - - $embed = << - - - -EOT; - - - $result = array(); - $result[self::EMBED_SNIPPET] = $embed; - $result[self::TITLE] = $title; - $result[self::DESCRIPTION] = $description; - $result[self::TAGS] = $keywords; - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/protocol/asset_google_widget_renderer.class.php b/main/inc/lib/system/media/renderer/protocol/asset_google_widget_renderer.class.php deleted file mode 100755 index b98a46149c..0000000000 --- a/main/inc/lib/system/media/renderer/protocol/asset_google_widget_renderer.class.php +++ /dev/null @@ -1,90 +0,0 @@ -url_match('gmodules.com/ig/') && $asset->url_param('url') != false) - { - $url = $asset->url(); - $title = $asset->url_param('title'); - $title = ($title == '__MSG_title__') ? '' : $title; - - $embed = << -EOT; - - $result = array(); - $result[self::EMBED_SNIPPET] = $embed; - $result[self::TITLE] = $title; - return $result; - } - - if (!$asset->is_gadget()) - { - $url = $asset->url(); - - if (!$asset->url_match('google.com/ig/directory')) - { - return false; - } - if (!$asset->url_match('type=gadgets')) - { - return false; - } - - $url = $asset->url_param('url'); - if (empty($url)) - { - return false; - } - $asset = new HttpResource($url); - if (!$asset->is_gadget()) - { - return false; - } - } - - $url = $asset->url(); - if (strpos($url, 'http') !== 0) - { - $url = "http://$url"; - } - $url = urlencode($url); - $title = $asset->title(); - $title = $title ? $title : $asset->name(); - - $size = (int) $asset->config('size'); - $size = (24 <= $size && $size <= 800) ? $size : 300; - - $embed = << -EOT; - - $result = array(); - $result[self::EMBED_SNIPPET] = $embed; - $result[self::TITLE] = $title; - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/protocol/asset_image_renderer.class.php b/main/inc/lib/system/media/renderer/protocol/asset_image_renderer.class.php deleted file mode 100755 index 9b8df5b364..0000000000 --- a/main/inc/lib/system/media/renderer/protocol/asset_image_renderer.class.php +++ /dev/null @@ -1,44 +0,0 @@ -is_image()) - { - return false; - } - - global $THEME; - $url = $asset->url(); - $title = $asset->title(); - $title = $title ? $title : $asset->name(); - - $size = (int) $asset->config('size'); - $size = (24 <= $size && $size <= 800) ? $size : 300; - - $embed = <<{$title} -EOT; - - $result = array(); - $result[self::URL] = $url; - $result[self::EMBED_SNIPPET] = $embed; - $result[self::TITLE] = $title; - $result[self::THUMBNAIL] = $url; - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/protocol/asset_media_renderer.class.php b/main/inc/lib/system/media/renderer/protocol/asset_media_renderer.class.php deleted file mode 100755 index 5572296b32..0000000000 --- a/main/inc/lib/system/media/renderer/protocol/asset_media_renderer.class.php +++ /dev/null @@ -1,65 +0,0 @@ -is_video()) - { - return true; - } - - //swf mime type is application/x-shockwave-flash - return $asset->has_ext('swf'); - } - - /** - * - * @param HttpResource $asset - */ - public function render($asset) - { - if (!$this->accept($asset)) - { - return; - } - - $url = $asset->url(); - - $title = $asset->title(); - $description = $asset->get_meta('description'); - $keywords = $asset->get_meta('keywords'); - - - $size = (int) $asset->config('size'); - $size = (24 <= $size && $size <= 800) ? $size : 300; - - $width = $size; - $height = $size *9/16; - - $embed = << -EOT; - - - $result = array(); - $result[self::EMBED_SNIPPET] = $embed; - $result[self::TITLE] = $title; - $result[self::DESCRIPTION] = $description; - $result[self::TAGS] = $keywords; - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/protocol/asset_mediaserver_renderer.class.php b/main/inc/lib/system/media/renderer/protocol/asset_mediaserver_renderer.class.php deleted file mode 100755 index f83d9a5831..0000000000 --- a/main/inc/lib/system/media/renderer/protocol/asset_mediaserver_renderer.class.php +++ /dev/null @@ -1,65 +0,0 @@ -url_match('https://mediaserver.unige.ch/play/') ||$asset->url_match('http://mediaserver.unige.ch/play/'); - } - - /** - * - * @param HttpResource $asset - */ - public function render($asset) - { - if (!$this->accept($asset)) - { - return; - } - - $width = (int) $asset->config('size'); - $width = (24 <= $width && $width <= 800) ? $width : 300; - - $url = $asset->url(); - - $oembed = self::API_ENDPOINT . '?url=' . urlencode($url) . '&maxwidth=' . $width; - - $data = HttpResource::fetch_json($oembed); - if (empty($data)) - { - return false; - } - - $result[self::THUMBNAIL] = isset($data['thumbnail_url']) ? $data['thumbnail_url'] : ''; - $result[self::TITLE] = isset($data['title']) ? $data['title'] : ''; - $result[self::EMBED_SNIPPET] = isset($data['html']) ? $data['html'] : ''; - - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/protocol/asset_oembed_renderer.class.php b/main/inc/lib/system/media/renderer/protocol/asset_oembed_renderer.class.php deleted file mode 100755 index 1eef014baa..0000000000 --- a/main/inc/lib/system/media/renderer/protocol/asset_oembed_renderer.class.php +++ /dev/null @@ -1,124 +0,0 @@ -get_link('type', 'application/json+oembed'); - if (empty($link)) - { - return false; - } - - $width = (int) $asset->config('size'); - $width = (24 <= $width && $width <= 800) ? $width : 300; - - $href = $link['href']; - $data = HttpResource::fetch_json("$href&maxwidth=$width"); //&maxheight=$height - if (empty($data)) - { - return false; - } - - $data['title'] = isset($data['title']) ? $data['title'] : ''; - $data['width'] = isset($data['width']) ? intval($data['width']) : ''; - $data['height'] = isset($data['height']) ? intval($data['height']) : ''; - - $type = $data['type']; - $f = array($this, "render_$type"); - if (is_callable($f)) - { - $result = call_user_func($f, $asset, $data); - } - else - { - $result = array(); - } - $result[self::THUMBNAIL] = isset($data['thumbnail_url']) ? $data['thumbnail_url'] : ''; - $result[self::TITLE] = isset($data['title']) ? $data['title'] : ''; - - return $result; - } - - protected function render_photo($asset, $data) - { - if ($data['type'] != 'photo') - { - return array(); - } - - $result = array(); - $html = isset($data['html']) ? $data['html'] : ''; - if ($html) - { - $result[self::EMBED_SNIPPET] = '
    ' . $html . '
    '; - return $result; - } - - $title = $data['title']; - $width = (int)$data['width']; - $height = (int)$data['height']; -// $ratio = $height / $width; -// $height = $ratio * $width; - - $url = $data['url']; - - $embed = << -EOT; - - $result[self::EMBED_SNIPPET] = $embed; - return $result; - } - - protected function render_video($asset, $data) - { - if ($data['type'] != 'video') - { - return array(); - } - $result = array(); - $result[self::EMBED_SNIPPET] = '
    ' . $data['html'] . '
    '; - return $result; - } - - protected function render_rich($asset, $data) - { - if ($data['type'] != 'rich') - { - return array(); - } - - $result = array(); - $result[self::EMBED_SNIPPET] = '
    ' . $data['html'] . '
    '; - return $result; - } - - protected function render_link($asset, $data) - { - if ($data['type'] != 'link') - { - return array(); - } - return array(); - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/protocol/asset_og_renderer.class.php b/main/inc/lib/system/media/renderer/protocol/asset_og_renderer.class.php deleted file mode 100755 index 9eb56ce1bf..0000000000 --- a/main/inc/lib/system/media/renderer/protocol/asset_og_renderer.class.php +++ /dev/null @@ -1,201 +0,0 @@ -get_meta('og:type'); - if (empty($type)) - { - if ($video = $asset->get_meta('og:video')) - { - $type = 'video'; - } - else if ($video = $asset->get_meta('og:image')) - { - $type = 'default'; - } - } - if (empty($type)) - { - return array(); - } - - $type = explode('.', $type); - $type = reset($type); - $f = array($this, "render_$type"); - if (is_callable($f)) - { - $result = call_user_func($f, $asset); - } - else - { - $result = $this->render_default($asset); - } - - $result[self::TITLE] = $asset->get_meta('og:title'); - $result[self::THUMBNAIL] = $asset->get_meta('og:image'); - $result[self::LANGUAGE] = $asset->get_meta('og:language'); - - return $result; - } - - /** - * @param HttpResource $asset - * @return array - */ - protected function render_video($asset) - { - $url = $asset->get_meta('og:video'); - $url = str_replace('?autoPlay=1', '?', $url); - $url = str_replace('&autoPlay=1', '', $url); - - if (empty($url)) - { - return array(); - } - - $type = $asset->get_meta('og:video:type'); - if ($type) - { - $type = ' type="' . $type . '" '; - } - - $size = (int) $asset->config('size'); - $size = (24 <= $size && $size <= 800) ? $size : 300; - - $width = $asset->get_meta('og:video:width'); - $width = $width ? $width : $asset->get_meta('video_width'); - $height = $asset->get_meta('og:video:height'); - $height = $height ? $height : $asset->get_meta('video_height'); - - if ($width) - { - $ratio = $height / $width; - $base = min($size, $width); - $width = $base; - $height = $ratio * $base; - $size = 'width="' . $width . '" height="' . $height . '"'; - } - else - { - $size = 'width="' . $size . '"'; - } - - $embed = << -EOT; - - $result[self::EMBED_TYPE] = $type; - $result[self::EMBED_URL] = $url; - $result[self::EMBED_SNIPPET] = $embed; - $result[self::TAGS] = $asset->get_meta('og:video:tag'); - $result[self::CREATED_TIME] = $asset->get_meta('og:video:release_date'); - $result[self::DURATION] = $asset->get_meta('og:duration'); - return $result; - } - - protected function render_article($asset) - { - $result = $this->render_default($asset); - return $result; - } - - protected function render_audio($asset) - { - $result = $this->render_default($asset); - return $result; - } - - protected function render_book($asset) - { - $result = $this->render_default($asset); - return $result; - } - - /** - * - * @param HttpResource $asset - * @return array - */ - protected function render_default($asset) - { - $url = $asset->get_meta('og:url'); - $url = htmlentities($url); - $title = $asset->get_meta('og:title'); - $image = $asset->get_meta('og:image'); - $image = htmlentities($image); - $width = $asset->get_meta('og:image:width'); - $height = $asset->get_meta('og:image:height'); - $description = $asset->get_meta('og:description'); - $description = $description ? $description : $asset->get_meta('description'); - - $size = (int) $asset->config('size'); - $size = (24 <= $size && $size <= 800) ? $size : 300; - - if ($width) - { - $ratio = $height / $width; - $base = min($size, $width); - $width = $base; - $height = $ratio * $base; - $size = 'width="' . $width . '" height="' . $height . '"'; - } - else - { - $size = 'width="' . $size . '"'; - } - $embed = << - {$title} -
    - -EOT; - - $result[self::EMBED_SNIPPET] = $embed; - $result[self::DESCRIPTION] = $asset->get_meta('description'); - return $result; - } - - /** - * @param HttpResource $asset - * @return array - */ - protected function render_image($asset) - { - $size = (int) $asset->config('size'); - $size = (24 <= $size && $size <= 800) ? $size : 300; - - $title = $data['title']; - $width = $data['width']; - $height = $data['height']; - $ratio = $height / $width; - $base = min($size, $width); - $width = $base; - $height = $ratio * $base; - - $url = $data['url']; - - $embed = <<{$title} -EOT; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/protocol/asset_page_renderer.class.php b/main/inc/lib/system/media/renderer/protocol/asset_page_renderer.class.php deleted file mode 100755 index d37608d1e9..0000000000 --- a/main/inc/lib/system/media/renderer/protocol/asset_page_renderer.class.php +++ /dev/null @@ -1,83 +0,0 @@ -url(); - $title = $asset->title(); - $title = $title ? $title : $asset->name(); - $description = $asset->get_meta('description'); - $description = $description; - - $keywords = $asset->get_meta('keywords'); - - $image_src = $asset->get_link('rel', 'image_src'); - $image_src = $image_src ? $image_src['href'] : false; - - if (empty($image_src)) - { - $image_src = $this->get_icon($asset); - } - - $icon = $this->get_icon($asset); - - $image_src = $asset->canonic_url($image_src); - $icon = $asset->canonic_url($icon); - - $embed = << - {$title} - - $description - -EOT; - - - $result = array(); - $result[self::EMBED_SNIPPET] = $embed; - $result[self::TITLE] = $title; - $result[self::THUMBNAIL] = $image_src; - $result[self::DESCRIPTION] = $description; - $result[self::ICON] = $icon; - $result[self::TAGS] = $keywords; - return $result; - } - - function get_icon($asset) - { - - $icon = $asset->get_link('rel', 'apple-touch-icon'); - $icon = $icon ? $icon['href'] : false; - if (empty($icon)) - { - $icon = $asset->get_link('rel', 'fluid-icon'); - $icon = $icon ? $icon['href'] : false; - } - if (empty($icon)) - { - $icon = $asset->get_link('rel', 'shortcut icon'); - $icon = $icon ? $icon['href'] : false; - } - if (empty($icon)) - { - $icon = $asset->get_link('rel', 'icon'); - $icon = $icon ? $icon['href'] : false; - } - return $icon; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/protocol/asset_rss_renderer.class.php b/main/inc/lib/system/media/renderer/protocol/asset_rss_renderer.class.php deleted file mode 100755 index 589466965f..0000000000 --- a/main/inc/lib/system/media/renderer/protocol/asset_rss_renderer.class.php +++ /dev/null @@ -1,95 +0,0 @@ -is_rss()) - { - return; - } - - $url = $asset->url(); - $title = $asset->title(); - $id = 'a' . md5($url); - - $embed = << - .gfg-root { - border: none; - font-family: inherit; - } - - - - -
    Loading...
    -EOT; - - - $result = array(); - $result[self::EMBED_SNIPPET] = $embed; - $result[self::TITLE] = $title; - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/media/renderer/protocol/asset_scratch_renderer.class.php b/main/inc/lib/system/media/renderer/protocol/asset_scratch_renderer.class.php deleted file mode 100755 index 189c088b5b..0000000000 --- a/main/inc/lib/system/media/renderer/protocol/asset_scratch_renderer.class.php +++ /dev/null @@ -1,76 +0,0 @@ -url_match('http://scratch.mit.edu/projects/'); - } - - /** - * - * @param HttpResource $asset - */ - public function render($asset) - { - if (!$this->accept($asset)) - { - return; - } - - $matches = array(); - $pattern = "#http:\/\/scratch.mit.edu\/projects\/(\w+)/(\d*)\/?#ims"; - preg_match($pattern, $asset->url(), $matches); - - $url = $matches[0]; - $author = $matches[1]; - $project_id = $matches[2]; - - $project_url = "../../static/projects/$author/$project_id.sb"; - $image_url = "http://scratch.mit.edu/static/projects/$author/{$project_id}_med.png"; - $thumb_url = "http://scratch.mit.edu/static/projects/$author/{$project_id}_sm.png"; - - $height = 387; - $width = 482; - - if (function_exists('get_string')) - { - $no_java = get_string('no_java', 'artefact.extresource'); - } - else - { - $no_java = 'Java is not installed on your computer. You must install java first.'; - } - - $embed = << - - - - - -
    $no_java
    - - -EOT; - $result = array(); - $result[self::EMBED_SNIPPET] = $embed; - $result[self::THUMBNAIL] = $thumb_url; - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/net/curl.class.php b/main/inc/lib/system/net/curl.class.php deleted file mode 100755 index aceafc0646..0000000000 --- a/main/inc/lib/system/net/curl.class.php +++ /dev/null @@ -1,131 +0,0 @@ - - */ -class Curl -{ - - protected static $default_options = array(); - - static function get_default_options($options = array()) - { - if (empty(self::$default_options)) { - self::$default_options[CURLOPT_HEADER] = false; - self::$default_options[CURLOPT_RETURNTRANSFER] = true; - self::$default_options[CURLOPT_SSL_VERIFYPEER] = false; - } - - $result = self::$default_options; - foreach ($options as $key => $value) { - $result[$key] = $value; - } - return $result; - } - - static function set_default_option($key, $value) - { - $options = $this->get_options(array($key => $value)); - self::$default_options = $options; - } - - /** - * - * @param string $url - * @param array $options - * @return Curl - */ - static function get($url, $options = array()) - { - $options[CURLOPT_HTTPGET] = true; - $result = new self($url, $options); - return $result; - } - - /** - * - * @param string $url - * @param array $fields - * @param array $options - * @return Curl - */ - static function post($url, $fields, $options = array()) - { - $options[CURLOPT_POST] = true; - $options[CURLOPT_POSTFIELDS] = $fields; - $result = new self($url, $options); - return $result; - } - - protected $url = ''; - protected $options = array(); - protected $content = ''; - protected $info = array(); - protected $error = ''; - protected $error_no = 0; - - function __construct($url, $options = array()) - { - $this->url = $url; - $this->options = self::get_default_options($options); - } - - function url() - { - return $this->url; - } - - function options() - { - return $this->options; - } - - function execute() - { - $ch = curl_init(); - - $options = $this->options; - $options[CURLOPT_URL] = $this->url; - curl_setopt_array($ch, $options); - - $this->content = curl_exec($ch); - $this->error = curl_error($ch); - $this->info = curl_getinfo($ch); - $this->error_no = curl_errno($ch); - - curl_close($ch); - - return $this->content; - } - - function content() - { - return $this->content; - } - - /** - * @return array|string - */ - function info($key = false) - { - if ($key) { - return isset($this->info[$key]) ? $this->info[$key] : false; - } else { - return $this->info; - } - } - - function error() - { - return $this->error; - } - - function error_no() - { - return $this->error_no; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/net/http_channel.class.php b/main/inc/lib/system/net/http_channel.class.php deleted file mode 100755 index becb08008e..0000000000 --- a/main/inc/lib/system/net/http_channel.class.php +++ /dev/null @@ -1,72 +0,0 @@ - - */ -class HttpChannel -{ - - /** - * - * @param string $url - * @param type $modules - * @return HttpChannel - */ - static function create($url, $modules = array()) - { - return new self($url, $modules); - } - - protected $base_url = ''; - protected $modules = array(); - - public function __construct($base_url = '', $modules = array()) - { - $this->base_url = $base_url; - $this->modules = $modules; - } - - function modules() - { - return $this->modules; - } - - function get($url, $parameters) - { - $options = $this->get_options(); - $url = $this->base_url . $url; - return Curl::get($url, $options)->execute(); - } - - function post($url, $fields) - { - $options = $this->get_options(); - $url = $this->base_url . $url; - return Curl::post($url, $fields, $options)->execute(); - } - - protected function get_options() - { - $result = array(); - $modules = $this->modules(); - foreach ($modules as $module) { - if (is_array($module)) { - $options = $module; - } else { - - $options = $module->get_options(); - } - $result = array_merge($result, $options); - } - return $result; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/portfolio/artefact.class.php b/main/inc/lib/system/portfolio/artefact.class.php deleted file mode 100755 index 1a69f33a04..0000000000 --- a/main/inc/lib/system/portfolio/artefact.class.php +++ /dev/null @@ -1,149 +0,0 @@ -set_path('...'); - * - * or - * - * - * $artefact = new artefact(); - * $artefact->set_url('...'); - * - * @copyright (c) 2012 University of Geneva - * @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html - * @author Laurent Opprecht - */ -class Artefact -{ - - protected $id = ''; - protected $mime_type = ''; - protected $name = ''; - protected $description = ''; - protected $path = ''; - protected $url = ''; - protected $creation_date = ''; - protected $modification_date = ''; - protected $metadata = null; - - /** - * - * @param string $file Either url or file path - */ - public function __construct($file = '') - { - if ($file) { - if (strpos($file, 'http') !== false) { - $this->url = $file; - } else { - $this->path = $file; - } - } - $this->id = uniqid('', true); - $this->mime_type = ''; - $time = time(); - $this->creation_date = $time; - $this->modification_date = $time; - } - - public function get_id() - { - return $this->id; - } - - public function set_id($value) - { - $this->id = $value; - } - - public function get_name() - { - return $this->name; - } - - public function set_name($value) - { - $this->name = $value; - } - - public function get_mime_type() - { - return $this->mime_type; - } - - public function set_mime_type($value) - { - $this->mime_type = $value; - } - - public function get_description() - { - return $this->description; - } - - public function set_description($value) - { - $this->description = $value; - } - - public function get_path() - { - return $this->path; - } - - public function set_path($value) - { - $this->path = $value; - } - - public function get_url() - { - return $this->url; - } - - public function set_url($value) - { - $this->url = $value; - } - - public function get_creation_date() - { - return $this->creation_date; - } - - public function set_creation_date($value) - { - $this->creation_date = $value; - } - - public function get_modification_date() - { - return $this->modification_date; - } - - public function set_modification_date($value) - { - $this->modification_date = $value; - } - - public function get_metadata() - { - return $this->metadata; - } - - public function set_metadata($value) - { - $this->metadata = $value; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/portfolio/download.class.php b/main/inc/lib/system/portfolio/download.class.php deleted file mode 100755 index 7bfe5436ac..0000000000 --- a/main/inc/lib/system/portfolio/download.class.php +++ /dev/null @@ -1,35 +0,0 @@ - - */ -class Download extends Portfolio -{ - - function __construct() - { - parent::__construct('download', null); - } - - /** - * - * @param User $user - * @param Artefact $artefact - * @return bool - */ - function send($user, $artefact) - { - if ($artefact->get_url()) { - Header::location($artefact->get_url()); - } - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/portfolio/mahara.class.php b/main/inc/lib/system/portfolio/mahara.class.php deleted file mode 100755 index f8b526d7f0..0000000000 --- a/main/inc/lib/system/portfolio/mahara.class.php +++ /dev/null @@ -1,59 +0,0 @@ - - */ -class Mahara extends Portfolio -{ - - protected $url = ''; - - /** - * - * @param string $url The root url - */ - function __construct($url) - { - $name = md5($url); - parent::__construct($name, null); - $this->url = $url; - } - - function get_url() - { - return $this->url; - } - - function get_title(){ - $result = parent::get_title(); - $result = $result ? $result : 'Mahara'; - return $result; - } - - /** - * - * @param User $user - * @param Artefact $artefact - * @return bool - */ - function send($user, $artefact) - { - $root = $this->get_url(); - rtrim($root, '/'); - $url = $artefact->get_url(); - $url = $root . '/artefact/connect/upload.php?url=' . urlencode($url) . '&extract=true'; - Header::location($url); - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/portfolio/portfolio.class.php b/main/inc/lib/system/portfolio/portfolio.class.php deleted file mode 100755 index b1fc225527..0000000000 --- a/main/inc/lib/system/portfolio/portfolio.class.php +++ /dev/null @@ -1,106 +0,0 @@ - - */ -class Portfolio -{ - - public static function none() - { - static $result = null; - if (empty($result)) { - $result = new self('empty', null); - } - return $result; - } - - public static function all() - { - - } - - protected $name; - protected $title = ''; - protected $description = ''; - protected $channel; - - function __construct($name, $channel = null) - { - $this->name = $name; - $this->title = $name; - $this->channel = $channel; - } - - /** - * The name of the portfolio - i.e. the unique id. - * @return type - */ - function get_name() - { - return $this->name; - } - - /** - * Title for the end user. - * - * @return type - */ - function get_title() - { - return $this->title; - } - - function set_title($value) - { - $this->title = $value; - } - - /** - * Description for the end user. - * - * @return type - */ - function get_description() - { - return $this->description; - } - - function set_description($value) - { - $this->description = $value; - } - - /** - * - * @return HttpChannel - */ - function channel() - { - return $this->channel; - } - - function __toString() - { - return $this->name; - } - - /** - * - * @param User $user - * @param Artefact $artefact - * @return bool - */ - function send($user, $artefact) - { - return false; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/portfolio/user.class.php b/main/inc/lib/system/portfolio/user.class.php deleted file mode 100755 index 52ddbacf9b..0000000000 --- a/main/inc/lib/system/portfolio/user.class.php +++ /dev/null @@ -1,19 +0,0 @@ - - */ -class User -{ - public $id; - public $email; - public $token; - -} \ No newline at end of file diff --git a/main/inc/lib/system/text/converter.class.php b/main/inc/lib/system/text/converter.class.php deleted file mode 100755 index 3579d3f700..0000000000 --- a/main/inc/lib/system/text/converter.class.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -class Converter -{ - - /** - * Identity converter. Returns the string with no transformations. - * - * @return Converter - */ - public static function identity() - { - static $result = null; - if(empty($result)) - { - $result = new self(); - } - return $result; - } - - - function convert($string) - { - return $string; - } -} \ No newline at end of file diff --git a/main/inc/lib/system/text/encoding.class.php b/main/inc/lib/system/text/encoding.class.php deleted file mode 100755 index f72c0eb6b5..0000000000 --- a/main/inc/lib/system/text/encoding.class.php +++ /dev/null @@ -1,158 +0,0 @@ -decoder(); - * $decoder->convert('text'); - * - * The system encoding is the platform/system/default encoding. This defaults to - * UTF8 but can be changed: - * - * Encoding::system('name'); - * - * Note that Encoding returns to its name when converted to a string. As such it - * can be used in places where a string is expected: - * - * $utf8 = Encoding::Utf8(); - * echo $utf8; - * - * @copyright (c) 2012 University of Geneva - * @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html - * @author Laurent Opprecht - */ -class Encoding -{ - - private static $system = null; - - /** - * Returns encoding for $name. - * - * @param string $name - * @return Encoding - */ - public static function get($name) - { - if (is_object($name)) { - return $name; - } else if (Encoding::utf8()->is($name)) { - return self::utf8(); - } else { - return new self($name); - } - } - - /** - * Returns the Utf8 encoding. - * - * @return Utf8 - */ - public static function utf8() - { - return Utf8::instance(); - } - - /** - * Returns/set the system/default encoding. - * - * @return Encoding - */ - public static function system($value = null) - { - if (is_object($value)) { - self::$system = $value; - } else if (is_string($value)) { - self::$system = self::get($value); - } - - return self::$system ? self::$system : self::utf8(); - } - - /** - * Detect encoding from an abstract. - * - * @param string $abstract - * @return Encoding - */ - public static function detect_encoding($abstract) - { - $encoding_name = api_detect_encoding($abstract); - return self::get($encoding_name); - } - - protected $name = ''; - - protected function __construct($name = '') - { - $this->name = $name; - } - - /** - * The name of the encoding - * - * @return string - */ - function name() - { - return $this->name; - } - - /** - * The Byte Order Mark. - * - * @see http://en.wikipedia.org/wiki/Byte_order_mark - * @return string - */ - function bom() - { - return ''; - } - - /** - * Returns a decoder that convert encoding to another encoding. - * - * @param string|Encoder $to Encoding to convert to, defaults to system encoding - * @return Converter - */ - public function decoder($to = null) - { - $from = $this; - $to = $to ? $to : Encoding::system(); - return EncodingConverter::create($from, $to); - } - - /** - * Returns an encoder that convert from another encoding to this encoding. - * - * @param string|Encoder $from Encoding to convert from, defaults to system encoding. - * @return Converter - */ - public function encoder($from = null) - { - $from = $from ? $from : Encoding::system(); - $to = $this; - return EncodingConverter::create($from, $to); - } - - function __toString() - { - return $this->name(); - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/text/encoding_converter.class.php b/main/inc/lib/system/text/encoding_converter.class.php deleted file mode 100755 index 460a056e8e..0000000000 --- a/main/inc/lib/system/text/encoding_converter.class.php +++ /dev/null @@ -1,71 +0,0 @@ -convert($text); - * - * Note that the create function will returns an identify converter if from and to - * encodings are the same. Reason why the constructor is private. - * - * @copyright (c) 2012 University of Geneva - * @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html - * @author Laurent Opprecht - */ -class EncodingConverter extends Converter -{ - - /** - * - * @param string $from_encoding - * @param string $to_encoding - * - * @return EncodingConverter - */ - public static function create($from_encoding, $to_encoding) - { - $from_encoding = (string) $from_encoding; - $to_encoding = (string) $to_encoding; - if (strtolower($from_encoding) == strtolower($to_encoding)) { - return Converter::identity(); - } else { - return new self($from_encoding, $to_encoding); - } - } - - protected $from_encoding; - protected $to_encoding; - - protected function __construct($from_encoding, $to_encoding) - { - $this->from_encoding = $from_encoding; - $this->to_encoding = $to_encoding; - } - - function from_encoding() - { - return $this->from_encoding; - } - - function to_encoding() - { - return $this->to_encoding; - } - - function convert($string) - { - $from = $this->from_encoding; - $to = $this->to_encoding; - if ($from == $to) { - return $string; - } - return api_convert_encoding($string, $to, $from); - } - - function reset() - { - ; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/text/utf8.class.php b/main/inc/lib/system/text/utf8.class.php deleted file mode 100755 index 8a7c1ee950..0000000000 --- a/main/inc/lib/system/text/utf8.class.php +++ /dev/null @@ -1,287 +0,0 @@ - for the Univesity of Geneva - * @author More authors, mentioned in the correpsonding fragments of this source. - */ -class Utf8 extends Encoding -{ - - const PATTERN_NOT_VISIBLE_CHARS = '/[^[:print:]-]/'; //Visible characters and the space character - - /** - * @see http://en.wikipedia.org/wiki/Byte_order_mark - */ - const BOM = "\xEF\xBB\xBF"; - const NAME = 'UTF-8'; - - /** - * - * @return Utf8 - */ - public static function instance() - { - static $result = null; - if (empty($result)) { - $result = new self(); - } - return $result; - } - - /** - * Returns true if encoding is UTF8. - * - * @param string|Encoding $encoding - * @return bool - */ - function is($encoding) - { - $encoding = (string) $encoding; - return strtolower($encoding) == strtolower(self::NAME); - } - - protected function __construct() - { - parent::__construct(self::NAME); - } - - function name() - { - return self::NAME; - } - - function bom() - { - return self::BOM; - } - - /** - * Returns the hexa decimal representation of an utf8 string. Usefull to understand - * what is going on - not printable chars, rare patterns such as e' for é, etc. - * - * @param type $text - * @return string - */ - function to_hex($text) - { - $result = ''; - mb_internal_encoding('utf-8'); - - for ($i = 0, $n = mb_strlen($text); $i < $n; $i++) { - $char = mb_substr($text, $i, 1); - $num = strlen($char); - for ($j = 0; $j < $num; $j++) { - $result .= sprintf('%02x', ord($char[$j])); - } - $result .= ' '; - } - return $result; - } - - /** - * Trim the BOM from an utf-8 string - * - * @param string $text - * @return string - */ - function trim($text) - { - $bom = self::BOM; - if (strlen($text) < strlen($bom)) { - return $text; - } - - if (substr($text, 0, 3) == $bom) { - return substr($text, 3); - } - return $text; - } - - /** - * Checks a string for UTF-8 validity. - * - * @param string $string The string to be tested. - * @return bool Returns TRUE when the tested string is valid UTF-8, FALSE othewise. - * @link http://en.wikipedia.org/wiki/UTF-8 - * @author see internationalization.lib.php - */ - static function is_valid(&$string) - { - - //return @mb_detect_encoding($string, 'UTF-8', true) == 'UTF-8' ? true : false; - // Ivan Tcholakov, 05-OCT-2008: I do not trust mb_detect_encoding(). I have - // found a string with a single cyrillic letter (single byte), that is - // wrongly detected as UTF-8. Possibly, there would be problems with other - // languages too. An alternative implementation will be used. - - $str = (string) $string; - $len = api_byte_count($str); - $i = 0; - while ($i < $len) { - $byte1 = ord($str[$i++]); // Here the current character begins. Its size is - // determined by the senior bits in the first byte. - - if (($byte1 & 0x80) == 0x00) { // 0xxxxxxx - // & - // 10000000 - // -------- - // 00000000 - // This is s valid character and it contains a single byte. - } elseif (($byte1 & 0xE0) == 0xC0) { // 110xxxxx 10xxxxxx - // & & - // 11100000 11000000 - // -------- -------- - // 11000000 10000000 - // The character contains two bytes. - if ($i == $len) { - return false; // Here the string ends unexpectedly. - } - - if (!((ord($str[$i++]) & 0xC0) == 0x80)) - return false; // Invalid second byte, invalid string. - } - - elseif (($byte1 & 0xF0) == 0xE0) { // 1110xxxx 10xxxxxx 10xxxxxx - // & & & - // 11110000 11000000 11000000 - // -------- -------- -------- - // 11100000 10000000 10000000 - // This is a character of three bytes. - if ($i == $len) { - return false; // Unexpected end of the string. - } - if (!((ord($str[$i++]) & 0xC0) == 0x80)) { - return false; // Invalid second byte. - } - if ($i == $len) { - return false; // Unexpected end of the string. - } - if (!((ord($str[$i++]) & 0xC0) == 0x80)) { - return false; // Invalid third byte, invalid string. - } - } elseif (($byte1 & 0xF8) == 0xF0) { // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - // & & & & - // 11111000 11000000 11000000 11000000 - // -------- -------- -------- -------- - // 11110000 10000000 10000000 10000000 - // This is a character of four bytes. - if ($i == $len) { - return false; - } - if (!((ord($str[$i++]) & 0xC0) == 0x80)) { - return false; - } - if ($i == $len) { - return false; - } - if (!((ord($str[$i++]) & 0xC0) == 0x80)) { - return false; - } - if ($i == $len) { - return false; - } - if (!((ord($str[$i++]) & 0xC0) == 0x80)) { - return false; - } - } elseif (($byte1 & 0xFC) == 0xF8) { // 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx - // & & & & & - // 11111100 11000000 11000000 11000000 11000000 - // -------- -------- -------- -------- -------- - // 11111000 10000000 10000000 10000000 10000000 - // This is a character of five bytes. - if ($i == $len) { - return false; - } - if (!((ord($str[$i++]) & 0xC0) == 0x80)) { - return false; - } - if ($i == $len) { - return false; - } - if (!((ord($str[$i++]) & 0xC0) == 0x80)) { - return false; - } - if ($i == $len) { - return false; - } - if (!((ord($str[$i++]) & 0xC0) == 0x80)) { - return false; - } - if ($i == $len) { - return false; - } - if (!((ord($str[$i++]) & 0xC0) == 0x80)) { - return false; - } - } elseif (($byte1 & 0xFE) == 0xFC) { // 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx - // & & & & & & - // 11111110 11000000 11000000 11000000 11000000 11000000 - // -------- -------- -------- -------- -------- -------- - // 11111100 10000000 10000000 10000000 10000000 10000000 - // This is a character of six bytes. - if ($i == $len) { - return false; - } - if (!((ord($str[$i++]) & 0xC0) == 0x80)) { - return false; - } - if ($i == $len) { - return false; - } - if (!((ord($str[$i++]) & 0xC0) == 0x80)) { - return false; - } - if ($i == $len) { - return false; - } - if (!((ord($str[$i++]) & 0xC0) == 0x80)) { - return false; - } - if ($i == $len) { - return false; - } - if (!((ord($str[$i++]) & 0xC0) == 0x80)) { - return false; - } - if ($i == $len) { - return false; - } - if (!((ord($str[$i++]) & 0xC0) == 0x80)) { - return false; - } - } else { - return false; // In any other case the character is invalid. - } - // Here the current character is valid, it - // matches to some of the cases above. - // The next character is to be examinated. - } - return true; // Empty strings are valid too. - } - - /** - * - * @param type $to - * @return Utf8Decoder - */ - public function decoder($to = null) - { - $to = $to ? $to : Encoding::system(); - return new Utf8Decoder($to); - } - - /** - * - * @param type $from - * @return Utf8Encoder - */ - public function encoder($from = null) - { - $from = $from ? $from : Encoding::system(); - return new Utf8Encoder($from); - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/text/utf8_decoder.class.php b/main/inc/lib/system/text/utf8_decoder.class.php deleted file mode 100755 index 04d5cd7857..0000000000 --- a/main/inc/lib/system/text/utf8_decoder.class.php +++ /dev/null @@ -1,54 +0,0 @@ - - */ -class Utf8Decoder extends Converter -{ - - protected $started = false; - protected $to_encoding; - protected $encoding_converter; - - function __construct($to_encoding = null) - { - $this->to_encoding = $to_encoding ? $to_encoding : Encoding::system(); - $this->encoding_converter = EncodingConverter::create(Utf8::NAME, $this->to_encoding); - $this->reset(); - } - - function from_encoding() - { - return Utf8::NAME; - } - - function to_encoding() - { - return $this->to_encoding; - } - - function reset() - { - $this->started = false; - } - - function convert($string) - { - if (!$this->started) { - $this->started = true; - $string = Utf8::instance()->trim($string); - return $this->encoding_converter->convert($string); - } else { - return $this->encoding_converter->convert($string); - } - return $string; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/text/utf8_encoder.class.php b/main/inc/lib/system/text/utf8_encoder.class.php deleted file mode 100755 index aabe921cf6..0000000000 --- a/main/inc/lib/system/text/utf8_encoder.class.php +++ /dev/null @@ -1,72 +0,0 @@ - - */ -class Utf8Encoder extends Converter -{ - - protected $started = false; - protected $from_encoding; - protected $encoding_converter; - protected $convert_html_entities = false; - - function __construct($from_encoding = null , $convert_html_entities = false) - { - $this->from_encoding = $from_encoding ? $from_encoding : Encoding::system(); - $this->encoding_converter = EncodingConverter::create($this->from_encoding, Utf8::NAME); - $this->convert_html_entities = $convert_html_entities; - $this->reset(); - } - - function from_encoding() - { - return $this->from_encoding; - } - - function to_encoding() - { - return Utf8::NAME; - } - - function get_convert_html_entities() - { - return $this->convert_html_entities; - } - - function reset() - { - $this->started = false; - } - - function convert($string) - { - if ($this->convert_html_entities) { - $string = html_entity_decode($string, ENT_COMPAT, Utf8::NAME); - } - $string = $this->encoding_converter->convert($string); - if (!$this->started) { - $this->started = true; - $string = Utf8::BOM . $string; - } - return $string; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system/web/header.class.php b/main/inc/lib/system/web/header.class.php index b1c23d08ab..1495c0babc 100755 --- a/main/inc/lib/system/web/header.class.php +++ b/main/inc/lib/system/web/header.class.php @@ -8,79 +8,14 @@ */ class Header { - - public static function response_code($response_code) - { - if (function_exists('http_response_code')) { - http_response_code($response_code); - return; - } - - switch ($response_code) { - case 400: - header("HTTP/1.0 $response_code Bad Request"); - case 401: - header("HTTP/1.0 $response_code Unauthorized"); - case 402: - header("HTTP/1.0 $response_code Payment Required"); - case 403: - header("HTTP/1.0 $response_code Forbidden"); - case 404: - header("HTTP/1.0 $response_code Not Found"); - default: - header("HTTP/1.0 $response_code"); - } - } - - public static function content_type($mime_type, $charset = '') - { - if (empty($mime_type)) { - return; - } - $type = $charset ? "$mime_type;charset=$charset" : $mime_type; - header('Content-type: ' . $type); - } - - public static function content_type_xml() - { - header('Content-type: text/xml'); - } - - public static function content_type_json() - { - header('Content-type: application/json'); - } - - public static function content_type_javascript() - { - header('Content-type: application/javascript'); - } - /** * Redirect the navigator to the specified url. - * - * @param string $url + * + * @param string $url */ public static function location($url) { header("Location: $url"); exit; } - - public static function expires($timestamp) - { - $value = gmdate('D, d M Y H:i:s \G\M\T', $timestamp); - header('Expires: ' . $value); - } - - public static function cache_control($value) - { - header('Cache-Control: ' . $value); - } - - public static function pragma($value) - { - header('Pragma: ' . $value); - } - -} \ No newline at end of file +} diff --git a/main/inc/lib/system/web/request.class.php b/main/inc/lib/system/web/request.class.php index 5e827f8f96..3979b70c9c 100755 --- a/main/inc/lib/system/web/request.class.php +++ b/main/inc/lib/system/web/request.class.php @@ -2,7 +2,7 @@ /** * Provides access to various HTTP request elements: GET, POST, FILE, etc paramaters. - + * @license see /license.txt * @author Laurent Opprecht for the Univesity of Geneva */ @@ -13,14 +13,14 @@ class Request { return isset($_REQUEST[$key]) ? $_REQUEST[$key] : $default; } - + public static function has($key){ return isset($_REQUEST[$key]); } - + /** * Returns true if the request is a GET request. False otherwise. - * + * * @return bool */ public static function is_get() @@ -29,15 +29,15 @@ class Request $method = strtoupper($method); return $method == 'GET'; } - + public static function post($key, $default = null) { return isset($_POST[$key]) ? $_POST[$key] : $default; } - + /** * Returns true if the request is a POST request. False otherwise. - * + * * @return bool */ public static function is_post() @@ -46,15 +46,6 @@ class Request $method = strtoupper($method); return $method == 'POST'; } - - /** - * - * @return RequestServer - */ - static function server() - { - return RequestServer::instance(); - } static function file($key, $default = null) { @@ -66,4 +57,4 @@ class Request return isset($_ENV[$key]) ? $_ENV[$key] : $default; } -} \ No newline at end of file +} diff --git a/main/inc/lib/system/web/request_server.class.php b/main/inc/lib/system/web/request_server.class.php deleted file mode 100755 index cd6741ed61..0000000000 --- a/main/inc/lib/system/web/request_server.class.php +++ /dev/null @@ -1,302 +0,0 @@ - request_uri() - * - * - * @license see /license.txt - * @author Laurent Opprecht for the Univesity of Geneva - */ -class RequestServer -{ - - public static function instance() - { - static $result = null; - if (empty($result)) { - $result = new self(); - } - return $result; - } - - function get($key, $default = null) - { - return isset($_SERVER[$key]) ? $_SERVER[$key] : null; - } - - /** - * The timestamp of the start of the request. Available since PHP 5.1.0. - * - * @return string - */ - function request_time() - { - return isset($_SERVER['REQUEST_TIME']) ? $_SERVER['REQUEST_TIME'] : null; - } - - /** - * Contents of the Host: header from the current request, if there is one. - * - * @return string - */ - function http_host() - { - return isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null; - } - - /** - * Contents of the User-Agent: header from the current request, if there is one. This is a string denoting the user agent being which is accessing the page. A typical example is: Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586). Among other things, you can use this value with get_browser() to tailor your page's output to the capabilities of the user agent. - * - * @return string - */ - function http_user_agent() - { - return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; - } - - /** - * Contents of the Accept: header from the current request, if there is one. - * - * @return string - */ - function http_accept() - { - return isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null; - } - - /** - * Contents of the Accept-Language: header from the current request, if there is one. Example: 'en'. - * - * @return string - */ - function http_accept_language() - { - return isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null; - } - - /** - * Contents of the Accept-Encoding: header from the current request, if there is one. Example: 'gzip'. - * - * @return string - */ - function http_accept_encoding() - { - return isset($_SERVER['HTTP_ACCEPT_ENCODING']) ? $_SERVER['HTTP_ACCEPT_ENCODING'] : null; - } - - /** - * Contents of the Connection: header from the current request, if there is one. Example: 'Keep-Alive'. - * - * @return string - */ - function http_connection() - { - return isset($_SERVER['HTTP_CONNECTION']) ? $_SERVER['HTTP_CONNECTION'] : null; - } - - function http_cookie() - { - return isset($_SERVER['HTTP_COOKIE']) ? $_SERVER['HTTP_COOKIE'] : null; - } - - function http_cache_control() - { - return isset($_SERVER['HTTP_CACHE_CONTROL']) ? $_SERVER['HTTP_CACHE_CONTROL'] : null; - } - - function path() - { - return isset($_SERVER['PATH']) ? $_SERVER['PATH'] : null; - } - - function systemroot() - { - return isset($_SERVER['SystemRoot']) ? $_SERVER['SystemRoot'] : null; - } - - function comspec() - { - return isset($_SERVER['COMSPEC']) ? $_SERVER['COMSPEC'] : null; - } - - function pathext() - { - return isset($_SERVER['PATHEXT']) ? $_SERVER['PATHEXT'] : null; - } - - function windir() - { - return isset($_SERVER['WINDIR']) ? $_SERVER['WINDIR'] : null; - } - - function server_signature() - { - return isset($_SERVER['SERVER_SIGNATURE']) ? $_SERVER['SERVER_SIGNATURE'] : null; - } - - /** - * Server identification string, given in the headers when responding to requests. - * - * @return string - */ - function server_software() - { - return isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : null; - } - - /** - * The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host. - * - * @return string - */ - function server_name() - { - return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null; - } - - /** - * The IP address of the server under which the current script is executing. - * - * @return string - */ - function server_addr() - { - return isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : null; - } - - function server_port() - { - return isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : null; - } - - /** - * The IP address from which the user is viewing the current page. - * - * @return string - */ - function remote_addr() - { - return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; - } - - /** - * The document root directory under which the current script is executing, as defined in the server's configuration file. - * @return string - */ - function document_root() - { - return isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : null; - } - - /** - * The value given to the SERVER_ADMIN (for Apache) directive in the web server configuration file. If the script is running on a virtual host, this will be the value defined for that virtual host. - * - * @return string - */ - function server_admin() - { - return isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : null; - } - - /** - * The absolute pathname of the currently executing script. - * - * Note: - * - * If a script is executed with the CLI, as a relative path, such as file.php or ../file.php, $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user. - * - * @return string - */ - function script_filename() - { - return isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : null; - } - - /** - * The port being used on the user's machine to communicate with the web server. - * - * @return string - */ - function remote_port() - { - return isset($_SERVER['REMOTE_PORT']) ? $_SERVER['REMOTE_PORT'] : null; - } - - /** - * What revision of the CGI specification the server is using; i.e. 'CGI/1.1'. - * - * @return string - */ - function gateway_interface() - { - return isset($_SERVER['GATEWAY_INTERFACE']) ? $_SERVER['GATEWAY_INTERFACE'] : null; - } - - /** - * Name and revision of the information protocol via which the page was requested; i.e. 'HTTP/1.0'; - * - * @return string - */ - function server_protocol() - { - return isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : null; - } - - /** - * Which request method was used to access the page; i.e. 'GET', 'HEAD', 'POST', 'PUT'. - * - * Note: - * PHP script is terminated after sending headers (it means after producing any output without output buffering) if the request method was HEAD. - * - * @return string - */ - function request_method() - { - return isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null; - } - - /** - * The query string, if any, via which the page was accessed. - * - * @return string - */ - function query_string() - { - return isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null; - } - - /** - * The URI which was given in order to access this page; for instance, '/index.html'. - * @return string - */ - function request_uri() - { - return isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null; - } - - /** - * Contains the current script's path. This is useful for pages which need to point to themselves. The __FILE__ constant contains the full path and filename of the current (i.e. included) file. - * - * @return string - */ - function script_name() - { - return isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : null; - } - - /** - * The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar. The __FILE__ constant contains the full path and filename of the current (i.e. included) file. If PHP is running as a command-line processor this variable contains the script name since PHP 4.3.0. Previously it was not available. - * - * @return string - */ - function php_self() - { - return isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : null; - } - -} \ No newline at end of file diff --git a/main/inc/lib/system_announcements.lib.php b/main/inc/lib/system_announcements.lib.php index 2b34fa408f..3ff0e234b6 100755 --- a/main/inc/lib/system_announcements.lib.php +++ b/main/inc/lib/system_announcements.lib.php @@ -57,7 +57,7 @@ class SystemAnnouncementManager } global $_configuration; $current_access_url_id = 1; - if ($_configuration['multiple_access_urls']) { + if (api_is_multiple_url_enabled()) { $current_access_url_id = api_get_current_access_url_id(); } $sql .= " AND access_url_id = '$current_access_url_id' "; @@ -251,7 +251,7 @@ class SystemAnnouncementManager global $_configuration; $current_access_url_id = 1; - if ($_configuration['multiple_access_urls']) { + if (api_is_multiple_url_enabled()) { $current_access_url_id = api_get_current_access_url_id(); } $sql .= " AND access_url_id = '$current_access_url_id' "; @@ -277,9 +277,8 @@ class SystemAnnouncementManager $now = api_get_utc_datetime(); $sql = "SELECT *, IF( '$now' >= date_start AND '$now' <= date_end, '1', '0') AS visible FROM $db_table"; - global $_configuration; $current_access_url_id = 1; - if ($_configuration['multiple_access_urls']) { + if (api_is_multiple_url_enabled()) { $current_access_url_id = api_get_current_access_url_id(); } $sql .= " WHERE access_url_id = '$current_access_url_id' "; @@ -357,9 +356,8 @@ class SystemAnnouncementManager $langsql = is_null($lang) ? 'NULL' : "'".Database::escape_string($lang)."'"; - global $_configuration; $current_access_url_id = 1; - if ($_configuration['multiple_access_urls']) { + if (api_is_multiple_url_enabled()) { $current_access_url_id = api_get_current_access_url_id(); } diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index baac62afc7..9a3b89509e 100755 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -451,11 +451,12 @@ class Template //Here we can add system parameters that can be use in any template $_s = array( - 'software_name' => $_configuration['software_name'], + 'software_name' => $_configuration['software_name'], 'system_version' => $_configuration['system_version'], - 'site_name' => api_get_setting('siteName'), - 'institution' => api_get_setting('Institution'), - 'date' => api_format_date('now', DATE_FORMAT_LONG), + 'site_name' => api_get_setting('siteName'), + 'institution' => api_get_setting('Institution'), + 'date' => api_format_date('now', DATE_FORMAT_LONG), + 'timezone' => _api_get_timezone() ); $this->assign('_s', $_s); } @@ -760,7 +761,7 @@ class Template $favico = ''; - if (isset($_configuration['multiple_access_urls']) && $_configuration['multiple_access_urls']) { + if (api_is_multiple_url_enabled()) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url_info = api_get_access_url($access_url_id); @@ -947,13 +948,13 @@ class Template //Tutor name if (api_get_setting('show_tutor_data') == 'true') { // Course manager - $id_course = api_get_course_id(); + $courseId = api_get_course_int_id(); $id_session = api_get_session_id(); - if (isset($id_course) && $id_course != -1) { + if (!empty($courseId)) { $tutor_data = ''; if ($id_session != 0) { - $coachs_email = CourseManager::get_email_of_tutor_to_session($id_session, $id_course); - $email_link = array(); + $coachs_email = CourseManager::get_email_of_tutor_to_session($id_session, $courseId); + $email_link = array(); foreach ($coachs_email as $coach) { $email_link[] = Display::encrypted_mailto_link($coach['email'], $coach['complete_name']); } @@ -973,10 +974,10 @@ class Template if (api_get_setting('show_teacher_data') == 'true') { // course manager - $id_course = api_get_course_id(); - if (isset($id_course) && $id_course != -1) { + $courseId = api_get_course_int_id(); + if (!empty($courseId)) { $teacher_data = ''; - $mail = CourseManager::get_emails_of_tutors_to_course($id_course); + $mail= CourseManager::get_emails_of_tutors_to_course($courseId); if (!empty($mail)) { $teachers_parsed = array(); foreach ($mail as $value) { diff --git a/main/inc/lib/thematic.lib.php b/main/inc/lib/thematic.lib.php index e8aed54d2f..0dee5d71ef 100755 --- a/main/inc/lib/thematic.lib.php +++ b/main/inc/lib/thematic.lib.php @@ -296,9 +296,9 @@ class Thematic VALUES ($this->course_int_id, '$title', '$content', 1, ".(intval($max_thematic_item)+1).", $session_id) "; $result = Database::query($sql); $last_id = Database::insert_id(); - if (Database::affected_rows($result)) { - // save inside item property table - $last_id = Database::insert_id(); + if ($last_id) { + $sql = "UPDATE $tbl_thematic SET id = iid WHERE iid = $last_id"; + Database::query($sql); api_item_property_update($_course, 'thematic', $last_id,"ThematicAdded", $user_id); } } else { @@ -633,7 +633,7 @@ class Thematic if (in_array($row['thematic_id'], $tmp)) { if ($force_session_id) { if (in_array($row['id'], array_keys($elements))) { - $row['session_id'] = $elements[$row['id']]['id_session']; + $row['session_id'] = $elements[$row['id']]['session_id']; $data[$row['thematic_id']][$row['id']] = $row; } } else { @@ -644,6 +644,7 @@ class Thematic } } } + return $data; } @@ -676,7 +677,10 @@ class Thematic $result = Database::query($sql); $last_id = Database::insert_id(); - if (Database::affected_rows($result)) { + if ($last_id) { + $sql = "UPDATE $tbl_thematic_advance SET id = iid WHERE iid = $last_id"; + Database::query($sql); + api_item_property_update($_course, 'thematic_advance', $last_id,"ThematicAdvanceAdded", $user_id); } } else { @@ -868,8 +872,9 @@ class Thematic VALUES ($this->course_int_id, $thematic_id, '$title', '$description', $description_type) "; $result = Database::query($ins); $last_id = Database::insert_id(); - $affected_rows = Database::affected_rows($result); - if ($affected_rows) { + if ($last_id) { + $sql = "UPDATE $tbl_thematic_plan SET id = iid WHERE iid = $last_id"; + Database::query($sql); api_item_property_update($_course, 'thematic_plan', $last_id,"ThematicPlanAdded", $user_id); } } @@ -879,8 +884,9 @@ class Thematic VALUES($this->course_int_id, $thematic_id, '$title', '$description', $description_type) "; $result = Database::query($ins); $last_id = Database::insert_id(); - $affected_rows = Database::affected_rows($result); - if ($affected_rows) { + if ($last_id) { + $sql = "UPDATE $tbl_thematic_plan SET id = iid WHERE iid = $last_id"; + Database::query($sql); api_item_property_update($_course, 'thematic_plan', $last_id,"ThematicPlanAdded", $user_id); } } @@ -1037,13 +1043,22 @@ class Thematic // get all thematic advance done $rs_thematic_done = Database::query("SELECT ref FROM $tbl_item_property - WHERE c_id = $course_id AND tool='thematic_advance' AND lastedit_type='ThematicAdvanceDone' AND id_session = $sessionId "); + WHERE c_id = $course_id AND tool='thematic_advance' AND lastedit_type='ThematicAdvanceDone' AND session_id = $sessionId "); if (Database::num_rows($rs_thematic_done) > 0) { while ($row_thematic_done = Database::fetch_array($rs_thematic_done)) { $ref = $row_thematic_done['ref']; if (in_array($ref, $a_thematic_advance_ids)) { continue; } // update items - Database::query("UPDATE $tbl_item_property SET lastedit_date='".api_get_utc_datetime()."', lastedit_type='ThematicAdvanceUpdated', lastedit_user_id = $user_id WHERE c_id = $course_id AND tool='thematic_advance' AND ref=$ref AND id_session = $sessionId "); + $sql = "UPDATE $tbl_item_property SET + lastedit_date='".api_get_utc_datetime()."', + lastedit_type='ThematicAdvanceUpdated', + lastedit_user_id = $user_id + WHERE + c_id = $course_id AND + tool='thematic_advance' AND + ref=$ref AND + session_id = $sessionId "; + Database::query($sql); } } } diff --git a/main/inc/lib/tools/entity_generator.class.php b/main/inc/lib/tools/entity_generator.class.php deleted file mode 100755 index ffe04b00b9..0000000000 --- a/main/inc/lib/tools/entity_generator.class.php +++ /dev/null @@ -1,1170 +0,0 @@ -getClassMetadataFactory()->getAllMetadata(); - * - * $generator = new \Doctrine\ORM\Tools\EntityGenerator(); - * $generator->setGenerateAnnotations(true); - * $generator->setGenerateStubMethods(true); - * $generator->setRegenerateEntityIfExists(false); - * $generator->setUpdateEntityIfExists(true); - * $generator->generate($classes, '/path/to/generate/entities'); - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision$ - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - */ -class EntityGenerator -{ - - /** - * @var bool - */ - private $_backupExisting = true; - - /** The extension to use for written php files */ - private $_extension = '.php'; - - /** Whether or not the current ClassMetadataInfo instance is new or old */ - private $_isNew = true; - private $_staticReflection = array(); - - /** Number of spaces to use for indention in generated code */ - private $_numSpaces = 4; - - /** The actual spaces to use for indention */ - private $_spaces = ' '; - - /** The class all generated entities should extend */ - private $_classToExtend; - - /** Whether or not to generation annotations */ - private $_generateAnnotations = false; - - /** - * @var string - */ - private $_annotationsPrefix = ''; - - /** Whether or not to generated sub methods */ - private $_generateEntityStubMethods = false; - - /** Whether or not to update the entity class if it exists already */ - private $_updateEntityIfExists = false; - - /** Whether or not to re-generate entity class if it exists already */ - private $_regenerateEntityIfExists = false; - private static $_classTemplate = - ' -{ -/** - * @return \Entity\Repository\Repository - */ - public static function repository(){ -return \Entity\Repository\Repository::instance(); -} - -/** - * @return \Entity\ - */ - public static function create(){ -return new self(); -} - - -}'; - private static $_getMethodTemplate = - '/** - * - * - * @return - */ -public function () -{ -return $this->; -}'; - private static $_setMethodTemplate = - '/** - * - * - * @param $ - * @return - */ -public function ($) -{ -$this-> = $; -return $this; -}'; - private static $_addMethodTemplate = - '/** - * - * - * @param $ - * @return - */ -public function ($) -{ -$this->[] = $; -return $this; -}'; - private static $_lifecycleCallbackMethodTemplate = - '/** - * @ - */ -public function () -{ -// Add your code here -}'; - private static $_constructorMethodTemplate = - 'public function __construct() -{ - -} -'; - - public function __construct() - { - if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) { - $this->_annotationsPrefix = 'ORM\\'; - } - } - - /** - * Generate and write entity classes for the given array of ClassMetadataInfo instances - * - * @param array $metadatas - * @param string $outputDirectory - * @return void - */ - public function generate(array $metadatas, $outputDirectory) - { - foreach ($metadatas as $metadata) { - $this->writeEntityClass($metadata, $outputDirectory); - } - } - - /** - * Generated and write entity class to disk for the given ClassMetadataInfo instance - * - * @param ClassMetadataInfo $metadata - * @param string $outputDirectory - * @return void - */ - public function writeEntityClass(ClassMetadataInfo $metadata, $outputDirectory) - { - //change - $name = $metadata->name; - $name = explode('\\', $name); - $name = end($name); - $name = Inflector::tableize($name); - $is_course_table = (strpos($name, 'c_') === 0); - if ($is_course_table) { - $name = substr($name, 2, strlen($name) - 2); - } - $name = Inflector::tableize($name); - // - - $path = $outputDirectory . '/' . str_replace('\\', DIRECTORY_SEPARATOR, $name) . $this->_extension; - $dir = dirname($path); - - if (!is_dir($dir)) { - mkdir($dir, 0777, true); - } - - $this->_isNew = !file_exists($path) || (file_exists($path) && $this->_regenerateEntityIfExists); - - if (!$this->_isNew) { - $this->_parseTokensInEntityFile(file_get_contents($path)); - } else { - $this->_staticReflection[$metadata->name] = array('properties' => array(), 'methods' => array()); - } - - if ($this->_backupExisting && file_exists($path)) { - $backupPath = dirname($path) . DIRECTORY_SEPARATOR . basename($path) . "~"; - if (!copy($path, $backupPath)) { - throw new \RuntimeException("Attempt to backup overwritten entity file but copy operation failed."); - } - } - - // If entity doesn't exist or we're re-generating the entities entirely - if ($this->_isNew) { - file_put_contents($path, $this->generateEntityClass($metadata)); - // If entity exists and we're allowed to update the entity class - } else if (!$this->_isNew && $this->_updateEntityIfExists) { - file_put_contents($path, $this->generateUpdatedEntityClass($metadata, $path)); - } - } - - /** - * Generate a PHP5 Doctrine 2 entity class from the given ClassMetadataInfo instance - * - * @param ClassMetadataInfo $metadata - * @return string $code - */ - public function generateEntityClass(ClassMetadataInfo $metadata) - { - $placeHolders = array( - '', - '', - '', - '' - ); - - $replacements = array( - $this->_generateEntityNamespace($metadata), - $this->_generateEntityDocBlock($metadata), - $this->_generateEntityClassName($metadata), - $this->_generateEntityBody($metadata) - ); - - - $code = str_replace($placeHolders, $replacements, self::$_classTemplate); - $result = str_replace('', $this->_spaces, $code); - $result = str_replace('', $this->_getClassName($metadata), $result); - return $result; - } - - /** - * Generate the updated code for the given ClassMetadataInfo and entity at path - * - * @param ClassMetadataInfo $metadata - * @param string $path - * @return string $code; - */ - public function generateUpdatedEntityClass(ClassMetadataInfo $metadata, $path) - { - $currentCode = file_get_contents($path); - - $body = $this->_generateEntityBody($metadata); - $body = str_replace('', $this->_spaces, $body); - $last = strrpos($currentCode, '}'); - - return substr($currentCode, 0, $last) . $body . (strlen($body) > 0 ? "\n" : '') . "}"; - } - - /** - * Set the number of spaces the exported class should have - * - * @param integer $numSpaces - * @return void - */ - public function setNumSpaces($numSpaces) - { - $this->_spaces = str_repeat(' ', $numSpaces); - $this->_numSpaces = $numSpaces; - } - - /** - * Set the extension to use when writing php files to disk - * - * @param string $extension - * @return void - */ - public function setExtension($extension) - { - $this->_extension = $extension; - } - - /** - * Set the name of the class the generated classes should extend from - * - * @return void - */ - public function setClassToExtend($classToExtend) - { - $this->_classToExtend = $classToExtend; - } - - /** - * Set whether or not to generate annotations for the entity - * - * @param bool $bool - * @return void - */ - public function setGenerateAnnotations($bool) - { - $this->_generateAnnotations = $bool; - } - - /** - * Set an annotation prefix. - * - * @param string $prefix - */ - public function setAnnotationPrefix($prefix) - { - $this->_annotationsPrefix = $prefix; - } - - /** - * Set whether or not to try and update the entity if it already exists - * - * @param bool $bool - * @return void - */ - public function setUpdateEntityIfExists($bool) - { - $this->_updateEntityIfExists = $bool; - } - - /** - * Set whether or not to regenerate the entity if it exists - * - * @param bool $bool - * @return void - */ - public function setRegenerateEntityIfExists($bool) - { - $this->_regenerateEntityIfExists = $bool; - } - - /** - * Set whether or not to generate stub methods for the entity - * - * @param bool $bool - * @return void - */ - public function setGenerateStubMethods($bool) - { - $this->_generateEntityStubMethods = $bool; - } - - /** - * Should an existing entity be backed up if it already exists? - */ - public function setBackupExisting($bool) - { - $this->_backupExisting = $bool; - } - - private function _generateEntityNamespace(ClassMetadataInfo $metadata) - { - if ($this->_hasNamespace($metadata)) { - return 'namespace ' . $this->_getNamespace($metadata) . ';'; - } - } - - private function _generateEntityClassName(ClassMetadataInfo $metadata) - { - return 'class ' . $this->_getClassName($metadata) . - ($this->_extendsClass() ? ' extends ' . $this->_getClassToExtendName($metadata) : null); - } - - private function _generateEntityBody(ClassMetadataInfo $metadata) - { - $fieldMappingProperties = $this->_generateEntityFieldMappingProperties($metadata); - $associationMappingProperties = $this->_generateEntityAssociationMappingProperties($metadata); - $stubMethods = $this->_generateEntityStubMethods ? $this->_generateEntityStubMethods($metadata) : null; - $lifecycleCallbackMethods = $this->_generateEntityLifecycleCallbackMethods($metadata); - - $code = array(); - - if ($fieldMappingProperties) { - $code[] = $fieldMappingProperties; - } - - if ($associationMappingProperties) { - $code[] = $associationMappingProperties; - } - - $code[] = $this->_generateEntityConstructor($metadata); - - if ($stubMethods) { - $code[] = $stubMethods; - } - - if ($lifecycleCallbackMethods) { - $code[] = $lifecycleCallbackMethods; - } - - return implode("\n", $code); - } - - private function _generateEntityConstructor(ClassMetadataInfo $metadata) - { - if ($this->_hasMethod('__construct', $metadata)) { - return ''; - } - - $collections = array(); - - foreach ($metadata->associationMappings AS $mapping) { - if ($mapping['type'] & ClassMetadataInfo::TO_MANY) { - $collections[] = '$this->' . $mapping['fieldName'] . ' = new \Doctrine\Common\Collections\ArrayCollection();'; - } - } - - if ($collections) { - return $this->_prefixCodeWithSpaces(str_replace("", implode("\n" . $this->_spaces, $collections), self::$_constructorMethodTemplate)); - } - - return ''; - } - - /** - * @todo this won't work if there is a namespace in brackets and a class outside of it. - * @param string $src - */ - private function _parseTokensInEntityFile($src) - { - $tokens = token_get_all($src); - $lastSeenNamespace = ""; - $lastSeenClass = false; - - $inNamespace = false; - $inClass = false; - for ($i = 0; $i < count($tokens); $i++) { - $token = $tokens[$i]; - if (in_array($token[0], array(T_WHITESPACE, T_COMMENT, T_DOC_COMMENT))) { - continue; - } - - if ($inNamespace) { - if ($token[0] == T_NS_SEPARATOR || $token[0] == T_STRING) { - $lastSeenNamespace .= $token[1]; - } else if (is_string($token) && in_array($token, array(';', '{'))) { - $inNamespace = false; - } - } - - if ($inClass) { - $inClass = false; - $lastSeenClass = $lastSeenNamespace . ($lastSeenNamespace ? '\\' : '') . $token[1]; - $this->_staticReflection[$lastSeenClass]['properties'] = array(); - $this->_staticReflection[$lastSeenClass]['methods'] = array(); - } - - if ($token[0] == T_NAMESPACE) { - $lastSeenNamespace = ""; - $inNamespace = true; - } else if ($token[0] == T_CLASS) { - $inClass = true; - } else if ($token[0] == T_FUNCTION) { - if ($tokens[$i + 2][0] == T_STRING) { - $this->_staticReflection[$lastSeenClass]['methods'][] = $tokens[$i + 2][1]; - } else if ($tokens[$i + 2] == "&" && $tokens[$i + 3][0] == T_STRING) { - $this->_staticReflection[$lastSeenClass]['methods'][] = $tokens[$i + 3][1]; - } - } else if (in_array($token[0], array(T_VAR, T_PUBLIC, T_PRIVATE, T_PROTECTED)) && $tokens[$i + 2][0] != T_FUNCTION) { - $this->_staticReflection[$lastSeenClass]['properties'][] = substr($tokens[$i + 2][1], 1); - } - } - } - - private function _hasProperty($property, ClassMetadataInfo $metadata) - { - if ($this->_extendsClass()) { - // don't generate property if its already on the base class. - $reflClass = new \ReflectionClass($this->_getClassToExtend($metadata)); - if ($reflClass->hasProperty($property)) { - return true; - } - } - - return ( - isset($this->_staticReflection[$metadata->name]) && - in_array($property, $this->_staticReflection[$metadata->name]['properties']) - ); - } - - private function _hasMethod($method, ClassMetadataInfo $metadata) - { - if ($this->_extendsClass()) { - // don't generate method if its already on the base class. - $reflClass = new \ReflectionClass($this->_getClassToExtend($metadata)); - if ($reflClass->hasMethod($method)) { - return true; - } - } - - return ( - isset($this->_staticReflection[$metadata->name]) && - in_array($method, $this->_staticReflection[$metadata->name]['methods']) - ); - } - - private function _hasNamespace(ClassMetadataInfo $metadata) - { - return strpos($metadata->name, '\\') ? true : false; - } - - private function _extendsClass() - { - return $this->_classToExtend ? true : false; - } - - private function _getClassToExtend($metadata) - { - return isset($metadata->class_to_extend) ? $metadata->class_to_extend : $this->_classToExtend; - } - - private function _getClassToExtendName($metadata) - { - $refl = new \ReflectionClass($this->_getClassToExtend($metadata)); - - return '\\' . $refl->getName(); - } - - private function _getClassName(ClassMetadataInfo $metadata) - { - //changed - $name = $metadata->name; - $name = explode('\\', $name); - $name = end($name); - $name = Inflector::tableize($name); - $is_course_table = (strpos($name, 'c_') === 0); - if ($is_course_table) { - $name = substr($name, 2, strlen($name) - 2); - } - $name = Inflector::classify($name); - - $result = ($pos = strrpos($name, '\\')) ? substr($name, $pos + 1, strlen($name)) : $name; - return $result; - } - - private function _getNamespace(ClassMetadataInfo $metadata) - { - return substr($metadata->name, 0, strrpos($metadata->name, '\\')); - } - - private function _generateEntityDocBlock(ClassMetadataInfo $metadata) - { - $lines = array(); - $lines[] = '/**'; - $lines[] = ' * ' . $metadata->name; - - if ($this->_generateAnnotations) { - $lines[] = ' *'; - - $methods = array( - '_generateTableAnnotation', - '_generateInheritanceAnnotation', - '_generateDiscriminatorColumnAnnotation', - '_generateDiscriminatorMapAnnotation' - ); - - foreach ($methods as $method) { - if ($code = $this->$method($metadata)) { - $lines[] = ' * ' . $code; - } - } - - if ($metadata->isMappedSuperclass) { - $lines[] = ' * @' . $this->_annotationsPrefix . 'MappedSuperClass'; - } else { - $lines[] = ' * @' . $this->_annotationsPrefix . 'Entity'; - } - - if ($metadata->customRepositoryClassName) { - $lines[count($lines) - 1] .= '(repositoryClass="' . $metadata->customRepositoryClassName . '")'; - } - - if (isset($metadata->lifecycleCallbacks) && $metadata->lifecycleCallbacks) { - $lines[] = ' * @' . $this->_annotationsPrefix . 'HasLifecycleCallbacks'; - } - } - - $lines[] = ' */'; - - return implode("\n", $lines); - } - - private function _generateTableAnnotation($metadata) - { - $table = array(); - - if (isset($metadata->table['schema'])) { - $table[] = 'schema="' . $metadata->table['schema'] . '"'; - } - - if (isset($metadata->table['name'])) { - $table[] = 'name="' . $metadata->table['name'] . '"'; - } - - if (isset($metadata->table['uniqueConstraints']) && $metadata->table['uniqueConstraints']) { - $constraints = $this->_generateTableConstraints('UniqueConstraint', $metadata->table['uniqueConstraints']); - $table[] = 'uniqueConstraints={' . $constraints . '}'; - } - - if (isset($metadata->table['indexes']) && $metadata->table['indexes']) { - $constraints = $this->_generateTableConstraints('Index', $metadata->table['indexes']); - $table[] = 'indexes={' . $constraints . '}'; - } - - return '@' . $this->_annotationsPrefix . 'Table(' . implode(', ', $table) . ')'; - } - - private function _generateTableConstraints($constraintName, $constraints) - { - $annotations = array(); - foreach ($constraints as $name => $constraint) { - $columns = array(); - foreach ($constraint['columns'] as $column) { - $columns[] = '"' . $column . '"'; - } - $annotations[] = '@' . $this->_annotationsPrefix . $constraintName . '(name="' . $name . '", columns={' . implode(', ', $columns) . '})'; - } - return implode(', ', $annotations); - } - - private function _generateInheritanceAnnotation($metadata) - { - if ($metadata->inheritanceType != ClassMetadataInfo::INHERITANCE_TYPE_NONE) { - return '@' . $this->_annotationsPrefix . 'InheritanceType("' . $this->_getInheritanceTypeString($metadata->inheritanceType) . '")'; - } - } - - private function _generateDiscriminatorColumnAnnotation($metadata) - { - if ($metadata->inheritanceType != ClassMetadataInfo::INHERITANCE_TYPE_NONE) { - $discrColumn = $metadata->discriminatorValue; - $columnDefinition = 'name="' . $discrColumn['name'] - . '", type="' . $discrColumn['type'] - . '", length=' . $discrColumn['length']; - - return '@' . $this->_annotationsPrefix . 'DiscriminatorColumn(' . $columnDefinition . ')'; - } - } - - private function _generateDiscriminatorMapAnnotation($metadata) - { - if ($metadata->inheritanceType != ClassMetadataInfo::INHERITANCE_TYPE_NONE) { - $inheritanceClassMap = array(); - - foreach ($metadata->discriminatorMap as $type => $class) { - $inheritanceClassMap[] .= '"' . $type . '" = "' . $class . '"'; - } - - return '@' . $this->_annotationsPrefix . 'DiscriminatorMap({' . implode(', ', $inheritanceClassMap) . '})'; - } - } - - private function _generateEntityStubMethods(ClassMetadataInfo $metadata) - { - $methods = array(); - - foreach ($metadata->fieldMappings as $fieldMapping) { - if (!isset($fieldMapping['id']) || !$fieldMapping['id'] || $metadata->generatorType == ClassMetadataInfo::GENERATOR_TYPE_NONE) { - if ($code = $this->_generateEntityStubMethod($metadata, 'set', $fieldMapping['fieldName'], $fieldMapping['type'])) { - $methods[] = $code; - } - } - - if ($code = $this->_generateEntityStubMethod($metadata, 'get', $fieldMapping['fieldName'], $fieldMapping['type'])) { - $methods[] = $code; - } - } - - foreach ($metadata->associationMappings as $associationMapping) { - if ($associationMapping['type'] & ClassMetadataInfo::TO_ONE) { - $nullable = $this->_isAssociationIsNullable($associationMapping) ? 'null' : null; - if ($code = $this->_generateEntityStubMethod($metadata, 'set', $associationMapping['fieldName'], $associationMapping['targetEntity'], $nullable)) { - $methods[] = $code; - } - if ($code = $this->_generateEntityStubMethod($metadata, 'get', $associationMapping['fieldName'], $associationMapping['targetEntity'])) { - $methods[] = $code; - } - } else if ($associationMapping['type'] & ClassMetadataInfo::TO_MANY) { - if ($code = $this->_generateEntityStubMethod($metadata, 'add', $associationMapping['fieldName'], $associationMapping['targetEntity'])) { - $methods[] = $code; - } - if ($code = $this->_generateEntityStubMethod($metadata, 'get', $associationMapping['fieldName'], 'Doctrine\Common\Collections\Collection')) { - $methods[] = $code; - } - } - } - - return implode("\n\n", $methods); - } - - private function _isAssociationIsNullable($associationMapping) - { - if (isset($associationMapping['id']) && $associationMapping['id']) { - return false; - } - if (isset($associationMapping['joinColumns'])) { - $joinColumns = $associationMapping['joinColumns']; - } else { - //@todo thereis no way to retreive targetEntity metadata - $joinColumns = array(); - } - foreach ($joinColumns as $joinColumn) { - if (isset($joinColumn['nullable']) && !$joinColumn['nullable']) { - return false; - } - } - return true; - } - - private function _generateEntityLifecycleCallbackMethods(ClassMetadataInfo $metadata) - { - if (isset($metadata->lifecycleCallbacks) && $metadata->lifecycleCallbacks) { - $methods = array(); - - foreach ($metadata->lifecycleCallbacks as $name => $callbacks) { - foreach ($callbacks as $callback) { - if ($code = $this->_generateLifecycleCallbackMethod($name, $callback, $metadata)) { - $methods[] = $code; - } - } - } - - return implode("\n\n", $methods); - } - - return ""; - } - - private function _generateEntityAssociationMappingProperties(ClassMetadataInfo $metadata) - { - $lines = array(); - - foreach ($metadata->associationMappings as $associationMapping) { - if ($this->_hasProperty($associationMapping['fieldName'], $metadata)) { - continue; - } - - $lines[] = $this->_generateAssociationMappingPropertyDocBlock($associationMapping, $metadata); - $lines[] = $this->_spaces . 'protected $' . $associationMapping['fieldName'] - . ($associationMapping['type'] == 'manyToMany' ? ' = array()' : null) . ";\n"; - } - - return implode("\n", $lines); - } - - private function _generateEntityFieldMappingProperties(ClassMetadataInfo $metadata) - { - $lines = array(); - - foreach ($metadata->fieldMappings as $fieldMapping) { - if ($this->_hasProperty($fieldMapping['fieldName'], $metadata) || - $metadata->isInheritedField($fieldMapping['fieldName'])) { - continue; - } - - $fieldMapping['fieldName'] = Inflector::tableize($fieldMapping['fieldName']); - - $lines[] = $this->_generateFieldMappingPropertyDocBlock($fieldMapping, $metadata); - $lines[] = $this->_spaces . 'protected $' . $fieldMapping['fieldName'] - . (isset($fieldMapping['default']) ? ' = ' . var_export($fieldMapping['default'], true) : null) . ";\n"; - } - - return implode("\n", $lines); - } - - private function _generateEntityStubMethod(ClassMetadataInfo $metadata, $type, $fieldName, $typeHint = null, $defaultValue = null) - { - - $fieldName = Inflector::tableize($fieldName); - if ($type == "add") { - $addMethod = explode("\\", $typeHint); - $addMethod = end($addMethod); - $methodName = $type . $addMethod; - } else { - //change - $methodName = $type . '_' . Inflector::tableize($fieldName); - // - } - - if ($this->_hasMethod($methodName, $metadata)) { - return; - } - $this->_staticReflection[$metadata->name]['methods'][] = $methodName; - - $var = sprintf('_%sMethodTemplate', $type); - $template = self::$$var; - - $variableType = $typeHint ? $typeHint . ' ' : null; - - $types = \Doctrine\DBAL\Types\Type::getTypesMap(); - $methodTypeHint = $typeHint && !isset($types[$typeHint]) ? '\\' . $typeHint . ' ' : null; - - $replacements = array( - '' => ucfirst($type) . ' ' . $fieldName, - '' => $methodTypeHint, - '' => $variableType, - '' => 'value', - '' => $methodName, - '' => $fieldName, - '' => ($defaultValue !== null ) ? (' = ' . $defaultValue) : '', - '' => $this->_getClassName($metadata) - ); - - $method = str_replace( - array_keys($replacements), array_values($replacements), $template - ); - - return $this->_prefixCodeWithSpaces($method); - } - - private function _generateLifecycleCallbackMethod($name, $methodName, $metadata) - { - if ($this->_hasMethod($methodName, $metadata)) { - return; - } - $this->_staticReflection[$metadata->name]['methods'][] = $methodName; - - $replacements = array( - '' => $this->_annotationsPrefix . $name, - '' => $methodName, - ); - - $method = str_replace( - array_keys($replacements), array_values($replacements), self::$_lifecycleCallbackMethodTemplate - ); - - return $this->_prefixCodeWithSpaces($method); - } - - private function _generateJoinColumnAnnotation(array $joinColumn) - { - $joinColumnAnnot = array(); - - if (isset($joinColumn['name'])) { - $joinColumnAnnot[] = 'name="' . $joinColumn['name'] . '"'; - } - - if (isset($joinColumn['referencedColumnName'])) { - $joinColumnAnnot[] = 'referencedColumnName="' . $joinColumn['referencedColumnName'] . '"'; - } - - if (isset($joinColumn['unique']) && $joinColumn['unique']) { - $joinColumnAnnot[] = 'unique=' . ($joinColumn['unique'] ? 'true' : 'false'); - } - - if (isset($joinColumn['nullable'])) { - $joinColumnAnnot[] = 'nullable=' . ($joinColumn['nullable'] ? 'true' : 'false'); - } - - if (isset($joinColumn['onDelete'])) { - $joinColumnAnnot[] = 'onDelete="' . ($joinColumn['onDelete'] . '"'); - } - - if (isset($joinColumn['columnDefinition'])) { - $joinColumnAnnot[] = 'columnDefinition="' . $joinColumn['columnDefinition'] . '"'; - } - - return '@' . $this->_annotationsPrefix . 'JoinColumn(' . implode(', ', $joinColumnAnnot) . ')'; - } - - private function _generateAssociationMappingPropertyDocBlock(array $associationMapping, ClassMetadataInfo $metadata) - { - $lines = array(); - $lines[] = $this->_spaces . '/**'; - - if ($associationMapping['type'] & ClassMetadataInfo::TO_MANY) { - $lines[] = $this->_spaces . ' * @var \Doctrine\Common\Collections\ArrayCollection'; - } else { - $lines[] = $this->_spaces . ' * @var ' . $associationMapping['targetEntity']; - } - - if ($this->_generateAnnotations) { - $lines[] = $this->_spaces . ' *'; - - if (isset($associationMapping['id']) && $associationMapping['id']) { - $lines[] = $this->_spaces . ' * @' . $this->_annotationsPrefix . 'Id'; - - if ($generatorType = $this->_getIdGeneratorTypeString($metadata->generatorType)) { - $lines[] = $this->_spaces . ' * @' . $this->_annotationsPrefix . 'GeneratedValue(strategy="' . $generatorType . '")'; - } - } - - $type = null; - switch ($associationMapping['type']) { - case ClassMetadataInfo::ONE_TO_ONE: - $type = 'OneToOne'; - break; - case ClassMetadataInfo::MANY_TO_ONE: - $type = 'ManyToOne'; - break; - case ClassMetadataInfo::ONE_TO_MANY: - $type = 'OneToMany'; - break; - case ClassMetadataInfo::MANY_TO_MANY: - $type = 'ManyToMany'; - break; - } - $typeOptions = array(); - - if (isset($associationMapping['targetEntity'])) { - $typeOptions[] = 'targetEntity="' . $associationMapping['targetEntity'] . '"'; - } - - if (isset($associationMapping['inversedBy'])) { - $typeOptions[] = 'inversedBy="' . $associationMapping['inversedBy'] . '"'; - } - - if (isset($associationMapping['mappedBy'])) { - $typeOptions[] = 'mappedBy="' . $associationMapping['mappedBy'] . '"'; - } - - if ($associationMapping['cascade']) { - $cascades = array(); - - if ($associationMapping['isCascadePersist']) - $cascades[] = '"persist"'; - if ($associationMapping['isCascadeRemove']) - $cascades[] = '"remove"'; - if ($associationMapping['isCascadeDetach']) - $cascades[] = '"detach"'; - if ($associationMapping['isCascadeMerge']) - $cascades[] = '"merge"'; - if ($associationMapping['isCascadeRefresh']) - $cascades[] = '"refresh"'; - - $typeOptions[] = 'cascade={' . implode(',', $cascades) . '}'; - } - - if (isset($associationMapping['orphanRemoval']) && $associationMapping['orphanRemoval']) { - $typeOptions[] = 'orphanRemoval=' . ($associationMapping['orphanRemoval'] ? 'true' : 'false'); - } - - $lines[] = $this->_spaces . ' * @' . $this->_annotationsPrefix . '' . $type . '(' . implode(', ', $typeOptions) . ')'; - - if (isset($associationMapping['joinColumns']) && $associationMapping['joinColumns']) { - $lines[] = $this->_spaces . ' * @' . $this->_annotationsPrefix . 'JoinColumns({'; - - $joinColumnsLines = array(); - - foreach ($associationMapping['joinColumns'] as $joinColumn) { - if ($joinColumnAnnot = $this->_generateJoinColumnAnnotation($joinColumn)) { - $joinColumnsLines[] = $this->_spaces . ' * ' . $joinColumnAnnot; - } - } - - $lines[] = implode(",\n", $joinColumnsLines); - $lines[] = $this->_spaces . ' * })'; - } - - if (isset($associationMapping['joinTable']) && $associationMapping['joinTable']) { - $joinTable = array(); - $joinTable[] = 'name="' . $associationMapping['joinTable']['name'] . '"'; - - if (isset($associationMapping['joinTable']['schema'])) { - $joinTable[] = 'schema="' . $associationMapping['joinTable']['schema'] . '"'; - } - - $lines[] = $this->_spaces . ' * @' . $this->_annotationsPrefix . 'JoinTable(' . implode(', ', $joinTable) . ','; - $lines[] = $this->_spaces . ' * joinColumns={'; - - foreach ($associationMapping['joinTable']['joinColumns'] as $joinColumn) { - $lines[] = $this->_spaces . ' * ' . $this->_generateJoinColumnAnnotation($joinColumn); - } - - $lines[] = $this->_spaces . ' * },'; - $lines[] = $this->_spaces . ' * inverseJoinColumns={'; - - foreach ($associationMapping['joinTable']['inverseJoinColumns'] as $joinColumn) { - $lines[] = $this->_spaces . ' * ' . $this->_generateJoinColumnAnnotation($joinColumn); - } - - $lines[] = $this->_spaces . ' * }'; - $lines[] = $this->_spaces . ' * )'; - } - - if (isset($associationMapping['orderBy'])) { - $lines[] = $this->_spaces . ' * @' . $this->_annotationsPrefix . 'OrderBy({'; - - foreach ($associationMapping['orderBy'] as $name => $direction) { - $lines[] = $this->_spaces . ' * "' . $name . '"="' . $direction . '",'; - } - - $lines[count($lines) - 1] = substr($lines[count($lines) - 1], 0, strlen($lines[count($lines) - 1]) - 1); - $lines[] = $this->_spaces . ' * })'; - } - } - - $lines[] = $this->_spaces . ' */'; - - return implode("\n", $lines); - } - - private function _generateFieldMappingPropertyDocBlock(array $fieldMapping, ClassMetadataInfo $metadata) - { - - $lines = array(); - $lines[] = $this->_spaces . '/**'; - $lines[] = $this->_spaces . ' * @var ' . $fieldMapping['type'] . ' $' . $fieldMapping['fieldName']; - - if ($this->_generateAnnotations) { - $lines[] = $this->_spaces . ' *'; - - $column = array(); - if (isset($fieldMapping['columnName'])) { - $column[] = 'name="' . $fieldMapping['columnName'] . '"'; - } - - if (isset($fieldMapping['type'])) { - $column[] = 'type="' . $fieldMapping['type'] . '"'; - } - - if (isset($fieldMapping['length'])) { - $column[] = 'length=' . $fieldMapping['length']; - } - - if (isset($fieldMapping['precision'])) { - $column[] = 'precision=' . $fieldMapping['precision']; - } - - if (isset($fieldMapping['scale'])) { - $column[] = 'scale=' . $fieldMapping['scale']; - } - - if (isset($fieldMapping['nullable'])) { - $column[] = 'nullable=' . var_export($fieldMapping['nullable'], true); - } - - if (isset($fieldMapping['columnDefinition'])) { - $column[] = 'columnDefinition="' . $fieldMapping['columnDefinition'] . '"'; - } - - if (isset($fieldMapping['unique'])) { - $column[] = 'unique=' . var_export($fieldMapping['unique'], true); - } - - $lines[] = $this->_spaces . ' * @' . $this->_annotationsPrefix . 'Column(' . implode(', ', $column) . ')'; - - if (isset($fieldMapping['id']) && $fieldMapping['id']) { - $lines[] = $this->_spaces . ' * @' . $this->_annotationsPrefix . 'Id'; - - if ($generatorType = $this->_getIdGeneratorTypeString($metadata->generatorType)) { - $lines[] = $this->_spaces . ' * @' . $this->_annotationsPrefix . 'GeneratedValue(strategy="' . $generatorType . '")'; - } - - if ($metadata->sequenceGeneratorDefinition) { - $sequenceGenerator = array(); - - if (isset($metadata->sequenceGeneratorDefinition['sequenceName'])) { - $sequenceGenerator[] = 'sequenceName="' . $metadata->sequenceGeneratorDefinition['sequenceName'] . '"'; - } - - if (isset($metadata->sequenceGeneratorDefinition['allocationSize'])) { - $sequenceGenerator[] = 'allocationSize="' . $metadata->sequenceGeneratorDefinition['allocationSize'] . '"'; - } - - if (isset($metadata->sequenceGeneratorDefinition['initialValue'])) { - $sequenceGenerator[] = 'initialValue="' . $metadata->sequenceGeneratorDefinition['initialValue'] . '"'; - } - - $lines[] = $this->_spaces . ' * @' . $this->_annotationsPrefix . 'SequenceGenerator(' . implode(', ', $sequenceGenerator) . ')'; - } - } - - if (isset($fieldMapping['version']) && $fieldMapping['version']) { - $lines[] = $this->_spaces . ' * @' . $this->_annotationsPrefix . 'Version'; - } - } - - $lines[] = $this->_spaces . ' */'; - - return implode("\n", $lines); - } - - private function _prefixCodeWithSpaces($code, $num = 1) - { - $lines = explode("\n", $code); - - foreach ($lines as $key => $value) { - $lines[$key] = str_repeat($this->_spaces, $num) . $lines[$key]; - } - - return implode("\n", $lines); - } - - private function _getInheritanceTypeString($type) - { - switch ($type) { - case ClassMetadataInfo::INHERITANCE_TYPE_NONE: - return 'NONE'; - - case ClassMetadataInfo::INHERITANCE_TYPE_JOINED: - return 'JOINED'; - - case ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE: - return 'SINGLE_TABLE'; - - case ClassMetadataInfo::INHERITANCE_TYPE_TABLE_PER_CLASS: - return 'PER_CLASS'; - - default: - throw new \InvalidArgumentException('Invalid provided InheritanceType: ' . $type); - } - } - - private function _getChangeTrackingPolicyString($policy) - { - switch ($policy) { - case ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT: - return 'DEFERRED_IMPLICIT'; - - case ClassMetadataInfo::CHANGETRACKING_DEFERRED_EXPLICIT: - return 'DEFERRED_EXPLICIT'; - - case ClassMetadataInfo::CHANGETRACKING_NOTIFY: - return 'NOTIFY'; - - default: - throw new \InvalidArgumentException('Invalid provided ChangeTrackingPolicy: ' . $policy); - } - } - - private function _getIdGeneratorTypeString($type) - { - switch ($type) { - case ClassMetadataInfo::GENERATOR_TYPE_AUTO: - return 'AUTO'; - - case ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE: - return 'SEQUENCE'; - - case ClassMetadataInfo::GENERATOR_TYPE_TABLE: - return 'TABLE'; - - case ClassMetadataInfo::GENERATOR_TYPE_IDENTITY: - return 'IDENTITY'; - - case ClassMetadataInfo::GENERATOR_TYPE_NONE: - return 'NONE'; - - default: - throw new \InvalidArgumentException('Invalid provided IdGeneratorType: ' . $type); - } - } - -} diff --git a/main/inc/lib/tools/entity_repository_generator.class.php b/main/inc/lib/tools/entity_repository_generator.class.php deleted file mode 100755 index f5a4a70468..0000000000 --- a/main/inc/lib/tools/entity_repository_generator.class.php +++ /dev/null @@ -1,138 +0,0 @@ -. - */ - -namespace Tools; - -use Doctrine\ORM\Mapping\ClassMetadataInfo, - Doctrine\ORM\Mapping\AssociationMapping, - Doctrine\Common\Util\Inflector; - -/** - * Class to generate entity repository classes - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision$ - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - */ -class EntityRepositoryGenerator -{ - - protected static $_template = - ' extends -{ - - /** - * @return \Entity\Repository\ - */ - public static function instance(){ - static $result = false; - if($result === false){ - $result = db::instance()->get_repository(\'\\Entity\\\'); - } - return $result; - } - - /** - * - * @param EntityManager $em The EntityManager to use. - * @param ClassMetadata $class The class descriptor. - */ - public function __construct($em, $class){ - parent::__construct($em, $class); - } - -}'; - - public function generateEntityRepositoryClass($name) - { - $name = Inflector::tableize($name); - $is_course_table = (strpos($name, 'c_') === 0); - if ($is_course_table) { - $name = substr($name, 2, strlen($name) - 2); - } - $name = Inflector::classify($name); - $className = $name; - //$namespace = substr($fullClassName, 0, strrpos($fullClassName, '\\')); - //$className = substr($fullClassName, strrpos($fullClassName, '\\') + 1, strlen($fullClassName)); - - $is_course_table = $metadata->is_course_table; - - - $variables = array( - '' => $namespace, - '' => $className, - '' => str_replace('Repository', '', $className), - '' => $is_course_table ? '\CourseEntityRepository' : '\EntityRepository' - ); - return str_replace(array_keys($variables), array_values($variables), self::$_template); - } - - /** - * - * @param type $name - * @param type $outputDirectory - */ - public function writeEntityRepositoryClass($name, $outputDirectory) - { - $name = explode('\\', $name); - $name = end($name); - $name = Inflector::tableize($name); - $is_course_table = (strpos($name, 'c_') === 0); - if ($is_course_table) { - $name = substr($name, 2, strlen($name) - 2); - } - $name = Inflector::classify($name) . 'Repository'; - $fullClassName = $name; - - $file_name = Inflector::tableize($name); - - $code = $this->generateEntityRepositoryClass($fullClassName); - - $path = $outputDirectory . DIRECTORY_SEPARATOR - . str_replace('\\', \DIRECTORY_SEPARATOR, $file_name) . '.class.php'; - $dir = dirname($path); - - if (!is_dir($dir)) { - mkdir($dir, 0777, true); - } - - if (!file_exists($path)) { - file_put_contents($path, $code); - } - } - -} \ No newline at end of file diff --git a/main/inc/lib/tools/yaml_exporter.class.php b/main/inc/lib/tools/yaml_exporter.class.php deleted file mode 100755 index e56a856b5e..0000000000 --- a/main/inc/lib/tools/yaml_exporter.class.php +++ /dev/null @@ -1,214 +0,0 @@ -. - */ - -namespace Tools; - -use Doctrine\ORM\Mapping\ClassMetadataInfo; -use Doctrine\ORM\Tools\Export\Driver\AbstractExporter; - -/** - * ClassMetadata exporter for Doctrine YAML mapping files - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision$ - * @author Jonathan Wage - */ -class YamlExporter extends AbstractExporter -{ - protected $_extension = '.dcm.yml'; - - /** - * Converts a single ClassMetadata instance to the exported format - * and returns it - * - * TODO: Should this code be pulled out in to a toArray() method in ClassMetadata - * - * @param ClassMetadataInfo $metadata - * @return mixed $exported - */ - public function exportClassMetadata(ClassMetadataInfo $metadata) - { - $array = array(); - - if ($metadata->isMappedSuperclass) { - $array['type'] = 'mappedSuperclass'; - } else { - $array['type'] = 'entity'; - } - - $array['table'] = $metadata->table['name']; - - if (isset($metadata->table['schema'])) { - $array['schema'] = $metadata->table['schema']; - } - - $inheritanceType = $metadata->inheritanceType; - if ($inheritanceType !== ClassMetadataInfo::INHERITANCE_TYPE_NONE) { - $array['inheritanceType'] = $this->_getInheritanceTypeString($inheritanceType); - } - - if ($column = $metadata->discriminatorColumn) { - $array['discriminatorColumn'] = $column; - } - - if ($map = $metadata->discriminatorMap) { - $array['discriminatorMap'] = $map; - } - - if ($metadata->changeTrackingPolicy !== ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT) { - $array['changeTrackingPolicy'] = $this->_getChangeTrackingPolicyString($metadata->changeTrackingPolicy); - } - - if (isset($metadata->table['indexes'])) { - $array['indexes'] = $metadata->table['indexes']; - } - - if ($metadata->customRepositoryClassName) { - $array['repositoryClass'] = $metadata->customRepositoryClassName; - } - - if (isset($metadata->table['uniqueConstraints'])) { - $array['uniqueConstraints'] = $metadata->table['uniqueConstraints']; - } - - $fieldMappings = $metadata->fieldMappings; - - $ids = array(); - foreach ($fieldMappings as $name => $fieldMapping) { - $fieldMapping['column'] = $fieldMapping['columnName']; - unset( - $fieldMapping['columnName'], - $fieldMapping['fieldName'] - ); - - if ($fieldMapping['column'] == $name) { - unset($fieldMapping['column']); - } - - if (isset($fieldMapping['id']) && $fieldMapping['id']) { - $ids[$name] = $fieldMapping; - unset($fieldMappings[$name]); - continue; - } - - $fieldMappings[$name] = $fieldMapping; - } - - if ($idGeneratorType = $this->_getIdGeneratorTypeString($metadata->generatorType)) { - $ids[$metadata->getSingleIdentifierFieldName()]['generator']['strategy'] = $this->_getIdGeneratorTypeString($metadata->generatorType); - }else{ - if(count($metadata->identifier) == 2){ - foreach($metadata->identifier as $identifier){ - if($identifier != 'c_id'){ - $ids[$identifier]['generator']['strategy'] = 'IDENTITY'; - } - } - } - - } - - if ($ids) { - $array['fields'] = $ids; - } - - if ($fieldMappings) { - if ( ! isset($array['fields'])) { - $array['fields'] = array(); - } - $array['fields'] = array_merge($array['fields'], $fieldMappings); - } - - $associations = array(); - foreach ($metadata->associationMappings as $name => $associationMapping) { - $cascade = array(); - if ($associationMapping['isCascadeRemove']) { - $cascade[] = 'remove'; - } - if ($associationMapping['isCascadePersist']) { - $cascade[] = 'persist'; - } - if ($associationMapping['isCascadeRefresh']) { - $cascade[] = 'refresh'; - } - if ($associationMapping['isCascadeMerge']) { - $cascade[] = 'merge'; - } - if ($associationMapping['isCascadeDetach']) { - $cascade[] = 'detach'; - } - if (count($cascade) === 5) { - $cascade = array('all'); - } - $associationMappingArray = array( - 'targetEntity' => $associationMapping['targetEntity'], - 'cascade' => $cascade, - ); - - if ($associationMapping['type'] & ClassMetadataInfo::TO_ONE) { - $joinColumns = $associationMapping['joinColumns']; - $newJoinColumns = array(); - foreach ($joinColumns as $joinColumn) { - $newJoinColumns[$joinColumn['name']]['referencedColumnName'] = $joinColumn['referencedColumnName']; - if (isset($joinColumn['onDelete'])) { - $newJoinColumns[$joinColumn['name']]['onDelete'] = $joinColumn['onDelete']; - } - } - $oneToOneMappingArray = array( - 'mappedBy' => $associationMapping['mappedBy'], - 'inversedBy' => $associationMapping['inversedBy'], - 'joinColumns' => $newJoinColumns, - 'orphanRemoval' => $associationMapping['orphanRemoval'], - ); - - $associationMappingArray = array_merge($associationMappingArray, $oneToOneMappingArray); - $array['oneToOne'][$name] = $associationMappingArray; - } else if ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_MANY) { - $oneToManyMappingArray = array( - 'mappedBy' => $associationMapping['mappedBy'], - 'inversedBy' => $associationMapping['inversedBy'], - 'orphanRemoval' => $associationMapping['orphanRemoval'], - 'orderBy' => isset($associationMapping['orderBy']) ? $associationMapping['orderBy'] : null - ); - - $associationMappingArray = array_merge($associationMappingArray, $oneToManyMappingArray); - $array['oneToMany'][$name] = $associationMappingArray; - } else if ($associationMapping['type'] == ClassMetadataInfo::MANY_TO_MANY) { - $manyToManyMappingArray = array( - 'mappedBy' => $associationMapping['mappedBy'], - 'inversedBy' => $associationMapping['inversedBy'], - 'joinTable' => isset($associationMapping['joinTable']) ? $associationMapping['joinTable'] : null, - 'orderBy' => isset($associationMapping['orderBy']) ? $associationMapping['orderBy'] : null - ); - - $associationMappingArray = array_merge($associationMappingArray, $manyToManyMappingArray); - $array['manyToMany'][$name] = $associationMappingArray; - } - } - if (isset($metadata->lifecycleCallbacks)) { - $array['lifecycleCallbacks'] = $metadata->lifecycleCallbacks; - } - - return \Symfony\Component\Yaml\Yaml::dump(array($metadata->name => $array), 10); - } -} diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index 3edecf8e47..82f29fbcfb 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -1,9 +1,9 @@ '.COURSE_RELATION_TYPE_RRHH; $rs = Database::query($sql); $nb_courses = Database::num_rows($rs); if ($include_sessions) { - $sql = 'SELECT DISTINCT course_code + $sql = 'SELECT DISTINCT c_id FROM ' . $tbl_session_course_rel_user . ' - WHERE id_user = ' . $user_id; + WHERE user_id = ' . $user_id; $rs = Database::query($sql); $nb_courses += Database::num_rows($rs); } @@ -1871,16 +1871,19 @@ class Tracking $sessionId = intval($sessionId); $courseId = intval($courseId); + $sessionCourseUserTable = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); + $sessionTable = Database::get_main_table(TABLE_MAIN_SESSION); + //get teachers - $sql = "SELECT scu.id_session, scu.id_user, s.name - FROM session_rel_course_rel_user scu, session s + $sql = "SELECT scu.session_id, scu.user_id, s.name + FROM $sessionCourseUserTable scu, $sessionTable s WHERE - scu.id_session = s.id + scu.session_id = s.id AND scu.status = 2 AND scu.visibility = 1 - AND scu.course_code = '%s' - AND scu.id_session = %s"; - $query = sprintf($sql,$course['code'], $sessionId); + AND scu.c_id = '%s' + AND scu.session_id = %s"; + $query = sprintf($sql, intval($courseId), $sessionId); $rs = Database::query($query); $teachers = array(); while ($teacher = Database::fetch_array($rs,'ASSOC')) { @@ -1894,11 +1897,11 @@ class Tracking WHERE lastedit_type = 'DocumentAdded' AND c_id = %s AND insert_user_id = %s - AND id_session = %s"; + AND session_id = %s"; $query = sprintf($sql, $courseId, - $teacher['id_user'], - $teacher['id_session'] + $teacher['user_id'], + $teacher['session_id'] ); $rs = Database::query($query); @@ -1913,11 +1916,11 @@ class Tracking WHERE lastedit_type = 'LinkAdded' AND c_id = %s AND insert_user_id = %s - AND id_session = %s"; + AND session_id = %s"; $query = sprintf($sql, $courseId, - $teacher['id_user'], - $teacher['id_session'] + $teacher['user_id'], + $teacher['session_id'] ); $rs = Database::query($query); @@ -1932,11 +1935,11 @@ class Tracking WHERE lastedit_type = 'ForumthreadVisible' AND c_id = %s AND insert_user_id = %s - AND id_session = %s"; + AND session_id = %s"; $query = sprintf($sql, $courseId, - $teacher['id_user'], - $teacher['id_session'] + $teacher['user_id'], + $teacher['session_id'] ); $rs = Database::query($query); @@ -1951,11 +1954,11 @@ class Tracking WHERE lastedit_type = 'WikiAdded' AND c_id = %s AND insert_user_id = %s - AND id_session = %s"; + AND session_id = %s"; $query = sprintf($sql, $courseId, - $teacher['id_user'], - $teacher['id_session'] + $teacher['user_id'], + $teacher['session_id'] ); $rs = Database::query($query); @@ -1971,11 +1974,11 @@ class Tracking AND tool = 'work' AND c_id = %s AND insert_user_id = %s - AND id_session = %s"; + AND session_id = %s"; $query = sprintf($sql, $courseId, - $teacher['id_user'], - $teacher['id_session'] + $teacher['user_id'], + $teacher['session_id'] ); $rs = Database::query($query); @@ -1990,11 +1993,11 @@ class Tracking WHERE lastedit_type = 'AnnouncementAdded' AND c_id = %s AND insert_user_id = %s - AND id_session = %s"; + AND session_id = %s"; $query = sprintf($sql, $courseId, - $teacher['id_user'], - $teacher['id_session'] + $teacher['user_id'], + $teacher['session_id'] ); $rs = Database::query($query); @@ -2003,7 +2006,7 @@ class Tracking $row = Database::fetch_row($rs); $totalAnnouncements = $row[0]; } - $tutor = api_get_user_info($teacher['id_user']); + $tutor = api_get_user_info($teacher['user_id']); $data[] = array( 'course' => $course['title'], 'session' => $teacher['name'], @@ -2660,20 +2663,20 @@ class Tracking $a_students = array (); // At first, courses where $coach_id is coach of the course // - $sql = 'SELECT id_session, course_code + $sql = 'SELECT session_id, c_id FROM ' . $tbl_session_course_user . ' - WHERE id_user=' . $coach_id.' AND status=2'; + WHERE user_id=' . $coach_id.' AND status=2'; if (api_is_multiple_url_enabled()) { $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { - $sql = 'SELECT scu.id_session, scu.course_code + $sql = 'SELECT scu.session_id, scu.c_id FROM ' . $tbl_session_course_user . ' scu INNER JOIN '.$tbl_session_rel_access_url.' sru - ON (scu.id_session=sru.session_id) + ON (scu.session_id=sru.session_id) WHERE - scu.id_user=' . $coach_id.' AND + scu.user_id=' . $coach_id.' AND scu.status=2 AND sru.access_url_id = '.$access_url_id; } @@ -2682,59 +2685,61 @@ class Tracking $result = Database::query($sql); while ($a_courses = Database::fetch_array($result)) { - $course_code = $a_courses["course_code"]; - $id_session = $a_courses["id_session"]; + $courseId = $a_courses["c_id"]; + $id_session = $a_courses["session_id"]; - $sql = "SELECT distinct srcru.id_user + $sql = "SELECT DISTINCT srcru.user_id FROM $tbl_session_course_user AS srcru, $tbl_session_user sru WHERE - srcru.id_user = sru.id_user AND + srcru.user_id = sru.user_id AND sru.relation_type<>".SESSION_RELATION_TYPE_RRHH." AND - srcru.id_session = sru.id_session AND - srcru.course_code='$course_code' AND - srcru.id_session='$id_session'"; + srcru.session_id = sru.session_id AND + srcru.c_id = '$courseId' AND + srcru.session_id='$id_session'"; $rs = Database::query($sql); while ($row = Database::fetch_array($rs)) { - $a_students[$row['id_user']] = $row['id_user']; + $a_students[$row['user_id']] = $row['user_id']; } } // Then, courses where $coach_id is coach of the session // - - $sql = 'SELECT session_course_user.id_user + $sql = 'SELECT session_course_user.user_id FROM ' . $tbl_session_course_user . ' as session_course_user - INNER JOIN '.$tbl_session_user.' sru ON session_course_user.id_user = sru.id_user AND session_course_user.id_session = sru.id_session + INNER JOIN '.$tbl_session_user.' sru + ON session_course_user.user_id = sru.user_id AND session_course_user.session_id = sru.session_id INNER JOIN ' . $tbl_session_course . ' as session_course - ON session_course.course_code = session_course_user.course_code - AND session_course_user.id_session = session_course.id_session + ON session_course.c_id = session_course_user.c_id + AND session_course_user.session_id = session_course.session_id INNER JOIN ' . $tbl_session . ' as session - ON session.id = session_course.id_session + ON session.id = session_course.session_id AND session.id_coach = ' . $coach_id; if (api_is_multiple_url_enabled()) { $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1){ - $sql = 'SELECT session_course_user.id_user - FROM ' . $tbl_session_course_user . ' as session_course_user - INNER JOIN '.$tbl_session_user.' sru - ON session_course_user.id_user = sru.id_user AND - session_course_user.id_session = sru.id_session - INNER JOIN ' . $tbl_session_course . ' as session_course - ON session_course.course_code = session_course_user.course_code AND - session_course_user.id_session = session_course.id_session - INNER JOIN ' . $tbl_session . ' as session - ON session.id = session_course.id_session AND - session.id_coach = ' . $coach_id.' - INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url - ON session.id = session_rel_url.session_id WHERE access_url_id = '.$access_url_id; + $sql = 'SELECT session_course_user.user_id + FROM ' . $tbl_session_course_user . ' as session_course_user + INNER JOIN '.$tbl_session_user.' sru + ON session_course_user.user_id = sru.user_id AND + session_course_user.session_id = sru.session_id + INNER JOIN ' . $tbl_session_course . ' as session_course + ON session_course.c_id = session_course_user.c_id AND + session_course_user.session_id = session_course.session_id + INNER JOIN ' . $tbl_session . ' as session + ON session.id = session_course.session_id AND + session.id_coach = ' . $coach_id.' + INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url + ON session.id = session_rel_url.session_id WHERE access_url_id = '.$access_url_id; } } + $result = Database::query($sql); while ($row = Database::fetch_array($result)) { - $a_students[$row['id_user']] = $row['id_user']; + $a_students[$row['user_id']] = $row['user_id']; } + return $a_students; } @@ -2752,20 +2757,21 @@ class Tracking $a_students = array (); // At first, courses where $coach_id is coach of the course // - $sql = 'SELECT course_code FROM ' . $tbl_session_course_user . ' WHERE id_session="' . $id_session . '" AND id_user=' . $coach_id.' AND status=2'; + $sql = 'SELECT c_id FROM ' . $tbl_session_course_user . ' + WHERE session_id="' . $id_session . '" AND user_id=' . $coach_id.' AND status=2'; $result = Database::query($sql); while ($a_courses = Database::fetch_array($result)) { - $course_code = $a_courses["course_code"]; + $courseId = $a_courses["c_id"]; - $sql = "SELECT distinct srcru.id_user + $sql = "SELECT DISTINCT srcru.user_id FROM $tbl_session_course_user AS srcru WHERE - course_code='$course_code' AND - id_session = '" . $id_session . "'"; + c_id = '$courseId' AND + session_id = '" . $id_session . "'"; $rs = Database::query($sql); while ($row = Database::fetch_array($rs)) { - $a_students[$row['id_user']] = $row['id_user']; + $a_students[$row['user_id']] = $row['user_id']; } } @@ -2775,14 +2781,15 @@ class Tracking $result = Database::query($sql); //He is the session_coach so we select all the users in the session if (Database::num_rows($result) > 0) { - $sql = 'SELECT DISTINCT srcru.id_user + $sql = 'SELECT DISTINCT srcru.user_id FROM ' . $tbl_session_course_user . ' AS srcru - WHERE id_session="' . $id_session . '"'; + WHERE session_id="' . $id_session . '"'; $result = Database::query($sql); while ($row = Database::fetch_array($result)) { - $a_students[$row['id_user']] = $row['id_user']; + $a_students[$row['user_id']] = $row['user_id']; } } + return $a_students; } @@ -2803,24 +2810,27 @@ class Tracking // At first, courses where $coach_id is coach of the course // - $sql = 'SELECT 1 FROM ' . $tbl_session_course_user . ' WHERE id_user=' . $coach_id .' AND status=2'; + $sql = 'SELECT 1 FROM ' . $tbl_session_course_user . ' + WHERE user_id=' . $coach_id .' AND status=2'; $result = Database::query($sql); if (Database::num_rows($result) > 0) { return true; } + // Then, courses where $coach_id is coach of the session - $sql = 'SELECT session_course_user.id_user + $sql = 'SELECT session_course_user.user_id FROM ' . $tbl_session_course_user . ' as session_course_user INNER JOIN ' . $tbl_session_course . ' as session_course - ON session_course.course_code = session_course_user.course_code + ON session_course.c_id = session_course_user.c_id INNER JOIN ' . $tbl_session . ' as session - ON session.id = session_course.id_session + ON session.id = session_course.session_id AND session.id_coach = ' . $coach_id . ' - WHERE id_user = ' . $student_id; + WHERE user_id = ' . $student_id; $result = Database::query($sql); if (Database::num_rows($result) > 0) { return true; } + return false; } @@ -2841,65 +2851,71 @@ class Tracking $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); + $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); // At first, courses where $coach_id is coach of the course. - $sql = 'SELECT DISTINCT course_code - FROM ' . $tbl_session_course_user . ' - WHERE id_user = ' . $coach_id.' AND status = 2'; + $sql = 'SELECT DISTINCT c.code + FROM ' . $tbl_session_course_user . ' sc + INNER JOIN '.$tbl_course.' c + ON (c.id = sc.c_id) + WHERE user_id = ' . $coach_id.' AND status = 2'; if (api_is_multiple_url_enabled()) { - $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 DISTINCT scu.course_code + $sql = 'SELECT DISTINCT c.code FROM ' . $tbl_session_course_user . ' scu + INNER JOIN '.$tbl_course.' c + ON (c.code = scu.c_id) INNER JOIN '.$tbl_course_rel_access_url.' cru - ON (scu.course_code = cru.course_code) + ON (c.id = cru.c_id) WHERE - scu.id_user=' . $coach_id.' AND + scu.user_id=' . $coach_id.' AND scu.status=2 AND cru.access_url_id = '.$access_url_id; } } if (!empty($id_session)) { - $sql .= ' AND id_session=' . $id_session; + $sql .= ' AND session_id=' . $id_session; } $courseList = array(); $result = Database::query($sql); while ($row = Database::fetch_array($result)) { - $courseList[$row['course_code']] = $row['course_code']; + $courseList[$row['code']] = $row['code']; } // Then, courses where $coach_id is coach of the session - $sql = 'SELECT DISTINCT session_course.course_code + $sql = 'SELECT DISTINCT course.code FROM ' . $tbl_session_course . ' as session_course INNER JOIN ' . $tbl_session . ' as session - ON session.id = session_course.id_session + ON session.id = session_course.session_id AND session.id_coach = ' . $coach_id . ' INNER JOIN ' . $tbl_course . ' as course - ON course.code = session_course.course_code'; + ON course.id = session_course.c_id'; if (api_is_multiple_url_enabled()) { - $tbl_course_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); + $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 DISTINCT session_course.course_code + $sql = 'SELECT DISTINCT c.code FROM ' . $tbl_session_course . ' as session_course + INNER JOIN '.$tbl_course.' c + ON (c.id = session_course.c_id) INNER JOIN ' . $tbl_session . ' as session - ON session.id = session_course.id_session + ON session.id = session_course.session_id AND session.id_coach = ' . $coach_id . ' INNER JOIN ' . $tbl_course . ' as course - ON course.code = session_course.course_code + ON course.id = session_course.c_id INNER JOIN '.$tbl_course_rel_access_url.' course_rel_url - ON (session_course.course_code = course_rel_url.course_code)'; + ON (course_rel_url.c_id = c.id)'; } } if (!empty ($id_session)) { - $sql .= ' WHERE session_course.id_session=' . $id_session; + $sql .= ' WHERE session_course.session_id=' . $id_session; if (api_is_multiple_url_enabled()) $sql .= ' AND access_url_id = '.$access_url_id; } else { @@ -2909,7 +2925,7 @@ class Tracking $result = Database::query($sql); while ($row = Database::fetch_array($result)) { - $courseList[$row['course_code']] = $row['course_code']; + $courseList[$row['code']] = $row['code']; } return $courseList; @@ -2977,8 +2993,8 @@ class Tracking SELECT DISTINCT session.id, session.name, session.date_start, session.date_end FROM $tbl_session as session INNER JOIN $tbl_session_course_user as session_course_user - ON session.id = session_course_user.id_session AND - session_course_user.id_user= $coach_id AND + ON session.id = session_course_user.session_id AND + session_course_user.user_id= $coach_id AND session_course_user.status=2 INNER JOIN $tbl_session_rel_access_url session_rel_url ON (session.id = session_rel_url.session_id) @@ -3037,24 +3053,31 @@ class Tracking // table definition $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE); + $courseTable = Database :: get_main_table(TABLE_MAIN_COURSE); - $sql = 'SELECT DISTINCT course_code - FROM ' . $tbl_session_course . ' - WHERE id_session=' . $session_id; + $sql = "SELECT DISTINCT code, c_id + FROM $tbl_session_course sc + INNER JOIN $courseTable c + sc.c_id = c.id + WHERE session_id= $session_id"; - $rs = Database::query($sql); - $a_courses = array (); - while ($row = Database::fetch_array($rs)) { - $a_courses[$row['course_code']] = $row; + $result = Database::query($sql); + + $courses = array(); + while ($row = Database::fetch_array($result)) { + $courses[$row['code']] = $row; } - return $a_courses; + + return $courses; } /** * Count the number of documents that an user has uploaded to a course * @param int|array Student id(s) * @param string Course code - * @param int Session id (optional), if param $session_id is null(default) return count of assignments including sessions, 0 = session is not filtered + * @param int Session id (optional), + * if param $session_id is null(default) + * return count of assignments including sessions, 0 = session is not filtered * @return int Number of documents */ public static function count_student_uploaded_documents($student_id, $course_code, $session_id = null) @@ -3099,7 +3122,9 @@ class Tracking * Count assignments per student * @param int|array Student id(s) * @param string Course code - * @param int Session id (optional), if param $session_id is null(default) return count of assignments including sessions, 0 = session is not filtered + * @param int Session id (optional), + * if param $session_id is null(default) return count of assignments + * including sessions, 0 = session is not filtered * @return int Count of assignments */ public static function count_student_assignments($student_id, $course_code = null, $session_id = null) @@ -3199,7 +3224,9 @@ class Tracking /** * This function counts the number of post by course * @param string Course code - * @param int Session id (optional), if param $session_id is null(default) it'll return results including sessions, 0 = session is not filtered + * @param int Session id (optional), if param $session_id is + * null(default) it'll return results including sessions, + * 0 = session is not filtered * @return int The number of post by course */ public static function count_number_of_posts_by_course($course_code, $session_id = null) @@ -3235,7 +3262,9 @@ class Tracking /** * This function counts the number of threads by course * @param string Course code - * @param int Session id (optional), if param $session_id is null(default) it'll return results including sessions, 0 = session is not filtered + * @param int Session id (optional), + * if param $session_id is null(default) it'll return results including + * sessions, 0 = session is not filtered * @return int The number of threads by course */ public static function count_number_of_threads_by_course($course_code, $session_id = null) @@ -3268,7 +3297,9 @@ class Tracking /** * This function counts the number of forums by course * @param string Course code - * @param int Session id (optional), if param $session_id is null(default) it'll return results including sessions, 0 = session is not filtered + * @param int Session id (optional), + * if param $session_id is null(default) it'll return results + * including sessions, 0 = session is not filtered * @return int The number of forums by course */ public static function count_number_of_forums_by_course($course_code, $session_id = null) @@ -3429,17 +3460,21 @@ class Tracking $user_id = intval($user_id); $id_session = intval($id_session); $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); - $sql = 'SELECT course_code - FROM ' . $tbl_session_course_user . ' + $courseTable = Database :: get_main_table(TABLE_MAIN_COURSE); + + $sql = "SELECT c.code + FROM $tbl_session_course_user sc + INNER JOIN $courseTable c WHERE - id_user="' . $user_id . '" AND - id_session="' . $id_session . '"'; + user_id= $user_id AND + session_id = $id_session"; $result = Database::query($sql); - $a_courses = array (); + $courses = array(); while ($row = Database::fetch_array($result)) { - $a_courses[$row['course_code']] = $row['course_code']; + $courses[$row['code']] = $row['code']; } - return $a_courses; + + return $courses; } /** @@ -3457,11 +3492,15 @@ class Tracking $tableCourse = Database :: get_main_table(TABLE_MAIN_COURSE); $inner = ''; $now = api_get_utc_datetime(); - if ($session_id!=0) { + + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + + if ($session_id != 0) { $inner = ' INNER JOIN '.$tbl_session_course_user.' session_course_user - ON c.code = session_course_user.course_code - AND session_course_user.id_session = '.intval($session_id).' - AND session_course_user.id_user = stats_login.user_id '; + ON c.id = session_course_user.c_id + AND session_course_user.session_id = '.intval($session_id).' + AND session_course_user.user_id = stats_login.user_id '; } $sql = 'SELECT user_id, MAX(login_course_date) max_date FROM '.$tbl_track_login.' stats_login '.$inner.' @@ -3479,7 +3518,7 @@ class Tracking INNER JOIN '.$tableCourse.' c ON (c.id = stats_login.c_id) '.$inner.' - WHERE course_user.course_code = \''.Database::escape_string($course_code).'\' + WHERE course_user.c_id = \''.$courseId.'\' AND stats_login.login_course_date IS NULL GROUP BY course_user.user_id'; } @@ -3660,7 +3699,9 @@ class Tracking /** * get count clicks about tools most used by course * @param int $courseId - * @param int Session id (optional), if param $session_id is null(default) it'll return results including sessions, 0 = session is not filtered + * @param int Session id (optional), + * if param $session_id is null(default) it'll return results + * including sessions, 0 = session is not filtered * @return array tools data */ public static function get_tools_most_used_by_course($courseId, $session_id = null) @@ -3766,9 +3807,6 @@ class Tracking 'user' => 'upload_user_id', 'start_date'=> 'upload_date', ), - #TABLE_STATISTIC_TRACK_E_HOTSPOT, - #TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY, - #TABLE_STATISTIC_TRACK_E_OPEN, ); $error_sql = ''; @@ -3823,7 +3861,9 @@ class Tracking /** * get documents most downloaded by course * @param string Course code - * @param int Session id (optional), if param $session_id is null(default) it'll return results including sessions, 0 = session is not filtered + * @param int Session id (optional), + * if param $session_id is null(default) it'll return results including + * sessions, 0 = session is not filtered * @param int Limit (optional, default = 0, 0 = without limit) * @return array documents downloaded */ @@ -3859,7 +3899,9 @@ class Tracking /** * get links most visited by course * @param string Course code - * @param int Session id (optional), if param $session_id is null(default) it'll return results including sessions, 0 = session is not filtered + * @param int Session id (optional), + * if param $session_id is null(default) it'll + * return results including sessions, 0 = session is not filtered * @return array links most visited */ public static function get_links_most_visited_by_course($course_code, $session_id = null) @@ -3919,19 +3961,21 @@ class Tracking $user_id = intval($user_id); if (api_is_multiple_url_enabled()) { - $sql = "SELECT cu.course_code as code, title - FROM $tbl_course_user cu INNER JOIN $tbl_access_rel_course a - ON (a.course_code = cu.course_code) - INNER JOIN $tbl_course c ON (cu.course_code = c.code) + $sql = "SELECT c.code, title + FROM $tbl_course_user cu + INNER JOIN $tbl_course c + ON (cu.c_id = c.id) + INNER JOIN $tbl_access_rel_course a + ON (a.c_id = c.id) WHERE - user_id = $user_id AND + cu.user_id = $user_id AND relation_type<> ".COURSE_RELATION_TYPE_RRHH." AND access_url_id = ".api_get_current_access_url_id()." ORDER BY title"; } else { - $sql = "SELECT course_code as code, title + $sql = "SELECT c.code, title FROM $tbl_course_user u - INNER JOIN $tbl_course c ON (course_code = c.code) + INNER JOIN $tbl_course c ON (c_id = c.id) WHERE u.user_id= $user_id AND relation_type<>".COURSE_RELATION_TYPE_RRHH." @@ -3940,7 +3984,7 @@ class Tracking $rs = Database::query($sql); $courses = $course_in_session = $temp_course_in_session = array(); - while($row = Database :: fetch_array($rs, 'ASSOC')) { + while ($row = Database :: fetch_array($rs, 'ASSOC')) { $courses[$row['code']] = $row['title']; } @@ -3950,34 +3994,41 @@ class Tracking if (!empty($session_id)) { $orderBy = " ORDER BY s.id, position "; $tableSessionRelCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); - $extraInnerJoin = " INNER JOIN $tableSessionRelCourse src ON (cu.course_code = src.course_code AND src.id_session = $session_id) "; + $extraInnerJoin = " INNER JOIN $tableSessionRelCourse src + ON (cu.c_id = src.c_id AND src.session_id = $session_id) "; } // Get the list of sessions where the user is subscribed as student if (api_is_multiple_url_enabled()) { - $sql = "SELECT DISTINCT cu.course_code, s.id as session_id, name + $sql = "SELECT DISTINCT c.code, s.id as session_id, name FROM $tbl_session_course_user cu INNER JOIN $tbl_access_rel_session a - ON (a.session_id = cu.id_session) - INNER JOIN $tbl_session s ON (s.id = a.session_id) + ON (a.session_id = cu.session_id) + INNER JOIN $tbl_session s + ON (s.id = a.session_id) + INNER JOIN $tbl_course c + ON (c.id = cu.c_id) $extraInnerJoin WHERE - id_user = $user_id AND + cu.user_id = $user_id AND access_url_id = ".api_get_current_access_url_id()." $orderBy "; } else { - $sql = "SELECT DISTINCT cu.course_code, s.id as session_id, name + $sql = "SELECT DISTINCT c.code, s.id as session_id, name FROM $tbl_session_course_user cu - INNER JOIN $tbl_session s ON (s.id = cu.id_session) + INNER JOIN $tbl_session s + ON (s.id = cu.session_id) + INNER JOIN $tbl_course c + ON (c.id = cu.c_id) $extraInnerJoin - WHERE id_user = $user_id + WHERE cu.user_id = $user_id $orderBy "; } $rs = Database::query($sql); $simple_session_array = array(); while ($row = Database :: fetch_array($rs)) { - $course_info = CourseManager::get_course_information($row['course_code']); + $course_info = CourseManager::get_course_information($row['code']); $temp_course_in_session[$row['session_id']]['course_list'][$course_info['id']] = $course_info; $temp_course_in_session[$row['session_id']]['name'] = $row['name']; $simple_session_array[$row['session_id']] = $row['name']; @@ -4353,7 +4404,7 @@ class Tracking $weighting = 0; $last_connection = Tracking :: get_last_connection_date_on_the_course($user_id, $courseId, $session_id_from_get); - $progress = Tracking :: get_avg_student_progress($user_id, $course_code,array(), $session_id_from_get); + $progress = Tracking :: get_avg_student_progress($user_id, $course_code, array(), $session_id_from_get); $total_time_login = Tracking :: get_time_spent_on_the_course($user_id, $courseId, $session_id_from_get); $time = api_time_to_hms($total_time_login); $percentage_score = Tracking :: get_avg_student_score($user_id, $course_code, array(), $session_id_from_get); @@ -4366,7 +4417,7 @@ class Tracking } $url = api_get_course_url($course_code, $session_id_from_get); - $course_url = Display::url($course_title, $url, array('target'=>SESSION_LINK_TARGET)); + $course_url = Display::url($course_title, $url, array('target' => SESSION_LINK_TARGET)); $html .= Display::tag('td', $course_url); $html .= Display::tag('td', $stats_array[$course_code]['exercises']); @@ -5226,7 +5277,7 @@ class Tracking // if, to the contrary, course is defined but not sessions, get the sessions that include this course // $sessions is an array like: [0] => ('id' => 3, 'name' => 'Session 35'), [1] => () etc; $course = api_get_course_info_by_id($courseId); - $sessionsTemp = SessionManager::get_session_by_course($course['code']); + $sessionsTemp = SessionManager::get_session_by_course($courseId); $courses[$courseId] = $course; foreach ($sessionsTemp as $sessionItem) { $sessions[$sessionItem['id']] = $sessionItem; @@ -5433,7 +5484,7 @@ class TrackingCourseLog WHERE track_resource.c_id = $course_id AND track_resource.insert_user_id = user.user_id AND - id_session = $session_id "; + session_id = $session_id "; if (isset($_GET['keyword'])) { $keyword = Database::escape_string(trim($_GET['keyword'])); @@ -5490,7 +5541,7 @@ class TrackingCourseLog WHERE track_resource.c_id = $course_id AND track_resource.insert_user_id = user.user_id AND - id_session = $session_id "; + session_id = $session_id "; if (isset($_GET['keyword'])) { $keyword = Database::escape_string(trim($_GET['keyword'])); @@ -5543,7 +5594,8 @@ class TrackingCourseLog if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) { $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC); - $sql = "SELECT thematic_id FROM $table_tool WHERE c_id = $course_id AND id = $ref"; + $sql = "SELECT thematic_id FROM $table_tool + WHERE c_id = $course_id AND id = $ref"; $rs_thematic = Database::query($sql); if (Database::num_rows($rs_thematic)) { $row_thematic = Database::fetch_array($rs_thematic); @@ -5619,14 +5671,18 @@ class TrackingCourseLog WHERE c_id = $course_id AND id = $ref"; $rs_document = Database::query($sql); $obj_document = Database::fetch_object($rs_document); - $row[5] = $obj_document->title; + if ($obj_document) { + $row[5] = $obj_document->title; + } break; case 'glossary': $sql = "SELECT name FROM $table_tool WHERE c_id = $course_id AND glossary_id = $ref"; $rs_document = Database::query($sql); $obj_document = Database::fetch_object($rs_document); - $row[5] = $obj_document->name; + if ($obj_document) { + $row[5] = $obj_document->name; + } break; case 'lp': $sql = "SELECT name @@ -5640,14 +5696,18 @@ class TrackingCourseLog WHERE c_id = $course_id AND id = $ref"; $rs_document = Database::query($sql); $obj_document = Database::fetch_object($rs_document); - $row[5] = $obj_document->title; + if ($obj_document) { + $row[5] = $obj_document->title; + } break; case 'course_description': $sql = "SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref"; $rs_document = Database::query($sql); $obj_document = Database::fetch_object($rs_document); - $row[5] = $obj_document->title; + if ($obj_document) { + $row[5] = $obj_document->title; + } break; case 'thematic': $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref"); @@ -5680,9 +5740,11 @@ class TrackingCourseLog } $row[2] = $row2; if (!empty($row['col3'])) { + $userInfo = api_get_user_info($row['user_id']); + $row['col3'] = Display::url( $row['col3'], - api_get_path(WEB_CODE_PATH).'user/userInfo.php?'.api_get_cidreq().'&origin=tracking&uInfo='.$row['user_id'] + $userInfo['profile_url'] ); $row[3] = $row['col3']; @@ -6019,11 +6081,11 @@ class TrackingCourseLog if (empty($session_id)) { $survey_user_list = array(); - $survey_list = survey_manager::get_surveys($course_code, $session_id); + $survey_list = SurveyManager::get_surveys($course_code, $session_id); $total_surveys = count($survey_list); foreach ($survey_list as $survey) { - $user_list = survey_manager::get_people_who_filled_survey( + $user_list = SurveyManager::get_people_who_filled_survey( $survey['survey_id'], false, $course_info['real_id'] diff --git a/main/inc/lib/uri.class.php b/main/inc/lib/uri.class.php deleted file mode 100755 index e75b5e6636..0000000000 --- a/main/inc/lib/uri.class.php +++ /dev/null @@ -1,104 +0,0 @@ - for the Univesity of Geneva - */ -class Uri -{ - - public static function chamilo() - { - return 'http://chamilo.org/'; - } - - /** - * Application web root - */ - public static function www() - { - static $result = false; - if (empty($result)) { - $result = api_get_path(WEB_PATH); - } - return $result; - } - - public static function here($params = array(), $html = true) - { - $protocol = Request::server()->server_protocol(); - $protocol = stripos($protocol, 'https') !== false ? 'https' : 'http'; - - $host = Request::server()->server_name(); - $host = $host ? $host : Request::server()->server_addr(); - - $here = Request::server()->request_uri(); - $here = explode('?', $here); - $here = reset($here); - $here = $protocol . '://' . $host . $here; - return self::url($here, $params, $html); - } - - /** - * Returns a full url from local/absolute path and parameters. - * Append the root as required for relative urls. - * - * @param string $path - * @param array $params - * @return string - */ - public static function url($path = '', $params = array(), $html = true) - { - $result = $path; - if (strpos($result, 'http') !== 0) - { - $result = ltrim($result, '/'); - $result = self::www() . $result; - } - if ($params) - { - - $result = rtrim($result, '?'); - $result = $result . '?' . self::params($params, $html); - } - return $result; - } - - /** - * Format url parameters - * - * @param array $params - * @return string - */ - public static function params($params = array(), $html = true) - { - $result = array(); - foreach ($params as $key => $value) - { - $result[] = $key . '=' . urlencode($value); - } - $result = implode($html ? '&' : '&', $result); - return $result; - } - - /** - * Returns the course parameters. If null default to the current user parameters. - * - * @param string $course_code - * @param string|int $session_id - * @param string|int $group_id - * @return type - */ - public static function course_params($course_code = null, $session_id = null, $group_id = null) - { - $course_code = is_null($course_code) ? api_get_course_id() : $course_code; - $session_id = is_null($session_id) ? api_get_session_id() : $session_id; - $session_id = $session_id ? $session_id : '0'; - $group_id = is_null($group_id) ? '' : $group_id; - $group_id = $group_id ? $group_id : '0'; - return array('cidReq' => $course_code, 'id_session' => $session_id, 'gidReq' => $group_id); - } - -} diff --git a/main/inc/lib/urlmanager.lib.php b/main/inc/lib/urlmanager.lib.php index 4cc8261e1a..bd4fa133ac 100755 --- a/main/inc/lib/urlmanager.lib.php +++ b/main/inc/lib/urlmanager.lib.php @@ -190,41 +190,42 @@ class UrlManager **/ public static function get_url_rel_course_data($access_url_id = null) { - $where =''; - $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); - $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE); + $where = ''; + $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); + $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE); if (!empty($access_url_id)) { - $where ="WHERE $table_url_rel_course.access_url_id = ".intval($access_url_id); + $where = " WHERE uc.access_url_id = ".intval($access_url_id); } - $sql = "SELECT course_code, title, access_url_id + $sql = "SELECT u.id, c_id, title, uc.access_url_id FROM $tbl_course u - INNER JOIN $table_url_rel_course - ON $table_url_rel_course.course_code = code + INNER JOIN $table_url_rel_course uc + ON uc.c_id = u.id $where ORDER BY title, code"; - $result=Database::query($sql); - $courses=Database::store_result($result); + $result = Database::query($sql); + $courses = Database::store_result($result); + return $courses; } /** * Gets the number of rows with a specific course_code in access_url_rel_course table * @author Yoselyn Castillo - * @param string code + * @param int $courseId * @return int Database::num_rows($res); - * **/ - public static function getCountUrlRelCourse($code) + public static function getCountUrlRelCourse($courseId) { - $code = Database::escape_string($code); + $courseId = intval($courseId); $tableUrlRelCourse = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $sql = "SELECT * FROM $tableUrlRelCourse - WHERE $tableUrlRelCourse.course_code = '$code'"; + WHERE c_id = '$courseId'"; $res = Database::query($sql); + return Database::num_rows($res); } @@ -296,7 +297,6 @@ class UrlManager public static function getUrlRelCourseCategory($access_url_id = null) { - $table_url_rel = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY); $table = Database::get_main_table(TABLE_MAIN_CATEGORY); $where = " WHERE 1=1 "; @@ -361,18 +361,20 @@ class UrlManager /** * Checks the relationship between an URL and a Course (return the num_rows) * @author Julio Montoya - * @param int user id - * @param int url id + * @param int $courseId + * @param int $urlId * @return boolean true if success * */ - public static function relation_url_course_exist($course_id, $url_id) + public static function relation_url_course_exist($courseId, $urlId) { - $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); - $sql= "SELECT course_code FROM $table_url_rel_course - WHERE access_url_id = ".intval($url_id)." AND - course_code = '".Database::escape_string($course_id)."'"; + $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); + $sql= "SELECT c_id FROM $table_url_rel_course + WHERE + access_url_id = ".intval($urlId)." AND + c_id = '".intval($courseId)."'"; $result = Database::query($sql); $num = Database::num_rows($result); + return $num; } @@ -384,7 +386,7 @@ class UrlManager * @param int $urlId * @return boolean true if success * */ - public static function relation_url_usergroup_exist($userGroupId, $urlId) + public static function relationUrlUsergroupExist($userGroupId, $urlId) { $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP); $sql= "SELECT usergroup_id FROM $table @@ -456,16 +458,19 @@ class UrlManager **/ public static function add_courses_to_urls($course_list,$url_list) { - $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); + $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $result_array = array(); if (is_array($course_list) && is_array($url_list)){ foreach ($url_list as $url_id) { foreach ($course_list as $course_code) { - $count = self::relation_url_course_exist($course_code,$url_id); + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + + $count = self::relation_url_course_exist($courseId, $url_id); if ($count==0) { $sql = "INSERT INTO $table_url_rel_course - SET course_code = '".Database::escape_string($course_code)."', access_url_id = ".intval($url_id); + SET c_id = '".$courseId."', access_url_id = ".intval($url_id); $result = Database::query($sql); if($result) $result_array[$url_id][$course_code]=1; @@ -475,6 +480,7 @@ class UrlManager } } } + return $result_array; } @@ -491,7 +497,7 @@ class UrlManager if (is_array($userGroupList) && is_array($urlList)) { foreach ($urlList as $urlId) { foreach ($userGroupList as $userGroupId) { - $count = self::relation_url_usergroup_exist($userGroupId, $urlId); + $count = self::relationUrlUsergroupExist($userGroupId, $urlId); if ($count == 0) { $result = self::addUserGroupToUrl($userGroupId, $urlId); if ($result) { @@ -653,20 +659,20 @@ class UrlManager } /** - * @param string $course_code + * @param int $courseId * @param int $url_id * @return resource */ - public static function add_course_to_url($course_code, $url_id=1) + public static function add_course_to_url($courseId, $url_id = 1) { - $table_url_rel_course= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); + $table_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); if (empty($url_id)) { $url_id = 1; } - $count = UrlManager::relation_url_course_exist($course_code,$url_id); + $count = UrlManager::relation_url_course_exist($courseId, $url_id); if (empty($count)) { $sql = "INSERT INTO $table_url_rel_course - SET course_code = '".Database::escape_string($course_code)."', access_url_id = ".intval($url_id); + SET c_id = '".intval($courseId)."', access_url_id = ".intval($url_id); $result = Database::query($sql); } @@ -721,15 +727,17 @@ class UrlManager /** * Deletes an url and course relationship * @author Julio Montoya - * @param char course code - * @param int url id + * @param id $courseId + * @param int $urlId * @return boolean true if success * */ - public static function delete_url_rel_course($course_code, $url_id) + public static function delete_url_rel_course($courseId, $urlId) { $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); - $sql= "DELETE FROM $table_url_rel_course WHERE course_code = '".Database::escape_string($course_code)."' AND access_url_id=".intval($url_id)." "; + $sql= "DELETE FROM $table_url_rel_course + WHERE c_id = '".intval($courseId)."' AND access_url_id=".intval($url_id)." "; $result = Database::query($sql); + return $result; } @@ -835,36 +843,35 @@ class UrlManager /** * Updates the access_url_rel_course table with a given user list * @author Julio Montoya - * @param array user list + * @param array $course_list * @param int access_url_id * */ - public static function update_urls_rel_course($course_list,$access_url_id) + public static function update_urls_rel_course($course_list, $access_url_id) { - $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); + $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); - $sql = "SELECT course_code FROM $table_url_rel_course WHERE access_url_id=".intval($access_url_id); + $sql = "SELECT c_id FROM $table_url_rel_course + WHERE access_url_id = ".intval($access_url_id); $result = Database::query($sql); - $existing_courses = array(); - while($row = Database::fetch_array($result)){ - $existing_courses[] = $row['course_code']; + $existing_courses = array(); + while ($row = Database::fetch_array($result)){ + $existing_courses[] = $row['c_id']; } // Adding courses foreach ($course_list as $course_code) { - if(!in_array($course_code, $existing_courses)) { - UrlManager::add_course_to_url($course_code, $access_url_id); - $course_info = api_get_course_info($course_code); - CourseManager::update_course_ranking($course_info['real_id'], 0, $access_url_id); + if (!in_array($course_code, $courseId)) { + UrlManager::add_course_to_url($courseId, $access_url_id); + CourseManager::update_course_ranking($courseId, 0, $access_url_id); } } // Deleting old courses - foreach ($existing_courses as $existing_course) { - if(!in_array($existing_course, $course_list)) { - UrlManager::delete_url_rel_course($existing_course,$access_url_id); - $course_info = api_get_course_info($existing_course); - CourseManager::update_course_ranking($course_info['real_id'], 0, $access_url_id); + foreach ($existing_courses as $courseId) { + if (!in_array($courseId, $course_list)) { + UrlManager::delete_url_rel_course($courseId, $access_url_id); + CourseManager::update_course_ranking($courseId, 0, $access_url_id); } } } diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index 7d804218be..8fc7e7a78a 100755 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -44,22 +44,25 @@ class UserManager * Creates a new user for the platform * @author Hugues Peeters , * @author Roan Embrechts - * @param string Firstname - * @param string Lastname - * @param int Status (1 for course tutor, 5 for student, 6 for anonymous) - * @param string e-mail address - * @param string Login - * @param string Password - * @param string Any official code (optional) - * @param string User language (optional) - * @param string Phone number (optional) - * @param string Picture URI (optional) - * @param string Authentication source (optional, defaults to 'platform', dependind on constant) - * @param string Account expiration date (optional, defaults to null) - * @param int Whether the account is enabled or disabled by default - * @param int The department of HR in which the user is registered (optional, defaults to 0) - * @param array Extra fields - * @param string Encrypt method used if password is given encrypted. Set to an empty string by default + * @param string Firstname + * @param string Lastname + * @param int Status (1 for course tutor, 5 for student, 6 for anonymous) + * @param string e-mail address + * @param string Login + * @param string Password + * @param string Any official code (optional) + * @param string User language (optional) + * @param string Phone number (optional) + * @param string Picture URI (optional) + * @param string Authentication source (optional, defaults to 'platform', dependind on constant) + * @param string Account expiration date (optional, defaults to null) + * @param int Whether the account is enabled or disabled by default + * @param int The department of HR in which the user is registered (optional, defaults to 0) + * @param array Extra fields + * @param string Encrypt method used if password is given encrypted. Set to an empty string by default + * @param bool $send_mail + * @param bool $isAdmin + * * @return mixed new user id - if the new user creation succeeds, false otherwise * @desc The function tries to retrieve user id from the session. * If it exists, the current user id is the creator id. If a problem arises, @@ -84,7 +87,8 @@ class UserManager $hr_dept_id = 0, $extra = null, $encrypt_method = '', - $send_mail = false + $send_mail = false, + $isAdmin = false ) { $currentUserId = api_get_user_id(); $hook = HookCreateUser::create(); @@ -206,6 +210,10 @@ class UserManager $sql = "UPDATE $table_user SET user_id = $return WHERE id = $return"; Database::query($sql); + if ($isAdmin) { + UserManager::add_user_as_admin($userId); + } + if (api_get_multiple_access_url()) { UrlManager::add_user_to_url($return, api_get_current_access_url_id()); } else { @@ -238,10 +246,9 @@ class UserManager EventsDispatcher::events('user_registration', $values); } else { $phoneNumber = isset($extra['mobile_phone_number']) ? $extra['mobile_phone_number'] : null; - $plugin = new AppPlugin(); $additionalParameters = array( - 'smsType' => constant($plugin->getSMSPluginName().':: WELCOME_LOGIN_PASSWORD'), + 'smsType' => SmsPlugin::WELCOME_LOGIN_PASSWORD, 'userId' => $return, 'mobilePhoneNumber' => $phoneNumber, 'password' => $original_password @@ -304,16 +311,18 @@ class UserManager return false; } $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - if ($user_id != strval(intval($user_id))) + if ($user_id != strval(intval($user_id))) { return false; - if ($user_id === false) + } + if ($user_id === false) { return false; + } $sql = "SELECT * FROM $table_course_user WHERE status = '1' AND user_id = '".$user_id."'"; $res = Database::query($sql); while ($course = Database::fetch_object($res)) { $sql = "SELECT user_id FROM $table_course_user - WHERE status='1' AND course_code ='".Database::escape_string($course->course_code)."'"; + WHERE status='1' AND c_id ='".Database::escape_string($course->c_id)."'"; $res2 = Database::query($sql); if (Database::num_rows($res2) == 1) { return false; @@ -362,7 +371,7 @@ class UserManager WHERE cu.user_id = '".$user_id."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." AND - c.code = cu.course_code"; + c.id = cu.c_id"; $res = Database::query($sql); while ($course = Database::fetch_object($res)) { $sql = "DELETE FROM $table_group @@ -384,7 +393,7 @@ class UserManager Database::query($sql); // Unsubscribe user from all courses in sessions - $sql = "DELETE FROM $table_session_course_user WHERE id_user = '".$user_id."'"; + $sql = "DELETE FROM $table_session_course_user WHERE user_id = '".$user_id."'"; Database::query($sql); // If the user was added as a id_coach then set the current admin as coach see BT# @@ -396,7 +405,7 @@ class UserManager Database::query($sql); // Unsubscribe user from all sessions - $sql = "DELETE FROM $table_session_user WHERE id_user = '".$user_id."'"; + $sql = "DELETE FROM $table_session_user WHERE user_id = '".$user_id."'"; Database::query($sql); // Delete user picture @@ -457,7 +466,7 @@ class UserManager } // Removing survey invitation - survey_manager::delete_all_survey_invitations_by_user($user_id); + SurveyManager::delete_all_survey_invitations_by_user($user_id); // Delete students works $sql = "DELETE FROM $table_work WHERE user_id = $user_id AND c_id <> 0"; @@ -1197,30 +1206,6 @@ class UserManager return false; } - /** - * Get the teacher list - * @param int the course ID - * @param array Content the list ID of user_id selected - */ - //for survey - // TODO: Ivan, 14-SEP-2009: It seems that this method is not used at all (it can be located in a test unit only. To be deprecated? - public static function get_teacher_list($course_id, $sel_teacher = '') - { - $user_course_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - $user_table = Database :: get_main_table(TABLE_MAIN_USER); - $course_id = Database::escape_string($course_id); - $sql = "SELECT * FROM $user_table a, $user_course_table b - WHERE a.user_id=b.user_id AND b.status=1 AND b.course_code='$course_id'"; - $sql_result = Database::query($sql); - echo ""; - } - /** * Get user picture URL or path from user ID (returns an array). * The return format is a complete path, enabling recovery of the directory @@ -2517,9 +2502,9 @@ class UserManager LEFT JOIN $tbl_session_category session_category ON (session_category_id = session_category.id) LEFT JOIN $tbl_session_course_user as session_rel_course_user - ON (session_rel_course_user.id_session = session.id) + ON (session_rel_course_user.session_id = session.id) WHERE ( - session_rel_course_user.id_user = $user_id OR + session_rel_course_user.user_id = $user_id OR session.id_coach = $user_id ) ORDER BY session_category_name, name"; @@ -2587,7 +2572,7 @@ class UserManager // Checking session visibility $visibility = api_get_session_visibility( $session_id, - $course['code'], + $course['real_id'], $ignore_visibility_for_admins ); @@ -2653,7 +2638,7 @@ class UserManager $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); - $join_access_url = "LEFT JOIN $tbl_url_course url_rel_course ON url_rel_course.course_code= course.code"; + $join_access_url = "LEFT JOIN $tbl_url_course url_rel_course ON url_rel_course.c_id = course.id"; $where_access_url = " AND access_url_id = $access_url_id "; } } @@ -2668,7 +2653,7 @@ class UserManager course_rel_user.user_course_cat user_course_cat FROM ".$tbl_course_user." course_rel_user LEFT JOIN ".$tbl_course." course - ON course.code = course_rel_user.course_code + ON course.id = course_rel_user.c_id LEFT JOIN ".$tbl_user_course_category." user_course_category ON course_rel_user.user_course_cat = user_course_category.id $join_access_url @@ -2695,14 +2680,14 @@ class UserManager if (api_is_allowed_to_create_course()) { $sessionListFromCourseCoach = array(); - $sql =" SELECT DISTINCT id_session FROM $tbl_session_course_user - WHERE id_user = $user_id AND status = 2 "; + $sql =" SELECT DISTINCT session_id FROM $tbl_session_course_user + WHERE user_id = $user_id AND status = 2 "; $result = Database::query($sql); if (Database::num_rows($result)) { $result = Database::store_result($result); foreach ($result as $session) { - $sessionListFromCourseCoach[]= $session['id_session']; + $sessionListFromCourseCoach[]= $session['session_id']; } } if (!empty($sessionListFromCourseCoach)) { @@ -2714,11 +2699,11 @@ class UserManager // Get the list of sessions where the user is subscribed // This is divided into two different queries $sessions = array(); - $sql = "SELECT DISTINCT id, name, date_start, date_end - FROM $tbl_session_user, $tbl_session + $sql = "SELECT DISTINCT s.id, name, date_start, date_end + FROM $tbl_session_user, $tbl_session s WHERE ( - id_session = id AND - id_user = $user_id AND + session_id = s.id AND + user_id = $user_id AND relation_type <> ".SESSION_RELATION_TYPE_RRHH." ) $coachCourseConditions @@ -2769,18 +2754,18 @@ class UserManager category_code user_course_cat, date_start, date_end, - session.id as id_session, + session.id as session_id, session.name as session_name FROM $tbl_session_course_user as session_course_user INNER JOIN $tbl_course AS course - ON course.code = session_course_user.course_code + ON course.id = session_course_user.c_id INNER JOIN $tbl_session as session - ON session.id = session_course_user.id_session + ON session.id = session_course_user.session_id LEFT JOIN $tbl_user as user - ON user.user_id = session_course_user.id_user OR session.id_coach = user.user_id + ON user.user_id = session_course_user.user_id OR session.id_coach = user.user_id WHERE - session_course_user.id_session = $id_session AND ( - (session_course_user.id_user = $user_id AND session_course_user.status = 2) + session_course_user.session_id = $id_session AND ( + (session_course_user.user_id = $user_id AND session_course_user.status = 2) OR session.id_coach = $user_id ) ORDER BY i"; @@ -2788,7 +2773,7 @@ class UserManager while ($result_row = Database::fetch_array($course_list_sql_result, 'ASSOC')) { $result_row['course_info'] = api_get_course_info($result_row['code']); - $key = $result_row['id_session'].' - '.$result_row['code']; + $key = $result_row['session_id'].' - '.$result_row['code']; $personal_course_list[$key] = $result_row; } } @@ -2812,22 +2797,22 @@ class UserManager category_code user_course_cat, date_start, date_end, - session.id as id_session, + session.id as session_id, session.name as session_name, - IF((session_course_user.id_user = 3 AND session_course_user.status=2),'2', '5') + IF((session_course_user.user_id = 3 AND session_course_user.status=2),'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 = $session_id - INNER JOIN $tbl_session as session ON session_course_user.id_session = session.id - LEFT JOIN $tbl_user as user ON user.user_id = session_course_user.id_user - WHERE session_course_user.id_user = $user_id + ON course.id = session_course_user.c_id AND session_course_user.session_id = $session_id + INNER JOIN $tbl_session as session ON session_course_user.session_id = session.id + LEFT JOIN $tbl_user as user ON user.user_id = session_course_user.user_id + WHERE session_course_user.user_id = $user_id ORDER BY i"; $course_list_sql_result = Database::query($personal_course_list_sql); while ($result_row = Database::fetch_array($course_list_sql_result, 'ASSOC')) { $result_row['course_info'] = api_get_course_info($result_row['code']); - $key = $result_row['id_session'].' - '.$result_row['code']; + $key = $result_row['session_id'].' - '.$result_row['code']; if (!isset($personal_course_list[$key])) { $personal_course_list[$key] = $result_row; } @@ -2846,10 +2831,10 @@ class UserManager public static function get_courses_list_by_session($user_id, $session_id) { // Database Table Definitions - $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); - $tableCourse = Database :: get_main_table(TABLE_MAIN_COURSE); - $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); - $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE); + $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); + $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); + $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); + $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $user_id = intval($user_id); $session_id = intval($session_id); @@ -2857,11 +2842,11 @@ class UserManager $join_access_url = $where_access_url = ''; if (api_get_multiple_access_url()) { - $access_url_id = api_get_current_access_url_id(); - if ($access_url_id != -1) { + $urlId = api_get_current_access_url_id(); + if ($urlId != -1) { $tbl_url_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); $join_access_url = " , $tbl_url_session url_rel_session "; - $where_access_url = " AND access_url_id = $access_url_id AND url_rel_session.session_id = $session_id "; + $where_access_url = " AND access_url_id = $urlId AND url_rel_session.session_id = $session_id "; } } @@ -2873,46 +2858,47 @@ class UserManager to our user or not */ $sql = "SELECT DISTINCT - scu.course_code as code, c.visibility, c.id as real_id + c.visibility, + c.id as real_id FROM $tbl_session_course_user as scu INNER JOIN $tbl_session_course sc - ON (scu.id_session = sc.id_session AND scu.course_code = sc.course_code) + ON (scu.session_id = sc.session_id AND scu.c_id = sc.c_id) INNER JOIN $tableCourse as c - ON (scu.course_code = c.code) + ON (scu.c_id = c.id) $join_access_url WHERE - scu.id_user = $user_id AND - scu.id_session = $session_id + scu.user_id = $user_id AND + scu.session_id = $session_id $where_access_url ORDER BY sc.position ASC"; $result = Database::query($sql); if (Database::num_rows($result) > 0) { - while ($result_row = Database::fetch_array($result)) { + while ($result_row = Database::fetch_array($result, 'ASSOC')) { $result_row['status'] = 5; - if (!in_array($result_row['code'], $courses)) { + if (!in_array($result_row['real_id'], $courses)) { $personal_course_list[] = $result_row; - $courses[] = $result_row['code']; + $courses[] = $result_row['real_id']; } } } if (api_is_allowed_to_create_course()) { $sql = "SELECT DISTINCT - scu.course_code as code, c.visibility, c.id as real_id + c.visibility, c.id as real_id FROM $tbl_session_course_user as scu INNER JOIN $tbl_session as s - ON (scu.id_session = s.id) + ON (scu.session_id = s.id) INNER JOIN $tbl_session_course sc - ON (scu.id_session = sc.id_session AND scu.course_code = sc.course_code) + ON (scu.session_id = sc.session_id AND scu.c_id = sc.c_id) INNER JOIN $tableCourse as c - ON (scu.course_code = c.code) + ON (scu.c_id = c.id) $join_access_url WHERE s.id = $session_id AND ( - (scu.id_user=$user_id AND scu.status=2) OR + (scu.user_id=$user_id AND scu.status=2) OR s.id_coach = $user_id ) $where_access_url @@ -2920,11 +2906,11 @@ class UserManager $result = Database::query($sql); if (Database::num_rows($result) > 0) { - while ($result_row = Database::fetch_array($result)) { + while ($result_row = Database::fetch_array($result, 'ASSOC')) { $result_row['status'] = 2; - if (!in_array($result_row['code'], $courses)) { + if (!in_array($result_row['real_id'], $courses)) { $personal_course_list[] = $result_row; - $courses[] = $result_row['code']; + $courses[] = $result_row['real_id']; } } } @@ -2946,9 +2932,10 @@ class UserManager $s = api_get_session_info($session_id); if ($s['id_coach'] == $user_id) { $course_list = SessionManager::get_course_list_by_session_id($session_id); + if (!empty($course_list)) { foreach ($course_list as $course) { - if (!in_array($course['code'], $courses)) { + if (!in_array($course['id'], $courses)) { $personal_course_list[] = $course; } } @@ -3994,7 +3981,7 @@ class UserManager $access_url_id = api_get_current_access_url_id(); $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"; + $join_access_url = "LEFT JOIN $tbl_url_course url_rel_course ON url_rel_course.c_id = course.id"; $where_access_url = " AND access_url_id = $access_url_id "; } @@ -4013,17 +4000,17 @@ class UserManager $course_list = array(); if (!empty($code_special_courses)) { - $course_list_sql = "SELECT course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, course.tutor_name t, course.course_language l, course_rel_user.status s, course_rel_user.sort sort, course_rel_user.user_course_cat user_course_cat - FROM ".$tbl_course_user." course_rel_user - LEFT JOIN ".$tbl_course." course - ON course.code = course_rel_user.course_code - LEFT JOIN ".$tbl_user_course_category." user_course_category - ON course_rel_user.user_course_cat = user_course_category.id - $join_access_url - WHERE $code_special_courses $where_access_url - GROUP BY course.code - ORDER BY user_course_category.sort,course.title,course_rel_user.sort ASC"; - $course_list_sql_result = Database::query($course_list_sql); + $sql = "SELECT course.code k, course.directory d, course.visual_code c, course.title i, course.tutor_name t, course.course_language l, course_rel_user.status s, course_rel_user.sort sort, course_rel_user.user_course_cat user_course_cat + FROM ".$tbl_course_user." course_rel_user + LEFT JOIN ".$tbl_course." course + ON course.id = course_rel_user.c_id + LEFT JOIN ".$tbl_user_course_category." user_course_category + ON course_rel_user.user_course_cat = user_course_category.id + $join_access_url + WHERE $code_special_courses $where_access_url + GROUP BY course.code + ORDER BY user_course_category.sort,course.title,course_rel_user.sort ASC"; + $course_list_sql_result = Database::query($sql); while ($result_row = Database::fetch_array($course_list_sql_result)) { $course_list[] = $result_row; } @@ -4322,16 +4309,16 @@ class UserManager "; $sessionConditionsTeacher .= " AND - (scu.status = 2 AND scu.id_user = '$userId') + (scu.status = 2 AND scu.user_id = '$userId') "; $teacherSelect = "UNION ALL ( $select FROM $tbl_user u - INNER JOIN $tbl_session_rel_user sru ON (sru.id_user = u.user_id) + INNER JOIN $tbl_session_rel_user sru ON (sru.user_id = u.user_id) WHERE - sru.id_session IN ( + sru.session_id IN ( SELECT DISTINCT(s.id) FROM $tbl_session s INNER JOIN $tbl_session_rel_access_url WHERE access_url_id = ".api_get_current_access_url_id()." @@ -4341,7 +4328,7 @@ class UserManager INNER JOIN $tbl_session_rel_access_url url ON (url.session_id = s.id) INNER JOIN $tbl_session_rel_course_rel_user scu - ON (scu.id_session = s.id) + ON (scu.session_id = s.id) WHERE access_url_id = ".api_get_current_access_url_id()." $sessionConditionsTeacher ) @@ -4352,8 +4339,8 @@ class UserManager $select FROM $tbl_user u INNER JOIN $tbl_course_user cu ON (cu.user_id = u.user_id) - WHERE cu.course_code IN ( - SELECT DISTINCT(course_code) FROM $tbl_course_user + WHERE cu.c_id IN ( + SELECT DISTINCT(c_id) FROM $tbl_course_user WHERE user_id = $userId AND status = ".COURSEMANAGER." ) $userConditions @@ -4519,21 +4506,26 @@ class UserManager /** * get user id of teacher or session administrator - * @param string The course id + * @param array $courseInfo + * * @return int The user id */ - public static function get_user_id_of_course_admin_or_session_admin($course_id) + public static function get_user_id_of_course_admin_or_session_admin($courseInfo) { $session = api_get_session_id(); $table_user = Database::get_main_table(TABLE_MAIN_USER); $table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); $table_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); + $courseId = $courseInfo['real_id']; + $courseCode = $courseInfo['code']; + if ($session == 0 || is_null($session)) { $sql = 'SELECT u.user_id FROM '.$table_user.' u - INNER JOIN '.$table_course_user.' ru ON ru.user_id=u.user_id + INNER JOIN '.$table_course_user.' ru + ON ru.user_id=u.user_id WHERE ru.status = 1 AND - ru.course_code = "'.Database::escape_string($course_id).'" '; + ru.c_id = "'.$courseId.'" '; $rs = Database::query($sql); $num_rows = Database::num_rows($rs); if ($num_rows == 1) { @@ -4547,9 +4539,9 @@ class UserManager } elseif ($session > 0) { $sql = 'SELECT u.user_id FROM '.$table_user.' u INNER JOIN '.$table_session_course_user.' sru - ON sru.id_user=u.user_id + ON sru.user_id=u.user_id WHERE - sru.course_code="'.Database::escape_string($course_id).'" AND + sru.course_code="'.Database::escape_string($courseCode).'" AND sru.status=2'; $rs = Database::query($sql); $row = Database::fetch_array($rs); @@ -4656,25 +4648,25 @@ class UserManager /** * This function check if the user is a coach inside session course * @param int User id - * @param string Course code + * @param int $courseId * @param int Session id * @return bool True if the user is a coach * */ - public static function is_session_course_coach($user_id, $course_code, $session_id) + public static function is_session_course_coach($user_id, $courseId, $session_id) { $tbl_session_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); // Protect data $user_id = intval($user_id); - $course_code = Database::escape_string($course_code); + $courseId = intval($courseId); $session_id = intval($session_id); $result = false; - $sql = "SELECT id_session FROM $tbl_session_course_rel_user + $sql = "SELECT session_id FROM $tbl_session_course_rel_user WHERE - id_session=$session_id AND - course_code='$course_code' AND - id_user = $user_id AND + session_id=$session_id AND + c_id='$courseId' AND + user_id = $user_id AND status = 2 "; $res = Database::query($sql); @@ -5337,4 +5329,30 @@ EOF; } return $userPath; } + + /** + * Displays the name of the user and makes the link to the user profile + * @param $userInfo + */ + public static function getUserProfileLink($userInfo) + { + if (isset($userInfo) && isset($userInfo['user_id'])) { + return Display::url($userInfo['complete_name'], $userInfo['profile_url']); + } else { + return get_lang('Anonymous'); + } + } + + /** + * Displays the name of the user and makes the link to the user profile + * @param $userInfo + * @todo + */ + public static function getUserProfileLinkWithPicture($userInfo) + { + $imagePath = UserManager::get_user_picture_path_by_id($userInfo['user_id'], 'web', false, true); + $userProfile = UserManager::get_picture_user($userInfo['user_id'], $imagePath['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" '); + + return Display::url(Display::img($userProfile['file']), $userInfo['profile_url']); + } } diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index 40b08772f0..3d384ddbf5 100755 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -1,8 +1,6 @@ , Ghent University - refactoring and code cleaning * @author Julio Montoya , Beeznest template modifs */ - function return_courses_in_categories() { + function return_courses_in_categories() + { $result = ''; $stok = Security::get_token(); @@ -416,13 +415,17 @@ class IndexManager // Showing only the courses of the current access_url_id. global $_configuration; - if ($_configuration['multiple_access_urls']) { + if (api_is_multiple_url_enabled()) { $url_access_id = api_get_current_access_url_id(); if ($url_access_id != -1) { $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); - $sql_get_course_list = "SELECT * FROM $main_course_table as course INNER JOIN $tbl_url_rel_course as url_rel_course - ON (url_rel_course.course_code=course.code) - WHERE access_url_id = $url_access_id AND category_code = '".Database::escape_string($_GET['category'])."' ORDER BY title, UPPER(visual_code)"; + $sql_get_course_list = "SELECT * FROM $main_course_table as course + INNER JOIN $tbl_url_rel_course as url_rel_course + ON (url_rel_course.c_id = course.id) + WHERE + access_url_id = $url_access_id AND + category_code = '".Database::escape_string($_GET['category'])."' + ORDER BY title, UPPER(visual_code)"; } } @@ -478,9 +481,9 @@ class IndexManager FROM $main_category_table t1 $courseCategoryCondition LEFT JOIN $main_category_table t2 ON t1.code = t2.parent_id - LEFT JOIN $main_course_table t3 ON (t3.category_code=t1.code $platform_visible_courses) + LEFT JOIN $main_course_table t3 ON (t3.category_code = t1.code $platform_visible_courses) INNER JOIN $tbl_url_rel_course as url_rel_course - ON (url_rel_course.course_code=t3.code) + ON (url_rel_course.c_id = t3.id) WHERE url_rel_course.access_url_id = $url_access_id AND t1.parent_id ".(empty($category) ? "IS NULL" : "='$category'")." GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name"; } @@ -650,25 +653,47 @@ class IndexManager * @param int $user_id: the id of the user * @return array an array containing all the information of the courses of the given user */ - function get_courses_of_user($user_id) { - $table_course = Database::get_main_table(TABLE_MAIN_COURSE); - $table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); + public function get_courses_of_user($user_id) + { + $table_course = Database::get_main_table(TABLE_MAIN_COURSE); + $table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); // Secondly we select the courses that are in a category (user_course_cat <> 0) and sort these according to the sort of the category $user_id = intval($user_id); - $sql_select_courses = "SELECT course.code k, course.visual_code vc, course.subscribe subscr, course.unsubscribe unsubscr, - course.title i, course.tutor_name t, course.db_name db, course.directory dir, course_rel_user.status status, - course_rel_user.sort sort, course_rel_user.user_course_cat user_course_cat - FROM $table_course course, - $table_course_user course_rel_user - WHERE course.code = course_rel_user.course_code - AND course_rel_user.user_id = '".$user_id."' - AND course_rel_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." - ORDER BY course_rel_user.sort ASC"; + $sql_select_courses = "SELECT + course.code k, + course.visual_code vc, + course.subscribe subscr, + course.unsubscribe unsubscr, + course.title i, + course.tutor_name t, + course.directory dir, + course_rel_user.status status, + course_rel_user.sort sort, + course_rel_user.user_course_cat user_course_cat + FROM + $table_course course, + $table_course_user course_rel_user + WHERE + course.id = course_rel_user.c_id AND + course_rel_user.user_id = '".$user_id."' AND + course_rel_user.relation_type <> ".COURSE_RELATION_TYPE_RRHH." + ORDER BY course_rel_user.sort ASC"; $result = Database::query($sql_select_courses); $courses = array(); while ($row = Database::fetch_array($result)) { // We only need the database name of the course. - $courses[$row['k']] = array('db' => $row['db'], 'code' => $row['k'], 'visual_code' => $row['vc'], 'title' => $row['i'], 'directory' => $row['dir'], 'status' => $row['status'], 'tutor' => $row['t'], 'subscribe' => $row['subscr'], 'unsubscribe' => $row['unsubscr'], 'sort' => $row['sort'], 'user_course_category' => $row['user_course_cat']); + $courses[$row['k']] = array( + 'code' => $row['k'], + 'visual_code' => $row['vc'], + 'title' => $row['i'], + 'directory' => $row['dir'], + 'status' => $row['status'], + 'tutor' => $row['t'], + 'subscribe' => $row['subscr'], + 'unsubscribe' => $row['unsubscr'], + 'sort' => $row['sort'], + 'user_course_category' => $row['user_course_cat'] + ); } return $courses; } @@ -1088,7 +1113,7 @@ class IndexManager $atLeastOneCourseIsVisible = false; foreach ($session['courses'] as $course) { - $is_coach_course = api_is_coach($session_id, $course['code']); + $is_coach_course = api_is_coach($session_id, $course['real_id']); $allowed_time = 0; $dif_time_after = 0; if ($date_session_start != '0000-00-00') { diff --git a/main/inc/lib/xht.lib.php b/main/inc/lib/xht.lib.php deleted file mode 100755 index 6652c11d84..0000000000 --- a/main/inc/lib/xht.lib.php +++ /dev/null @@ -1,552 +0,0 @@ - - - - - - -*/ - -/** -* This is an XML HTML template library. -* Include/require it in your code to use its functionality. -* -* This library defines function xht_htmlwchars & class xhtdoc with methods: -* - xht_fill_template($template_name) -* - xht_substitute($subtext) -* -* Check htt_error after defining a new xhtdoc(htt_file_contents). -* -* Assign xht_xmldoc (, xht_get_lang, xht_resource, xht_dbgn) -* before calling the class methods. -* -* @package chamilo.library -*/ - - - -function xht_htmlwchars($s) // use only where ISO-8859-1 is not required! -{ - //return ereg_replace('\[((/?(b|big|i|small|sub|sup|u))|br/)\]', '<\\1>', - // str_replace('@�@', '&', - // htmlspecialchars(ereg_replace('&#([0-9]+);', '@�@#\\1;', $s)))); - global $charset; - return api_ereg_replace('\[((/?(b|big|i|small|sub|sup|u))|br/)\]', '<\\1>', - str_replace('@�@', '&', - htmlspecialchars(api_ereg_replace('&#([0-9]+);', '@�@#\\1;', $s), ENT_QUOTES, $charset))); - // replaces htmlspecialchars for double-escaped xml chars like '&#nnn;' - // and when html tags <...> are represented as [...] -} - -function xht_is_assoclist($s) // ":key1:value1,, key2:value2,, ..." -{ - return is_string($s) && strpos($s, ',,'); -} - -function xht_explode_assoclist($s) -{ - $result = array(); if (!xht_is_assoclist($s)) return $result; - - foreach (explode(',,', api_substr($s, 1)) as $keyplusvalue) - if ($cp = api_strpos($keyplusvalue, api_substr($s, 0, 1))) - $result[trim(api_substr($keyplusvalue, 0, $cp))] = - api_substr($keyplusvalue, $cp+1); - - return $result; -} - - -class xhtdoc -{ - -var $htt_array; // array with HTML templates -var $htt_error; // error while parsing htt_file_contents to templates - -var $xht_xmldoc; // XML Mini-DOM document for which templates are processed -var $xht_param; // parameter array for template processing -var $xht_get_lang; // user-supplied function for {-L xx-}, e.g. Dokeos get_lang -var $xht_resource; // user-supplied function for '=/' in path - -var $xht_dbgn; // set to a positive value for debugging output -var $xht_dbgo; // debugging output accumulates here - -var $_prev_param; // old parameter values - - -function xht_fill_template($template_name, $cur_elem = 0) -{ - $template_name = trim($template_name); - if (!$template_name || (api_strpos($template_name, ' ') !== FALSE)) return ''; - if (!is_string($httext = $this->htt_array[$template_name])) return ''; - - if ($this->xht_dbgn) $this->xht_dbgo .= '\n"; - - $prev_lpp = 0; $prev_sub = ''; $scanpos = 0; - - while (($rpp = api_strpos($httext, XHT_RP, $scanpos)) !== FALSE) // first -} - { - if (($lpp = api_strpos($httext, XHT_LP)) === FALSE) break; // no {- for -} - if ($lpp > $rpp) break; // no {- preceding -} - - while (($next_lpp = api_strpos($httext, XHT_LP, $lpp + XHT_PL)) !== FALSE) - if ($next_lpp > $rpp) break; - else $lpp = $next_lpp; // find {- closest to -} - - $subtext = api_substr($httext, $lpp + XHT_PL, $rpp - $lpp - XHT_PL); - - $httext = api_substr($httext, 0, $lpp) . - $this->xht_substitute($subtext, $cur_elem, XHT_LP, XHT_RP) . - api_substr($httext, $rpp + XHT_PL); // substitute or leave intact - - if ($lpp == $prev_lpp && $subtext == $prev_sub) // prevent looping - { - $scanpos = $rpp + 1; $prev_lpp = 0; $prev_sub = ''; - } - else - { - $prev_lpp = $lpp; $prev_sub = $subtext; - } - } - - return $httext; -} - - -function xht_substitute($subtext, $cur_elem = 0, $pre = '', $post = '') -{ - global $charset; - - $regs = array(); // for use with ereg() - if (!api_ereg(XHT_SUBS2, $subtext, $regs) && !api_ereg(XHT_SUBS1, $subtext, $regs)) - return $pre . $subtext . $post; - - $type = $regs[1]; $text = $regs[2]; $result = ''; $subnum = FALSE; - $subtext = isset($regs[3]) ? $regs[3] : ''; - - if ($this->xht_dbgn) // generate debugging output, with new number $subnum - { - $subnum = ++ $this->xht_dbgn; - $this->xht_dbgo .= '\n"; - } - - if ($type == 'D') // Define, e.g. {-D key value-} - { - // Assign the value to parameter [key] - $this->xht_param[$text] = $subtext; - // used to be: = $this->xht_substitute($subtext, $cur_elem); - } - elseif ($type == 'E') // Escape, e.g. {-E userFunction subtext-} - { - $result = call_user_func($text, FALSE); // get cached result, if any - - if ($result === FALSE) // no cached result available - { - $result = $this->xht_substitute($subtext, $cur_elem); - $result = call_user_func($text, $result); // allow to cache - } - } - elseif ($type == 'R') // Repeat, e.g. {-R general/title/string subtext-} - { - $rdepthn = 'rdepth' . (++ $this->xht_param['rdepth']); - $n = 0; $this->xht_param['number'] = '0'; - - if (is_array($a = $this->_lang($text, $cur_elem))) // repeat on array - { - foreach ($a as $key => $value) - { - $this->xht_param['number'] = (string) (++ $n); - $this->xht_param[$rdepthn] = (string) ($n); - $this->xht_param['key'] = $key; - $this->xht_param['value'] = $value; - $result .= $this->xht_substitute($subtext, $cur_elem); - } - } - elseif (xht_is_assoclist($a)) // repeat on associative list - { - foreach (xht_explode_assoclist($a) as $key => $value) - { - $this->xht_param['number'] = (string) (++ $n); - $this->xht_param[$rdepthn] = (string) ($n); - $this->xht_param['key'] = $key; - $this->xht_param['value'] = $value; - $result .= $this->xht_substitute($subtext, $cur_elem); - } - } - elseif (!is_object($this->xht_xmldoc)) - { - $result = '? R Error: no XML doc has been assigned to xht_xmldoc'; - } - else // repeat on XML elements - { - $sub_elems = - $this->xht_xmldoc->xmd_select_elements($text, $cur_elem); - - foreach ($sub_elems as $subElem) - { - $this->xht_param['number'] = (string) (++ $n); - $this->xht_param[$rdepthn] = (string) ($n); - $result .= $this->xht_substitute($subtext, $subElem); - } - } - // removed 2004/10/05: template_array (security) - // added 2005/03/08: associative list (lang arrays deprecated) - - $this->xht_param['rdepth'] --; - - // As there is only one ['number'] or one set ['key'] + ['value'], - // using them in nested repeats may not have the desired result. - } - elseif ($type == 'T') // Test, e.g. {-T key1 == key2 text-} - { - if (api_ereg('^(=|==|<=|<|!=|<>|>|>=) +([^ ]+) +(.*)$', $subtext, $regs)) - { - // Comparand= parameter value if set, else languagevar value - - $cmp1 = isset($this->xht_param[$text]) ? - $this->xht_param[$text] : $this->_lang($text, $cur_elem); - $cmp3 = isset($this->xht_param[$cmp3 = $regs[2]]) ? - $this->xht_param[$cmp3] : $this->_lang($cmp3, $cur_elem); - $cmp = strcmp($cmp1, $cmp3); $op = ' ' . $regs[1] . ' '; - - if ($subnum) $this->xht_dbgo .= '\n"; // debugging output - - if ( ($cmp < 0 && api_strpos(' <= < != <> ', $op)) || - ($cmp == 0 && api_strpos(' = == <= >= ', $op)) || - ($cmp > 0 && api_strpos(' != <> > >= ', $op)) ) - $result = $this->xht_substitute($regs[3], $cur_elem); - // else $result is empty - } - else - { - $result = $pre . $subtext . $post; - } - } - else - { - if (api_strpos('CLPVX', $type) !== FALSE) // used to be always - $text = $this->xht_substitute($text, $cur_elem); // nested escape - - if ($type == 'C') // Call, e.g. {-C SUBTEMPLATE-} - $result = $this->xht_fill_template($text, $cur_elem); - elseif ($type == 'H') $result = htmlspecialchars($text, ENT_QUOTES, $charset); - elseif ($type == 'L') $result = $this->_lang($text, $cur_elem); - elseif ($type == 'P') $result = $this->xht_param[$text]; - elseif ($type == 'U') $result = urlencode($text); - elseif ($type == 'W') $result = xht_htmlwchars($text); - elseif (!is_object($this->xht_xmldoc)) - { - $result = '? V/X Error: no XML doc has been assigned to xht_xmldoc'; - } - else // $type == 'V' or 'X' - { - - if (api_ereg('^(.*)=/(.+)$', $text, $regs)) // special resource-marker - { - $path = $regs[1]; $text = $regs[2]; - if (api_substr($path, -1) == '/') $path = api_substr($path, 0, -1); - - if ($path) $cur_elem = $this->xht_xmldoc-> - xmd_select_single_element($path, $cur_elem); - - $cur_elem = call_user_func($this->xht_resource, $cur_elem); - } - - $result = ($type == 'V') ? - $this->xht_xmldoc->xmd_value($text, $cur_elem) : - $this->xht_xmldoc-> - xmd_html_value($text, $cur_elem, 'xht_htmlwchars'); - } - } - - if ($subnum) $this->xht_dbgo .= '\n"; - - return $result; -} - - -function xht_add_template($template_name, $httext) -{ - $this->htt_array[$template_name] = $httext; - // removed 2004/10/05: (substr($httext, 0, 6) == 'array(') ? - // removed 2004/10/05: @eval('return ' . $httext . ';') : $httext; - - if (!$this->htt_array[$template_name]) - { - $this->htt_error = 'template ' . $template_name . - ' is empty or invalid'; return; - } -} - - -function xhtdoc($htt_file_contents) -{ - $htt_file_contents = // normalize \r (Mac) and \r\n (Windows) to \n - str_replace("\r", "\n", str_replace("\r\n", "\n", $htt_file_contents)); - - while (api_substr($htt_file_contents, -1) == "\n") - $htt_file_contents = api_substr($htt_file_contents, 0, -1); - - $last_line = api_strrchr($htt_file_contents, "\n"); $this->htt_error = ''; - - if (api_strlen($last_line) < 12 || api_substr($last_line, 0, 6) != "\n") - { - $this->htt_error = 'last line must be of the form '; - return; - } - - define('XHT_PL', (int) (api_strlen($last_line) - 10) / 2); // Parentheses Lth - define('XHT_LP', api_substr($last_line, 6, XHT_PL)); // Left Par - define('XHT_RP', api_substr($last_line, 6 + XHT_PL, XHT_PL)); // Right Par - - if (XHT_LP == XHT_RP) - { - $this->htt_error = - 'parentheses in last line must not be identical'; - return; - } - - $this->htt_array = array(); // named elements are arrays and strings - - foreach (explode("\n\n"))) - { - $template_name = trim(api_substr($name_and_text, 0, $name_length)); - - if (api_strpos($template_name, ' ') !== FALSE) give_up('Template ' . - $template_name . ' has a space in its name'); - $httext = api_substr($name_and_text, $name_length + XHT_PL + 5); - - while (api_substr($httext, 0, 1) == "\n") $httext = api_substr($httext, 1); - while (api_substr($httext, -1) == "\n") $httext = api_substr($httext,0,-1); - - $this->xht_add_template($template_name, $httext); - } - } - - define('XHT_SUBS1', '^(C|H|L|P|U|V|W|X) +(.*)$'); // substitution types 1: - // Call, Htmlchars, Lang, Param, Urlencode, Value, Wchars, Xvalue - define('XHT_SUBS2', '^(D|E|R|T) +([^ ]+) +(.*)$'); // substitution types 2: - // Define, Escape, Repeat, Test - - $this->xht_dbgo = ''; - - $this->xht_param = array(0 => '0', 1 => '1', - '' => '', 'empty' => '', 'rdepth' => 0); - $this->_prev_param = $this->xht_param; - // empty: {-R * P empty-} puts the number of subelements in {-P number-} - // rdepth: current number of nested R's - // rdepth1, rdepth2, ...: key or number, see R -} - - -function _show_param() // for debugging info -{ - global $charset; - $result = ''; - foreach ($this->xht_param as $k => $v) - if ($v !== $this->_prev_param[$k]) { - $this->_prev_param[$k] = $v; $result .= ', ' . $k . ': ' . - ((api_strlen($v) <= 20) ? $v : api_substr($v, 0, 17).'...'); - } - return $result ? htmlspecialchars(api_substr($result, 1), ENT_QUOTES, $charset) : ''; -} - -function _lang($var, $cur_elem = 0) -{ - $result = @call_user_func($this->xht_get_lang, $var, $cur_elem); - - // This is a hack for proper working of the language selectors - // in the forms that are generated through templates. - if ($var == 'Langs') - { - global $langLangs; - if (isset($langLangs)) - { - $result = $langLangs; - } - } - - return isset($result) ? $result : $var; -} - - -} - -/* - -A word of explanation... - -The last line of a template file (example below) defines the special markers -that are used around template names such as INPUT and OPTION and around HTML -escapes such as 'P value' and 'L Store', { and } in the example. You can also -use markers of more than one character as long as both have the same length, -e.g. <% and %>. The markers must not be equal. In templates with JavaScript -or - - -

    {H {L Tool}: {P entry}}

    -
    '.$row->title.'
    - - - - - -{R general/keyword C KEYWORD} -
    {D label {L Language}}{D tip {L LanguageTip}}{C LABEL}
    - - - - -{H {P label}} : - - - - - - - {D label {L Keyword}}{D tip {L KeywordTip}}{C LABEL} - - {D value {X string}}{D title general/keyword[{P number}]/string}{C INPUT} - - - --------------------------------------------------------------------------------- - - -*/ - -?> diff --git a/main/inc/lib/xmd.lib.php b/main/inc/lib/xmd.lib.php deleted file mode 100755 index 624b868694..0000000000 --- a/main/inc/lib/xmd.lib.php +++ /dev/null @@ -1,883 +0,0 @@ - - - - - - -*/ - -/** -* This is the XML Dom library for Dokeos. -* Include/require it in your code to use its functionality. -* -* @author René Haentjens -* @package chamilo.library -*/ - -class xmddoc -{ - /* This MiniDom for XML essentially implements an array of elements, each - with a parent, a name, a namespace-URI, attributes & namespace definitions, - and children. Child nodes are a mix of texts and subelements. Parent - and subelements are stored as elementnumbers, the root is element 0. - - Parsing is built on James Clark's expat, by default enabled in PHP. - - The MiniDom is an alternative to the experimental DOM XML functions. - It is open source PHP and requires no extra libraries. - - Restrictions of the MiniDom: - - no two attributes with same name (different namespaces) on one element; - - only 'ISO-8859-1' right now; author will investigate 'UTF-8' later; - - processing instructions & external entities are ignored; - - no distinction between text and cdata child nodes; - - xmd_xml(nonrootelement) may not generate all needed namespace definitions; - - xmd_value, xmd_html_value, xmd_select_xxx, xmd_update, xmd_update_many: - path parameter uses names without namespaces - and supports only a small subset of XPath, with some extensions; - - maximum 11 auto-generated namespace prefixes (can be changed in xmddoc) - - Namespace definitions are stored as attributes, with name = 'xmlns...' - e.g. xmlns:xml='http://www.w3.org/XML/1998/namespace' - e.g. xmlns='http://www.imsglobal.org/xsd/imscp_v1p1' (default namespace) - - Exposed methods: - - new xmddoc(array_of_strings, charset = 'ISO-8859-1'): parse strings - new xmddoc(names, numbers, textstring): restore from cached arrays & string - - xmd_add_element(complete_name, parent, attributes_with_complete_names) - complete name = [ URI + ':' + ] name - xmd_set_attribute(element, complete_attribute_name, value) (id. as above) - xmd_add_text(text, element) - xmd_add_text_element(complete_name, text, parent, attributes) = - xmd_add_text(text, xmd_add_element(complete_name, parent, attributes)) - - xmd_get_element(element) => children, attributes, '?name', '?parent' - xmd_get_ns_uri(element [, attribute_name_without_uri] ) - - xmd_text(element): combines element and subelements' text nodes - xmd_xml(): generate XML-formatted string (reverse parsing) - xmd_xml(indent_increase, initial_indent, lbr): e.g. ' ', '', "\n" - - xmd_value(path): follow path from root, return attribute value or text - e.g. 'manifest/organizations/@default' 'body/p[1]' (1=first, -1=last) - xmd_value(path, parent, fix, function): find value(s) with path from parent, - apply function and decorate with fix = ('pre'=>..., 'in'=>..., 'post') - e.g. 'general/title/*' array('in' => ', ') - extensions to XPath: - - and + for previous and next sibling, e.g. general/title/+/string - -name and +name for sibling with specific name, e.g. item[2]/+item - .. for parent, e.g. general/title/../../technical/format (stops at root) - @* for location (element number within siblings, starts at 1) - @*name for location in siblings with specific name - @. for element name, e.g. organization/*[1]/@. - namespaces are not supported in paths: they use names without URI - - xmd_html_value(pathFix, parent, fun): 'path' 'path infix' 'prefix -% path' - 'path infix %- postfix': fun = 'htmlspecialchars' by default - - xmd_select_elements(path, parent): find element nodes with path (see above) - xmd_select_single_element (id.) returns -1 or elementnumber - xmd_select_elements_where(path, subpath, value, parent): e.g. '@id', '12' - is like XPath with path[@id='12']; subpath = '.' means text - xmd_select_elements_where_notempty(path, subpath, parent): e.g. '@id' - xmd_select_xxx methods only select elements, not attributes - - xmd_remove_element(childelement_number) - xmd_remove_nodes(childelement_numbers_and_strings, parent) - - xmd_update(path, text, parent): select single element, then: - text element: replace text by new text - attribute: give attribute new value = text - somepath/!newtag: create new child element containing text - somepath/~: delete single (first or only) element - xmd_update_many(paths, subpath, ...): paths can be path1,path2,...: - for all elements selected by all paths, update with subpath - - xmd_copy_foreign_child(fdoc, child, parent): - copies fdoc's child as a new child of parent; - note this method hasn't been tested for all cases (namespaces...) - - xmd_cache(): dump xmddoc into names+numbers+textstring for serialization - - Order of parameters (if present) for xmd_xxx methods: - name, text, children, path, subPath, value, - parent, fix, fun, attributes (name value) - - - Properties: (G)lobal to xmddoc or array (one for each xmddoc (E)lement) - - e.g. $this->name[0] is the name of the document root element - e.g. $this->names[$this->ns[0]] is its namespace URI - e.g. $this->attributes[0]['title'] is the value of its attribute 'title' - e.g. $this->attributes[0]['xmlns:a'] is the URI for prefix 'a:' - */ - - var $names; //G array: n => namespace URI (0 => '') - var $numbers; //G array: numeric dump of xmddoc for caching - var $textstring; //G string: string dump of xmddoc for caching - var $error; //G string: empty or parsing error message - var $_nesting; //G array: nested elements while parsing (internal) - var $_ns; //G array: namespace defs for upcoming element (id.) - var $_concat; //G bool: concatenate cData with previous (id.) - var $_nsp; //G array: namespace prefixes in use somewhere (id.) - var $_last; //G int: last used elementnumber (id.) - var $_strings; //G int: number of string child nodes cached (id.) - - var $parent; //E int: elementnumber: 0 is root, -1 is parent of root - var $name; //E string: element name, without namespace - var $ns; //E int: index into $names to find namespace URI - var $attributes; //E array: attribute name(without namespace) => value - var $atns; //E array: attribute name(id.) => index into $names - var $children; //E array: elementnumbers and strings (text children) - - - function xmd_get_element($parent = 0) // for convenience, readonly copy - { - // returns mixed array: children + texts have numeric key, - // other elements are attributes, '?name' and '?parent' - - if ($parent < 0 || $parent > $this->_last) return array(); - - return array_merge($this->children[$parent], $this->attributes[$parent], - array('?name' => $this->name[$parent], - '?parent' => $this->parent[$parent])); - } - - - function xmd_get_ns_uri($parent = 0, $attName = '') - { - if ($parent < 0 || $parent > $this->_last) return ''; - - return $attName ? $this->names[$this->atns[$parent][$attName]] : - $this->names[$this->ns[$parent]]; - } - - - function xmd_remove_element($child) // success = TRUE - { - if ($child <= 0 || $child > $this->_last) return FALSE; - - $parent = $this->parent[$child]; - - foreach ($this->children[$parent] as $key => $value) - if ($value === $child) - { - unset($this->children[$parent][$key]); return TRUE; - } - - return FALSE; - } - - - function xmd_remove_nodes($children, $parent = 0) // success = TRUE - { - if ($parent < 0 || $parent > $this->_last) return FALSE; - - if (!is_array($children)) $children = array($children); - - foreach ($children as $child) - { - $childFound = FALSE; - foreach ($this->children[$parent] as $key => $value) - if ($value === $child) - { - unset($this->children[$parent][$key]); - $childFound = TRUE; break; - } - if (!$childFound) return FALSE; - } - - return TRUE; - } - - - function xmd_update($xmPath, $text = '', $parent = 0) // success = TRUE - { - if ($parent < 0 || $parent > $this->_last || - !is_string($text) || !is_string($xmPath)) return FALSE; - - $m = array(); - if (api_ereg('^(.*)([~!@])(.*)$', $xmPath, $m)) // split on ~ or ! or @ - { - $xmPath = $m[1]; $op = $m[2]; $name = $m[3]; - } - - if (($elem = $this->xmd_select_single_element($xmPath, $parent)) == -1) - return FALSE; - - if (isset($op)) - { - if ($op == '!' && $name) - { - $this->xmd_add_text_element($name, $text, $elem); return TRUE; - } - elseif ($op == '@' && $name) - { - $this->attributes[$elem][$name] = $text; return TRUE; - } - elseif ($op == '~' && !$name) - return $this->xmd_remove_element($elem); - - return FALSE; - } - - if (($nch = count($this->children[$elem])) > 1) return FALSE; - - $this->children[$elem][0] = $text; return TRUE; - } - - - function xmd_update_many($xmPaths, $subPath = '', $text = '', $parent = 0) - { - $result = TRUE; - - foreach (explode(',', $xmPaths) as $xmPath) - foreach ($this->xmd_select_elements($xmPath, $parent) as $elem) - $result &= $this->xmd_update($subPath, $text, $elem); - // '&=' always evaluates rhs, '&&=' skips it if $result is FALSE - - return $result; - } - - - function xmd_copy_foreign_child($fdoc, $fchild = 0, $parent = 0) - { - $my_queue = array($fchild, $parent); // optimization, see below - - while (!is_null($fchild = array_shift($my_queue))) - { - $parent = array_shift($my_queue); - - if (is_string($fchild)) - $this->xmd_add_text($fchild, $parent); - - elseif (isset($fdoc->name[$fchild])) - { - $fullname = $fdoc->name[$fchild]; - $attribs = array(); $nsdefs = array(); - - if (($nsn = $fdoc->ns[$fchild])) - $fullname = $fdoc->names[$nsn] . ':' . $fullname; - - foreach ($fdoc->attributes[$fchild] as $name => $value) - { - if (($p = strrpos($name, ':')) !== FALSE) // 'xmlns:...' - $nsdefs[$name] = $value; - - else - { - if (($nsn = $fdoc->atns[$fchild][$name])) - $name = $fdoc->names[$nsn] . ':' . $name; - $attribs[$name] = $value; - } - } - - $child = $this->xmd_add_element($fullname, $parent, - array_merge($attribs, $nsdefs)); - - foreach ($fdoc->children[$fchild] as $ch) - array_push($my_queue, $ch, $child); - // recursive call was 10 times slower... - } - } - } - - - function xmd_add_element($name, $parent = 0, $attribs = array()) - { - if (!is_string($name) || $name == '') return -1; - - if (($p = strrpos($name, ':')) !== FALSE) // URI + ':' + name - if ($p == 0 || $p == api_strlen($name) - 1) return -1; - - $child = ($this->_last += 1); $uris = array(); $uri = ''; - - if ($p) - { - $uri = api_substr($name, 0, $p); $name = api_substr($name, $p + 1); - $uris[] = $uri; // check uris after defining all attributes - } - - $this->parent[$child] = $parent; $this->name[$child] = $name; - $this->ns[$child] = $uri ? $this->_lookup($uri) : 0; - $this->children[$child] = array(); - - $this->attributes[$child] = array(); $this->atns[$child] = array(); - - foreach ($attribs as $name => $value) - if (($uri = $this->xmd_set_attribute($child, $name, $value, FALSE))) - $uris[] = $uri; // check at end, not immediately - - if ($parent >= 0 && $parent <= $this->_last) - $this->children[$parent][] = $child; // link to parent - - foreach ($uris as $uri) $this->_nsPfx($child, $uri); - // find prefix (child and upwards) or create new prefix at root - - return $child; - } - - - function xmd_set_attribute($parent, $name, $value, $checkurihaspfx = TRUE) - { - if (!is_string($name) || $name == '') return ''; - - if (($p = strrpos($name, ':')) !== FALSE) // URI + ':' + name - if ($p == 0 || $p == api_strlen($name) - 1) return ''; - - $uri = ''; // beware of 'xmlns...', which is a namespace def! - - if ($p) if (api_substr($name, 0, 6) != 'xmlns:') - { - $uri = api_substr($name, 0, $p); $name = api_substr($name, $p + 1); - } - $this->attributes[$parent][$name] = $value; - $this->atns[$parent][$name] = $uri ? $this->_lookup($uri) : 0; - if ($checkurihaspfx) if ($uri) $this->_nsPfx($parent, $uri); - - if (api_substr($name, 0, 6) == 'xmlns:') // namespace def with prefix - $this->_nsp[api_substr($name, 6)] = $value; // prefix is in use - - return $uri; - } - - - function xmd_add_text($text, $parent = 0) // success = TRUE - { - if ($parent < 0 || $parent > $this->_last || !is_string($text)) - return FALSE; - - if ($text) $this->children[$parent][] = $text; return TRUE; - } - - - function xmd_add_text_element($name, $text, $parent = 0, $attribs = array()) - { - $this->xmd_add_text($text, - $child = $this->xmd_add_element($name, $parent, $attribs)); - - return $child; - } - - - function xmd_text($parent = 0) - { - if ($parent < 0 || $parent > $this->_last) return ''; - - $text = ''; // assemble text subnodes and text in child elements - - foreach ($this->children[$parent] as $child) - $text .= is_string($child) ? $child : $this->xmd_text($child); - - return $text; - } - - - function xmd_xml($increase = ' ', $indent = '', $lbr = "\n", $parent = 0) - { - global $charset; - - if ($parent < 0 || $parent > $this->_last) return ''; - - $uri = $this->names[$this->ns[$parent]]; - $pfxc = ($uri == '') ? '' : $this->_nsPfx($parent, $uri); - - $dbg = ''; // ($uri == '') ? '' : (' '); - - $result = $indent . '<' . ($element = $pfxc . $this->name[$parent]); - - $atnsp = $this->atns[$parent]; - - foreach ($this->attributes[$parent] as $name => $value) - { - if (isset($atnsp[$name])) - $atnsn = $atnsp[$name]; - elseif (isset($atnsn)) - unset($atnsn); - $uri = isset($atnsn) && isset($this->names[$atnsn]) ? - $this->names[$atnsn] : ''; - $pfxc = ($uri == '') ? '' : $this->_nsPfx($parent, $uri); - $result .= ' ' . $pfxc . $name - . '="' . htmlspecialchars($value, ENT_QUOTES, $charset) . '"'; - } - - if (count($this->children[$parent]) == 0) - return $result . ' />' . $dbg; - - $result .= '>'; - - foreach ($this->children[$parent] as $child) - $result .= is_string($child) ? htmlspecialchars($child, ENT_QUOTES, $charset) : ($lbr . - $this->xmd_xml($increase, $indent.$increase, $lbr, $child)); - - if (!is_string($child)) $result .= $lbr . $indent; // last $child - - return $result . '' . $dbg; - } - - - function xmd_value($xmPath, $parent = 0, $fix = array(), $fun = '') - { - // extensions: @*[name] for element position (starts at 1) - // @. for element (tag)name - - if ($parent < 0 || $parent > $this->_last || !is_string($xmPath)) - return ''; - - if (($p = strrpos($xmPath, '@')) !== FALSE) - { - $attName = api_substr($xmPath, $p+1); $xmPath = api_substr($xmPath, 0, $p); - } - - if (!($elems = $this->xmd_select_elements($xmPath, $parent))) return ''; - - $result = ''; $fixin = isset($fix['in']) ? $fix['in'] : ''; - - foreach ($elems as $elem) - { - $value = isset($attName) && api_strlen($attName) >= 1 ? - ($attName == '.' ? $this->name[$elem] : - ($attName{0} == '*' ? - $this->_sibnum($elem, api_substr($attName, 1)) : - $this->attributes[$elem][$attName])) : - $this->xmd_text($elem); - $result .= $fixin . ($fun ? $fun($value) : $value); - } - - return (isset($fix['pre']) ? $fix['pre'] : '') . - api_substr($result, api_strlen($fixin)) . - (isset($fix['post']) ? $fix['post'] : ''); - } - - - function xmd_html_value($xmPath, $parent = 0, $fun = 'htmlspecialchars') - { - if (!is_string($xmPath)) return ''; - - $fix = array(); - - if (($p = api_strpos($xmPath, ' -% ')) !== FALSE) - { - $fix['pre'] = api_substr($xmPath, 0, $p); - $xmPath = api_substr($xmPath, $p+4); - } - if (($p = api_strpos($xmPath, ' %- ')) !== FALSE) - { - $fix['post'] = api_substr($xmPath, $p+4); - $xmPath = api_substr($xmPath, 0, $p); - } - if (($p = api_strpos($xmPath, ' ')) !== FALSE) - { - $fix['in'] = api_substr($xmPath, $p+1); - $xmPath = api_substr($xmPath, 0, $p); - } - - return $this->xmd_value($xmPath, $parent, $fix, $fun); - } - - - function xmd_select_single_element($xmPath, $parent = 0) // for convenience - { - $elements = $this->xmd_select_elements($xmPath, $parent); - if (count($elements) == 0) return -1; - return $elements[0]; - } - - - function xmd_select_elements_where($xmPath, - $subPath = '.', $value = '', $parent = 0) - { - if (!is_string($subPath)) return array(); - - $elems = array(); if ($subPath == '.') $subPath = ''; - - foreach ($this->xmd_select_elements($xmPath, $parent) as $elem) - if ($this->xmd_value($subPath, $elem) == $value) $elems[] = $elem; - - return $elems; - } - - - function xmd_select_elements_where_notempty($xmPath, - $subPath = '.', $parent = 0) - { - if (!is_string($subPath)) return array(); - - $elems = array(); if ($subPath == '.') $subPath = ''; - - foreach ($this->xmd_select_elements($xmPath, $parent) as $elem) - if ($this->xmd_value($subPath, $elem)) $elems[] = $elem; - - return $elems; - } - - - function xmd_select_elements($xmPath, $parent = 0) - { - // XPath subset: e1/e2/.../en, also * and e[n] and *[n] (at 1 or -1) - // /*/... starts from root, regardless of $parent - // extensions: e= - or + (previous & next sibling) - // e= -name or +name (sibling of specific name) - // e= .. (stops at root, so too many doesn't matter) - - if (api_substr($xmPath, 0, 3) == '/*/') - { - $xmPath = api_substr($xmPath, 3); $parent = 0; - } - - if ($parent < 0 || $parent > $this->_last) return array(); - - while (api_substr($xmPath, 0, 1) == '/') $xmPath = api_substr($xmPath, 1); - while (api_substr($xmPath, -1) == '/') $xmPath = api_substr($xmPath, 0, -1); - - if ($xmPath == '' || $xmPath == '.') return array($parent); - - if ($xmPath == '..') - { - if ($parent > 0) return array($this->parent[$parent]); - return array($parent); - } - - if ($xmPath{0} == '-' || $xmPath{0} == '+') - { - $sib = $this->_sibnum($parent, api_substr($xmPath, 1), $xmPath{0}); - if ($sib == -1) return array(); return array($sib); - } - - $m = array(); - if (api_ereg('^(.+)/([^/]+)$', $xmPath, $m)) // split on last / - { - if (!($set = $this->xmd_select_elements($m[1], $parent))) - return $set; // which is empty array - if (count($set) == 1) - return $this->xmd_select_elements($m[2], $set[0]); - - $bigset = array(); $m2 = $m[2]; - foreach ($set as $e) - $bigset = array_merge($bigset, - $this->xmd_select_elements($m2, $e)); - return $bigset; - } - - $xmName = $xmPath; $xmNum = 0; $elems = array(); - - if (api_ereg('^(.+)\[(-?[0-9]+)\]$', $xmPath, $m)) - { - $xmName = $m[1]; $xmNum = (int) $m[2]; - } - - foreach ($this->children[$parent] as $child) if (!is_string($child)) - if ($xmName == '*' || ($this->name[$child]) == $xmName) - $elems[] = $child; - - if ($xmNum == 0) return $elems; - - $xmNum = ($xmNum > 0) ? $xmNum - 1 : count($elems) + $xmNum; - - return ($xmNum < count($elems)) ? array($elems[$xmNum]) : array(); - } - - // Notes on parsing and caching: - // - parsing 388 KB -> 0.94 sec - // - caching 298 KB <- 1.63 sec: 11387 elements, 5137 string nodes - // - uncache 298 KB -> 0.42 sec - // - $this->children[$n][] in a loop is quicker than a temporary array - // $children[] and copying $this->children[$n] = $children after the loop - // - incremental operator ++$numptr is not quicker than ($numptr += 1) - // - numbers & textstring: more compact with base64_encode(gzcompress()) - - function xmd_cache() // store all data in numbers+names+textstring - { - $this->numbers = array(); $this->textstring = ''; $this->_strings = 0; - // add all element- and attributenames to names - see below - - for ($n = 0; $n <= $this->_last; $n++) - { - $this->numbers[] = count($this->children[$n]); - - foreach ($this->children[$n] as $ch) - { - if (is_string($ch)) - { - $this->numbers[] = 0; $this->_strings += 1; - $this->numbers[] = strlen($ch); $this->textstring .= $ch; //!!! Here strlen() has not been changed to api_strlen(). To be investigated. Ivan Tcholakov, 29-AUG-2008. - } - else - { - $this->numbers[] = ($ch-$n); // more compact than $ch - } - } - - $this->numbers[] = count($this->attributes[$n]); - - foreach ($this->attributes[$n] as $name => $value) - { - $this->numbers[] = $this->_lookup($name); - $this->numbers[] = $this->atns[$n][$name]; - $this->numbers[] = strlen($value); $this->textstring .= $value; //!!! Here strlen() has not been changed to api_strlen(). To be investigated. Ivan Tcholakov, 29-AUG-2008. - } - - $this->numbers[] = $this->_lookup($this->name[$n]); - $this->numbers[] = $this->ns[$n]; - $this->numbers[] = $n - $this->parent[$n]; // more compact - } - } - - - function xmddoc($strings, $charset = null, $textstring = '') - { - if (empty($charset)) - { - $charset = api_get_system_encoding(); - } - - $this->parent = array(); $this->name = array(); - $this->ns = array(); $this->attributes = array(); - $this->atns = array(); $this->children = array(); - $this->error = ''; $this->_nesting = array(); - $this->_ns = array(); $this->_last = -1; - - $this->_nsp = array(); - foreach (explode(',', 'eb,tn,eg,ut,as,ne,jt,ne,ah,en,er') as $pfx) - $this->_nsp[$pfx] = ''; - - if (is_array($charset)) // new xmddoc($names, $numbers, $textstring) - { - $this->names = $strings; $this->numbers = $charset; - $this->textstring = $textstring; $this->_uncache(); return; - } - - $this->names = array(); $this->_lookup(''); // empty ns is number 0 - - // This is a quick workaround. - // The xml-parser supports only ISO-8859-1, UTF-8 and US-ASCII. - // See http://php.net/manual/en/function.xml-parser-create-ns.php - //$xml_parser = xml_parser_create_ns($charset, ':'); - $xml_parser = xml_parser_create_ns(api_is_utf8($charset) ? 'UTF-8' : 'ISO-8859-1', ':'); - - xml_set_object($xml_parser,$this); // instead of ...,&$this - // See PHP manual: Passing by Reference vs. xml_set_object - xml_set_element_handler($xml_parser, '_startElement', '_endElement'); - xml_set_character_data_handler($xml_parser, '_cData'); - xml_set_start_namespace_decl_handler($xml_parser, '_startNs'); - // xml_set_end_namespace_decl_handler($xml_parser, '_endNs'); - // xml_set_default_handler ($xml_parser, ''); - xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, FALSE); - - if (!is_array($strings)) $strings = array($strings); - - if (count($strings) && (api_substr($strings[0], 0, 5) != '', FALSE)) - { - $this->error = 'Encoding ' . $charset . ': ' . - xml_error_string(xml_get_error_code($xml_parser)); - $strings = array(); - } - - foreach ($strings as $s) - { - if (api_substr($s, -1) != "\n") $s .= "\n"; - - if (!xml_parse($xml_parser, $s, FALSE)) - { - $errCode = xml_get_error_code($xml_parser); - $this->error = 'Line '. xml_get_current_line_number($xml_parser) . - ' (c' . xml_get_current_column_number($xml_parser) . - // ', b' . xml_get_current_byte_index($xml_parser) . - '): error ' . $errCode . '= ' . xml_error_string($errCode); - break; // the error string is English... - } - } - - xml_parse($xml_parser, '', TRUE); xml_parser_free($xml_parser); - } - - - // internal methods - - function _sibnum($parent, $name = '', $pmn = 'N') // sibling or number - { - if ($parent <= 0) return -1; - - $found = FALSE; $prev = -1; $next = -1; $num = 0; - - foreach ($this->children[$this->parent[$parent]] as $child) - { - if (is_string($child)) continue; - - $name_ok = $name ? ($this->name[$child] == $name) : TRUE; - - if ($found && $name_ok) - { - $next = $child; break; - } - elseif ($parent === $child) - { - $num ++; $found = TRUE; - } - elseif ($name_ok) - { - $num ++; $prev = $child; - } - } - - return ($pmn == '-') ? $prev : (($pmn == '+') ? $next : $num); - } - - function _uncache() // restore all data from numbers+names+textstring - { - $n = -1; $numptr = -1; $txtptr = 0; $count = count($this->numbers); - $A0 = array(); // believe it or not, this makes the loops quicker! - - while (++$numptr < $count) - { - $n++; - - if (($countdown = $this->numbers[$numptr]) == 0) - { - $this->children[$n] = $A0; - } - else while (--$countdown >= 0) - { - if (($chc = $this->numbers[++$numptr]) == 0) - { - $this->children[$n][] = api_substr($this->textstring, - $txtptr, ($len = $this->numbers[++$numptr])); - $txtptr += $len; - } - else - { - $this->children[$n][] = $n + $chc; - } - } - - if (($countdown = $this->numbers[++$numptr]) == 0) - { - $this->attributes[$n] = $this->atns[$n] = $A0; - } - else while (--$countdown >= 0) - { - $name = $this->names[$this->numbers[++$numptr]]; - $this->atns[$n][$name] = $this->numbers[++$numptr]; - $this->attributes[$n][$name] = api_substr($this->textstring, - $txtptr, ($len = $this->numbers[++$numptr])); - $txtptr += $len; - } - - $this->name[$n] = $this->names[$this->numbers[++$numptr]]; - $this->ns[$n] = $this->numbers[++$numptr]; - - $this->parent[$n] = $n - $this->numbers[++$numptr]; - } - - $this->_last = $n; - } - - function _startElement($parser, $name, $attribs) - { - $level = count($this->_nesting); - $parent = ($level == 0) ? -1 : $this->_nesting[$level-1]; - - $child = $this->xmd_add_element($name, $parent, - array_merge($attribs, $this->_ns)); - - $this->_nesting[] = $child; $this->_ns = array(); - - $this->_concat = FALSE; // see _cData - } - - function _endElement($parser, $name) - { - array_pop($this->_nesting); $this->_concat = FALSE; - } - - function _cData($parser, $data) - { - if (!ltrim($data)) return; // empty line, or whitespace preceding - - $level = count($this->_nesting); - $parent = ($level == 0) ? -1 : $this->_nesting[$level-1]; - - if ($parent >= 0) - { - $nc = count($this->children[$parent]); - $pcs = ($nc > 0 && is_string($this->children[$parent][$nc - 1])); - - if ($pcs && api_strlen($data) == 1) $this->_concat = TRUE; - // expat parser puts &xx; in a separate cData, try to re-assemble - - if ($pcs && $data{0} > '~') $this->_concat = TRUE; - // PHP5 expat breaks before 8-bit characters - - if ($this->_concat) - { - $this->children[$parent][$nc - 1] .= $data; - $this->_concat = (api_strlen($data) == 1); - } - else - $this->children[$parent][] = $pcs ? "\n" . $data : $data; - } - } - - function _startNs($parser, $pfx, $uri) // called before _startElement - { - $this->_ns['xmlns' . ($pfx ? ':'.$pfx : '')] = $uri; - $this->_nsp[$pfx] = $uri; - } - - function _nsPfx($ppar, $uri) // find namespace prefix - { - while ($ppar >= 0) - { - foreach ($this->attributes[$ppar] as $name => $value) - if (api_substr($name, 0, 5) == 'xmlns' && $value == $uri) - { - $pfxc = api_substr($name, 6) . api_substr($name, 5, 1); break 2; - } - - $ppar = $this->parent[$ppar]; - } - - if ($ppar >= 0) return $pfxc; if ($uri == '') return ''; - - if ($uri == 'http://www.w3.org/XML/1998/namespace') return 'xml:'; - - foreach($this->_nsp as $pfx => $used) if (!$used) break; - - $this->_nsp[$pfx] = $uri; $xmlnspfx = 'xmlns:' . $pfx; - $this->attributes[0][$xmlnspfx] = $uri; $this->atns[0][$xmlnspfx] = 0; - - return $pfx . ':'; - - } - - function _lookup($name) // for namespaces + see cache - { - $where = array_search($name, $this->names); - - if ($where === FALSE || $where === NULL) - { - $where = count($this->names); $this->names[] = $name; - } - return $where; - } -} - -/* - -*/ -?> diff --git a/main/inc/lib/zip.class.php b/main/inc/lib/zip.class.php deleted file mode 100755 index 57c456c595..0000000000 --- a/main/inc/lib/zip.class.php +++ /dev/null @@ -1,131 +0,0 @@ -add($file_path, $local_path); - * - * Note - * - * Pclzip do not accept method callbacks. It only accepts pure function callbacks. - * As a result the implementation is a bit more complicated than it should be. - * - * @license see /license.txt - * @author Laurent Opprecht for the Univesity of Geneva - */ -/** - * Zip wrapper class - */ -class Zip -{ - - protected static $pool = array(); - - public static function pool($hash = '') - { - if (empty($hash)) { - return self::$pool; - } else { - return self::$pool[$hash]; - } - } - - - /** - * - * @param string $path - * @return Zip - */ - public static function create($path) - { - return new self($path); - } - - protected $path = ''; - protected $archive = null; - protected $entries = array(); - - public function __construct($path = '') - { - $this->path = $path; - self::$pool[$this->get_hash()] = $this; - } - - public function get_path() - { - return $this->path; - } - - public function get_hash() - { - return md5($this->path); - } - - public function add($file_path, $archive_path = '', $comment = '') - { - /** - * Remove c: when working on windows. - */ - if (substr($file_path, 1, 1) == ':') { - $file_path = substr($file_path, 2); - } - - $entry = array( - 'file_path' => $file_path, - 'archive_path' => $archive_path, - 'comment' => $comment - ); - $this->entries[$file_path] = $entry; - - $callback_name = 'zipcallback_' . $this->get_hash(); - if (!function_exists($callback_name)) { - $callback = ''; - $callback .= 'function ' . $callback_name . '($event, &$header){'; - $callback .= '$parts = explode(\'_\', __FUNCTION__);'; - $callback .= '$hash = end($parts);'; - $callback .= 'return Zip::pool($hash)->callback($event, $header);'; - $callback .= '};'; - eval($callback); - } - - $archive = $this->archive(); - $archive->add($file_path, PCLZIP_CB_PRE_ADD, $callback_name); - } - - /** - * - * @return PclZip - */ - protected function archive() - { - if ($this->archive) { - return $this->archive; - } - if (empty($this->path)) { - return null; - } - return $this->archive = new PclZip($this->path); - } - - public function callback($event, &$header) - { - if ($event != PCLZIP_CB_PRE_ADD) { - return 0; - } - - $path = $header['filename']; - if (!isset($this->entries[$path])) { - return 1; - } - - $entry = $this->entries[$path]; - $archive_path = $entry['archive_path']; - if (!empty($archive_path)) { - $header['stored_filename'] = $archive_path; - } - return 1; - } - -} diff --git a/main/inc/lib/zombie/zombie_manager.class.php b/main/inc/lib/zombie/zombie_manager.class.php index 0f57e6d094..68a4029abb 100755 --- a/main/inc/lib/zombie/zombie_manager.class.php +++ b/main/inc/lib/zombie/zombie_manager.class.php @@ -26,7 +26,7 @@ class ZombieManager * @param bool $active_only if true returns only active users. Otherwise returns all users. * @return ResultSet */ - static function list_zombies($ceiling, $active_only = true) + static function listZombies($ceiling, $active_only = true, $count = 0, $from = 10, $column = 'user.firstname', $direction = 'desc') { $ceiling = is_numeric($ceiling) ? (int) $ceiling : strtotime($ceiling); $ceiling = date('Y-m-d H:i:s', $ceiling); @@ -46,7 +46,6 @@ class ZombieManager user.active, access.login_date'; - global $_configuration; if (api_is_multiple_url_enabled()) { $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $current_url_id = api_get_current_access_url_id(); @@ -70,24 +69,31 @@ class ZombieManager access.login_date <= '$ceiling' AND user.user_id = access.login_user_id"; } - if($active_only) - { + if ($active_only) { $sql .= ' AND user.active = 1'; } - return ResultSet::create($sql); + $count = intval($count); + $from = intval($from); + + $sql .= " ORDER BY $column $direction"; + $sql .= " LIMIT $count, $from "; + + $result = Database::query($sql); + + return Database::store_result($result, 'ASSOC'); } + /** + * @param $ceiling + */ static function deactivate_zombies($ceiling) { $zombies = self::list_zombies($ceiling); $ids = array(); - foreach($zombies as $zombie) - { + foreach($zombies as $zombie) { $ids[] = $zombie['user_id']; } UserManager::deactivate_users($ids); } - - } diff --git a/main/inc/lib/zombie/zombie_report.class.php b/main/inc/lib/zombie/zombie_report.class.php index 24510ceca8..cc73b7d47c 100755 --- a/main/inc/lib/zombie/zombie_report.class.php +++ b/main/inc/lib/zombie/zombie_report.class.php @@ -31,7 +31,7 @@ class ZombieReport implements Countable function get_parameters() { - + $result = array( 'name' => 'zombie_report_parameters', 'method' => 'GET', @@ -149,7 +149,7 @@ class ZombieReport implements Countable { /** - * todo check token + * todo check token */ $check = Security::check_token('post'); Security::clear_token(); @@ -197,7 +197,7 @@ class ZombieReport implements Countable $ceiling = $this->get_ceiling(); $active_only = $this->get_active_only(); - $items = ZombieManager::list_zombies($ceiling, $active_only); + $items = ZombieManager::listZombies($ceiling, $active_only); return count($items); } @@ -209,7 +209,7 @@ class ZombieReport implements Countable $ceiling = $this->get_ceiling(); $active_only = $this->get_active_only(); - $items = ZombieManager::list_zombies($ceiling, $active_only)->limit($count, $from)->orderby($column, $direction); + $items = ZombieManager::listZombies($ceiling, $active_only, $count, $from, $column, $direction); $result = array(); foreach ($items as $item) { $row = array(); @@ -231,7 +231,6 @@ class ZombieReport implements Countable function display_data($return = false) { - $count = array($this, 'count'); $data = array($this, 'get_data'); @@ -277,9 +276,9 @@ class ZombieReport implements Countable /** * Table formatter for the active column. - * - * @param string $active - * @return string + * + * @param string $active + * @return string */ function format_active($active) { @@ -323,4 +322,4 @@ class ZombieReport implements Countable } } -} \ No newline at end of file +} diff --git a/main/inc/local.inc.php b/main/inc/local.inc.php index 99ba1e1696..8da5c18f4f 100755 --- a/main/inc/local.inc.php +++ b/main/inc/local.inc.php @@ -116,7 +116,7 @@ //require_once api_get_path(LIBRARY_PATH).'conditionallogin.lib.php'; moved to autologin // verified if exists the username and password in session current -use \ChamiloSession as Session; +use ChamiloSession as Session; //Conditional login if (isset($_SESSION['conditional_login']['uid']) && $_SESSION['conditional_login']['can_login'] === true) { @@ -917,7 +917,8 @@ if (isset($cidReset) && $cidReset) { $_SESSION['_gid'] = intval($_REQUEST['gidReq']); $group_table = Database::get_course_table(TABLE_GROUP); - $sql = "SELECT * FROM $group_table WHERE c_id = ".$_course['real_id']." AND id = '$gidReq'"; + $sql = "SELECT * FROM $group_table + WHERE c_id = ".$_course['real_id']." AND id = '$gidReq'"; $result = Database::query($sql); if (Database::num_rows($result) > 0) { // This group has recorded status related to this course $gpData = Database::fetch_array($result); @@ -1025,25 +1026,24 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { } } - if (isset($user_id) && $user_id && isset($_cid) && $_cid) { + if (isset($user_id) && $user_id && isset($_real_cid) && $_real_cid) { //Check if user is subscribed in a course $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); $sql = "SELECT * FROM $course_user_table - WHERE user_id = '".$user_id."' AND relation_type <> ".COURSE_RELATION_TYPE_RRHH." - AND course_code = '$cidReq'"; + WHERE + user_id = '".$user_id."' AND + relation_type <> ".COURSE_RELATION_TYPE_RRHH." AND + c_id = '$_real_cid'"; $result = Database::query($sql); $cuData = null; if (Database::num_rows($result) > 0) { // this user have a recorded state for this course $cuData = Database::fetch_array($result, 'ASSOC'); - $is_courseAdmin = (bool) ($cuData['status'] == 1 ); - $is_courseTutor = (bool) ($cuData['tutor_id' ] == 1 ); - $is_courseMember = true; - - $_courseUser['role'] = $cuData['role']; - Session::write('_courseUser', $_courseUser); + $is_courseAdmin = (bool)($cuData['status'] == 1); + $is_courseTutor = (bool)($cuData['is_tutor'] == 1); + $is_courseMember = true; } // We are in a session course? Check session permissions @@ -1053,18 +1053,19 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { // This user has no status related to this course // The user is subscribed in a session? The user is a Session coach a Session admin ? - $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); - $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE); + $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); // Session coach, session admin or course coach admin - $sql = "SELECT session.id_coach, session_admin_id, session_rcru.id_user + $sql = "SELECT session.id_coach, session_admin_id, session_rcru.user_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_id' AND - session_rcru.id_session = $session_id AND - session_rcru.status = 2 + WHERE + session_rcru.session_id = session.id AND + session_rcru.c_id = '$_real_cid' AND + session_rcru.user_id = '$user_id' AND + session_rcru.session_id = $session_id AND + session_rcru.status = 2 "; $result = Database::query($sql); @@ -1072,7 +1073,6 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { // Am I a session admin? if (isset($row) && isset($row[0]) && $row[0]['session_admin_id'] == $user_id) { - $_courseUser['role'] = 'Professor'; $is_courseMember = false; $is_courseTutor = false; $is_courseAdmin = false; @@ -1080,28 +1080,28 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { $is_sessionAdmin = true; } else { // Am I a session coach for this session? - $sql = "SELECT id, id_coach FROM $tbl_session session ". - "INNER JOIN $tbl_session_course sc ". - "ON sc.id_session = session.id ". - "WHERE session.id = $session_id ". - "AND session.id_coach = $user_id ". - "AND sc.course_code = '$_cid'"; + $sql = "SELECT id, id_coach FROM $tbl_session session + INNER JOIN $tbl_session_course sc + ON sc.session_id = session.id + WHERE session.id = $session_id + AND session.id_coach = $user_id + AND sc.c_id = '$_real_cid'"; $result = Database::query($sql); if (Database::num_rows($result)) { - $_courseUser['role'] = 'Professor'; $is_courseMember = true; $is_courseTutor = false; $is_courseCoach = true; $is_sessionAdmin = false; } else { // Am I a course coach or a student? - $sql = "SELECT cu.id_user, cu.status ". - "FROM $tbl_session_course_user cu ". - "WHERE course_code = '$_cid' AND ". - " cu.id_user = '".$user_id."' AND ". - " cu.id_session = '".$session_id."' ". - "LIMIT 1"; + $sql = "SELECT cu.user_id, cu.status + FROM $tbl_session_course_user cu + WHERE + c_id = '$_real_cid' AND + cu.user_id = '".$user_id."' AND + cu.session_id = '".$session_id."' + LIMIT 1"; $result = Database::query($sql); if (Database::num_rows($result)) { @@ -1111,48 +1111,41 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { switch ($session_course_status) { case '2': // coach - teacher - $_courseUser['role'] = 'Professor'; - $is_courseMember = true; - $is_courseTutor = true; - $is_courseCoach = true; - $is_sessionAdmin = false; + $is_courseMember = true; + $is_courseTutor = true; + $is_courseCoach = true; + $is_sessionAdmin = false; if (api_get_setting('extend_rights_for_coach') == 'true') { $is_courseAdmin = true; } else { $is_courseAdmin = false; } - Session::write('_courseUser', $_courseUser); break; case '0': //Student - $_courseUser['role'] = ''; - $is_courseMember = true; - $is_courseTutor = false; - $is_courseAdmin = false; - $is_courseCoach = false; - $is_sessionAdmin = false; - - Session::write('_courseUser', $_courseUser); + $is_courseMember = true; + $is_courseTutor = false; + $is_courseAdmin = false; + $is_courseCoach = false; + $is_sessionAdmin = false; + break; default: //unregister user - $_courseUser['role'] = ''; - $is_courseMember = false; - $is_courseTutor = false; - $is_courseAdmin = false; - $is_sessionAdmin = false; - $is_courseCoach = false; - Session::erase('_courseUser'); + $is_courseMember = false; + $is_courseTutor = false; + $is_courseAdmin = false; + $is_sessionAdmin = false; + $is_courseCoach = false; break; } } else { // Unregister user - $is_courseMember = false; - $is_courseTutor = false; - $is_courseAdmin = false; - $is_sessionAdmin = false; - $is_courseCoach = false; - Session::erase('_courseUser'); + $is_courseMember = false; + $is_courseTutor = false; + $is_courseAdmin = false; + $is_sessionAdmin = false; + $is_courseCoach = false; } } } @@ -1162,7 +1155,6 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { $sessionInfo = SessionManager::getSessionFollowedByDrh($user_id, $session_id); if (!empty($sessionInfo) && !empty($sessionInfo['course_list'])) { if (isset($sessionInfo['course_list'][$_course['real_id']])) { - $_courseUser['role'] = ''; $is_courseMember = true; $is_courseTutor = false; $is_courseCoach = false; @@ -1179,12 +1171,11 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { } } else { // keys missing => not anymore in the course - user relation // course - $is_courseMember = false; - $is_courseAdmin = false; - $is_courseTutor = false; - $is_courseCoach = false; - $is_sessionAdmin = false; - Session::erase('_courseUser'); + $is_courseMember = false; + $is_courseAdmin = false; + $is_courseTutor = false; + $is_courseCoach = false; + $is_sessionAdmin = false; } //Checking the course access @@ -1275,10 +1266,6 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { } else { // continue with the previous values - if (isset($_SESSION['_courseUser'])) { - $_courseUser = $_SESSION ['_courseUser']; - } - $is_courseAdmin = isset($_SESSION ['is_courseAdmin']) ? $_SESSION ['is_courseAdmin'] : false; $is_courseTutor = isset($_SESSION ['is_courseTutor']) ? $_SESSION ['is_courseTutor'] : false; $is_courseCoach = isset($_SESSION ['is_courseCoach']) ? $_SESSION ['is_courseCoach'] : false; diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index 8305cd5f8a..73b8a97332 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -21,48 +21,19 @@ * contains variables that can be changed and will not break the platform. * These optional settings are defined in the database, now * (table settings_current). - * example: $_configuration['tracking_enabled'] (assuming that the install - * script creates the necessary tables anyway). */ /** - * MYSQL connection settings + * Database connection settings */ // Your MySQL server -$_configuration['db_host'] = '{DATABASE_HOST}'; +$_configuration['db_host'] = '{DATABASE_HOST}'; // Your MySQL username -$_configuration['db_user'] = '{DATABASE_USER}'; +$_configuration['db_user'] = '{DATABASE_USER}'; // Your MySQL password $_configuration['db_password'] = '{DATABASE_PASSWORD}'; - -// Persistent connections may have profound effects (not always positive) on -// your database server. Use with care. -//$_configuration['db_persistent_connection'] = false; -// For separate web and DB servers, reduce the bandwidth used by compressing -// data returning from the DB server. By default, it is ignored. Uncomment -// the following to enable compression. -//$_configuration['db_client_flags'] = MYSQL_CLIENT_COMPRESS; - -/** - * Database settings - */ -// Is tracking enabled? -$_configuration['tracking_enabled'] = TRACKING_ENABLED; -// Is single database enabled (DO NOT MODIFY THIS) -$_configuration['single_database'] = SINGLE_DATABASE; -// Prefix for course tables (IF NOT EMPTY, can be replaced by another prefix, else leave empty) -$_configuration['table_prefix'] = '{COURSE_TABLE_PREFIX}'; -// Separator between database and table name (DO NOT MODIFY THIS) -$_configuration['db_glue'] = '{DATABASE_GLUE}'; -// prefix all created bases (for courses) with this string -$_configuration['db_prefix'] = '{DATABASE_PREFIX}'; // main Chamilo database -$_configuration['main_database'] = '{DATABASE_MAIN}'; -// stats Chamilo database -$_configuration['statistics_database'] ='{DATABASE_STATS}'; -// User Personal Database (where all the personal stuff of the user is stored -// (personal agenda items, course sorting) -$_configuration['user_personal_database']='{DATABASE_PERSONAL}'; +$_configuration['main_database'] = '{DATABASE_MAIN}'; // Enable access to database management for platform admins. $_configuration['db_manager_enabled'] = false; @@ -70,23 +41,23 @@ $_configuration['db_manager_enabled'] = false; * Directory settings */ // URL to the root of your Chamilo installation, e.g.: http://www.mychamilo.com/ -$_configuration['root_web'] = '{ROOT_WEB}'; +$_configuration['root_web'] = '{ROOT_WEB}'; // Path to the webroot of system, example: /var/www/ -$_configuration['root_sys'] = '{ROOT_SYS}'; +$_configuration['root_sys'] = '{ROOT_SYS}'; // Path from your WWW-root to the root of your Chamilo installation, example: chamilo (this means chamilo is installed in /var/www/chamilo/ -$_configuration['url_append'] = '{URL_APPEND_PATH}'; +$_configuration['url_append'] = '{URL_APPEND_PATH}'; // Directory of the Chamilo code. You could change this but it is not advised since this has not been tested yet. -$_configuration['code_append'] = "main/"; +$_configuration['code_append'] = "main/"; // Directory to store all course-related files. You could change this but it is not advised since this has not been tested yet. -$_configuration['course_folder'] = "courses/"; +$_configuration['course_folder'] = "courses/"; // URL to your phpMyAdmin installation. // If not empty, a link will be available in the Platform Administration -$_configuration['db_admin_path'] = ''; +$_configuration['db_admin_path'] = ''; /** * Login modules settings @@ -154,7 +125,7 @@ $_configuration['cdn'] = array( //You can define several CDNs and split them by extensions //Replace the following by your full CDN URL, which should point to // your Chamilo's root directory. DO NOT INCLUDE a final slash! (won't work) - 'http://cdn.chamilo.org' => array('.css','.js','.jpg','.jpeg','.png','.gif','.avi','.flv'), + 'http://cdn.chamilo.org' => array('.css','.js','.jpg','.jpeg','.png','.gif','.avi','.flv'), // copy the line above and modify following your needs ); @@ -162,24 +133,24 @@ $_configuration['cdn'] = array( * Misc. settings */ // Verbose backup -$_configuration['verbose_backup'] = false; +$_configuration['verbose_backup'] = false; // security word for password recovery -$_configuration['security_key'] = '{SECURITY_KEY}'; +$_configuration['security_key'] = '{SECURITY_KEY}'; // Hash function method -$_configuration['password_encryption'] = '{ENCRYPT_PASSWORD}'; +$_configuration['password_encryption'] = '{ENCRYPT_PASSWORD}'; // You may have to restart your web server if you change this -$_configuration['session_stored_in_db'] = false; +$_configuration['session_stored_in_db'] = false; // Session lifetime -$_configuration['session_lifetime'] = SESSION_LIFETIME; +$_configuration['session_lifetime'] = SESSION_LIFETIME; // Activation for multi-url access //$_configuration['multiple_access_urls'] = true; -$_configuration['software_name'] = 'Chamilo'; -$_configuration['software_url'] = 'http://www.chamilo.org/'; +$_configuration['software_name'] = 'Chamilo'; +$_configuration['software_url'] = 'http://www.chamilo.org/'; //Deny the elimination of users $_configuration['deny_delete_users'] = false; // Version settings -$_configuration['system_version'] = '{NEW_VERSION}'; -$_configuration['system_stable'] = NEW_VERSION_STABLE; +$_configuration['system_version'] = '{NEW_VERSION}'; +$_configuration['system_stable'] = NEW_VERSION_STABLE; /** * Settings to be included as settings_current in future versions diff --git a/main/install/country_data.csv b/main/install/country_data.csv deleted file mode 100755 index 749c097860..0000000000 --- a/main/install/country_data.csv +++ /dev/null @@ -1,264 +0,0 @@ -1,'ac','Ascension (ile)',0,, -2,'ad','Andorre',0, -3,'ae','Emirats Arabes Unis',0, -4,'af','Afghanistan',0, -5,'ag','Antigua et Barbuda',0, -6,'ai','Anguilla',0, -7,'al','Albanie',0, -8,'am','Arménie',0, -9,'an','Antilles Neerlandaises',0, -10,'ao','Angola',0, -11,'aq','Antarctique',0, -12,'ar','Argentine',0, -13,'as','American Samoa',0, -14,'au','Australie',0, -15,'aw','Aruba',0, -16,'az','Azerbaijan',0, -17,'ba','Bosnie Herzegovine',0, -18,'bb','Barbade',0, -19,'bd','Bangladesh',0, -20,'be','Belgique',0, -21,'bf','Burkina Faso',0, -22,'bg','Bulgarie',0, -23,'bh','Bahrain',0, -24,'bi','Burundi',0, -25,'bj','Benin',0, -26,'bm','Bermudes',0, -27,'bn','Brunei Darussalam',0, -28,'bo','Bolivie',0, -29,'br','Brésil',0, -30,'bs','Bahamas',0, -31,'bt','Bhoutan',0, -32,'bv','Bouvet (ile)',0, -33,'bw','Botswana',0, -34,'by','Biélorussie',0, -35,'bz','Bélize',0, -36,'ca','Canada',0, -37,'cc','Cocos (Keeling) iles',0, -38,'cd','Congo,(République démocratique du)',0, -39,'cf','Centrafricaine (République )',0, -40,'cg','Congo',0, -41,'ch','Suisse',0, -42,'ci','Cote d\'Ivoire',0, -43,'ck','Cook (iles)',0, -44,'cl','Chili',0, -45,'cm','Cameroun',0, -46,'cn','Chine',0, -47,'co','Colombie',0, -48,'cr','Costa Rica',0, -49,'cu','Cuba',0, -50,'cv','Cap Vert',0, -51,'cx','Christmas (ile)',0, -52,'cy','Chypre',0, -53,'cz','Tchéque (République)',0, -54,'de','Allemagne',0, -55,'dj','Djibouti',0, -56,'dk','Danemark',0, -57,'dm','Dominique',0, -58,'do','Dominicaine (république)',0, -59,'dz','Algérie',0, -60,'ec','Equateur',0, -61,'ee','Estonie',0, -62,'eg','Egypte',0, -63,'eh','Sahara Occidental',0, -64,'er','Erythrée',0, -65,'es','Espagne',0, -66,'et','Ethiopie',0, -67,'fi','Finlande',0, -68,'fj','Fiji',0, -69,'fk','Falkland (Malouines) iles',0, -70,'fm','Micronésie',0, -71,'fo','Faroe (iles)',0, -72,'fr','France',0, -73,'ga','Gabon',0, -74,'gd','Grenade',0, -75,'ge','Géorgie',0, -76,'gf','Guyane Française',0, -77,'gg','Guernsey',0, -78,'gh','Ghana',0, -79,'gi','Gibraltar',0, -80,'gl','Groenland',0, -81,'gm','Gambie',0, -82,'gn','Guinée',0, -83,'gp','Guadeloupe',0, -84,'gq','Guinée Equatoriale',0, -85,'gr','Grèce',0, -86,'gs','Georgie du sud et iles Sandwich du sud',0, -87,'gt','Guatemala',0, -88,'gu','Guam',0, -89,'gw','Guinée-Bissau',0, -90,'gy','Guyana',0, -91,'hk','Hong Kong',0, -92,'hm','Heard et McDonald (iles)',0, -93,'hn','Honduras',0, -94,'hr','Croatie',0, -95,'ht','Haiti',0, -96,'hu','Hongrie',0, -97,'id','Indonésie',0, -98,'ie','Irlande',0, -99,'il','Israël',0, -100,'im','Ile de Man',0, -101,'in','Inde',0, -102,'io','Territoire Britannique de l\'Océan Indien',0, -103,'iq','Iraq',0, -104,'ir','Iran',0, -105,'is','Islande',0, -106,'it','Italie',0, -107,'je','Jersey',0, -108,'jm','Jamaïque',0, -109,'jo','Jordanie',0, -110,'jp','Japon',0, -111,'ke','Kenya',0, -112,'kg','Kirgizstan',0, -113,'kh','Cambodge',0, -114,'ki','Kiribati',0, -115,'km','Comores',0, -116,'kn','Saint Kitts et Nevis',0, -117,'kp','Corée du nord',0, -118,'kr','Corée du sud',0, -119,'kw','Koweït',0, -120,'ky','Caïmanes (iles)',0, -121,'kz','Kazakhstan',0, -122,'la','Laos',0, -123,'lb','Liban',0, -124,'lc','Sainte Lucie',0, -125,'li','Liechtenstein',0, -126,'lk','Sri Lanka',0, -127,'lr','Liberia',0, -128,'ls','Lesotho',0, -129,'lt','Lituanie',0, -130,'lu','Luxembourg',0, -131,'lv','Latvia',0, -132,'ly','Libyan Arab Jamahiriya',0, -133,'ma','Maroc',0, -134,'mc','Monaco',0, -135,'md','Moldavie',0, -136,'mg','Madagascar',0, -137,'mh','Marshall (iles)',0, -138,'mk','Macédoine',0, -139,'ml','Mali',0, -140,'mm','Myanmar',0, -141,'mn','Mongolie',0, -142,'mo','Macao',0, -143,'mp','Mariannes du nord (iles)',0, -144,'mq','Martinique',0, -145,'mr','Mauritanie',0, -146,'ms','Montserrat',0, -147,'mt','Malte',0, -148,'mu','Maurice (ile)',0, -149,'mv','Maldives',0, -150,'mw','Malawi',0, -151,'mx','Mexique',0, -152,'my','Malaisie',0, -153,'mz','Mozambique',0, -154,'na','Namibie',0, -155,'nc','Nouvelle Calédonie',0, -156,'ne','Niger',0, -157,'nf','Norfolk (ile)',0, -158,'ng','Nigéria',0, -159,'ni','Nicaragua',0, -160,'nl','Pays Bas',0, -161,'no','Norvège',0, -162,'np','Népal',0, -163,'nr','Nauru',0, -164,'nu','Niue',0, -165,'nz','Nouvelle Zélande',0, -166,'om','Oman',0, -167,'pa','Panama',0, -168,'pe','Pérou',0, -169,'pf','Polynésie Française',0, -170,'pg','Papouasie Nouvelle Guinée',0, -171,'ph','Philippines',0, -172,'pk','Pakistan',0, -173,'pl','Pologne',0, -174,'pm','St. Pierre et Miquelon',0, -175,'pn','Pitcairn (ile)',0, -176,'pr','Porto Rico',0, -177,'pt','Portugal',0, -178,'pw','Palau',0, -179,'py','Paraguay',0, -180,'qa','Qatar',0, -181,'re','Réunion (ile de la)',0, -182,'ro','Roumanie',0, -183,'ru','Russie',0, -184,'rw','Rwanda',0, -185,'sa','Arabie Saoudite',0, -186,'sb','Salomon (iles)',0, -187,'sc','Seychelles',0, -188,'sd','Soudan',0, -189,'se','Suède',0, -190,'sg','Singapour',0, -191,'sh','St. Hélène',0, -192,'si','Slovénie',0, -193,'sj','Svalbard et Jan Mayen (iles)',0, -194,'sk','Slovaquie',0, -195,'sl','Sierra Leone',0, -196,'sm','Saint Marin',0, -197,'sn','Sénégal',0, -198,'so','Somalie',0, -199,'sr','Suriname',0, -200,'st','Sao Tome et Principe',0, -201,'sv','Salvador',0, -202,'sy','Syrie',0, -203,'sz','Swaziland',0, -204,'tc','Turks et Caïques (iles)',0, -205,'td','Tchad',0, -206,'tf','Territoires Français du sud',0, -207,'tg','Togo',0, -208,'th','Thailande',0, -209,'tj','Tajikistan',0, -210,'tk','Tokelau',0, -211,'tm','Turkménistan',0, -212,'tn','Tunisie',0, -213,'to','Tonga',0, -214,'tp','Timor Oriental',0, -215,'tr','Turquie',0, -216,'tt','Trinidad et Tobago',0, -217,'tv','Tuvalu',0, -218,'tw','Taiwan',0, -219,'tz','Tanzanie',0, -220,'ua','Ukraine',0, -221,'ug','Ouganda',0, -222,'uk','Royaume Uni',0, -223,'gb','Royaume Uni',0, -224,'um','US Minor Outlying (iles)',0, -225,'us','Etats Unis',0, -226,'uy','Uruguay',0, -227,'uz','Ouzbékistan',0, -228,'va','Vatican',0, -229,'vc','Saint Vincent et les Grenadines',0, -230,'ve','Venezuela',0, -231,'vg','Vierges Britaniques (iles)',0, -232,'vi','Vierges USA (iles)',0, -233,'vn','Viêt Nam',0, -234,'vu','Vanuatu',0, -235,'wf','Wallis et Futuna (iles)',0, -236,'ws','Western Samoa',0, -237,'ye','Yemen',0, -238,'yt','Mayotte',0, -239,'yu','Yugoslavie',0, -240,'za','Afrique du Sud',0, -241,'zm','Zambie',0, -242,'zr','Zaïre',0, -243,'zw','Zimbabwe',0, -244,'com','.COM',0, -245,'net','.NET',0, -246,'org','.ORG',0, -247,'edu','Education',0, -248,'int','.INT',0, -249,'arpa','.ARPA',0, -250,'at','Autriche',0, -251,'gov','Gouvernement',0, -252,'mil','Militaire',0, -253,'su','Ex U.R.S.S.',0, -254,'reverse','Reverse',0, -255,'biz','Businesses',0, -256,'info','.INFO',0, -257,'name','.NAME',0, -258,'pro','.PRO',0, -259,'coop','.COOP',0, -260,'aero','.AERO',0, -261,'museum','.MUSEUM',0, -262,'tv','.TV',0, -263,'ws','Web site',0, -264,'--','Unknown',0, \ No newline at end of file diff --git a/main/install/data.sql b/main/install/data.sql new file mode 100644 index 0000000000..e1997e7331 --- /dev/null +++ b/main/install/data.sql @@ -0,0 +1,154 @@ + +INSERT INTO language (original_name, english_name, isocode, dokeos_folder, available) VALUES +('العربية','arabic','ar','arabic',0), +('Asturianu','asturian','ast','asturian',0), +('Euskara','basque','eu','basque',1), +('বাংলা','bengali','bn','bengali',0), +('Bosanski','bosnian','bs','bosnian',1), +('Português do Brasil','brazilian','pt-BR','brazilian',1), +('Български','bulgarian','bg','bulgarian',1), +('Català','catalan','ca','catalan',0), +('Hrvatski','croatian','hr','croatian',0), +('Česky','czech','cs','czech',0), +('Dansk','danish','da','danish',0), +('دری','dari','prs','dari',0), +('Nederlands','dutch','nl','dutch',1), +('English','english','en','english',1), +('Esperanto','esperanto','eo','esperanto',0), +('Føroyskt', 'faroese', 'fo', 'faroese', 0), +('Suomi','finnish','fi','finnish',0), +('Français','french','fr','french',1), +('Furlan','friulian','fur','friulian',0), +('Galego','galician','gl','galician',1), +('ქართული','georgian','ka','georgian',0), +('Deutsch','german','de','german',1), +('Ελληνικά','greek','el','greek',1), +('עברית','hebrew','he','hebrew',0), +('हिन्दी','hindi','hi','hindi',0), +('Magyar','hungarian','hu','hungarian',1), +('Bahasa Indonesia','indonesian','id','indonesian',1), +('Italiano','italian','it','italian',1), +('日本語','japanese','ja','japanese',0), +('한국어','korean','ko','korean',0), +('Latviešu','latvian','lv','latvian',1), +('Lietuvių','lithuanian','lt','lithuanian',0), +('Македонски','macedonian','mk','macedonian',0), +('Bahasa Melayu','malay','ms','malay',0), +('Norsk','norwegian','no','norwegian',0), +('Occitan','occitan','oc','occitan',0), +('پښتو','pashto','ps','pashto',0), +('فارسی','persian','fa','persian',0), +('Polski','polish','pl','polish',1), +('Português europeu','portuguese','pt','portuguese',1), +('Runasimi','quechua_cusco','qu','quechua_cusco',0), +('Română','romanian','ro','romanian',0), +('Русский','russian','ru','russian',0), +('Srpski','serbian','sr','serbian',0), +('中文(简体)','simpl_chinese','zh','simpl_chinese',0), +('Slovenčina','slovak','sk','slovak',1), +('Slovenščina','slovenian','sl','slovenian',1), +('الصومالية','somali','so','somali',0), +('Español','spanish','es','spanish',1), +('Kiswahili','swahili','sw','swahili',0), +('Svenska','swedish','sv','swedish',0), +('Tagalog', 'tagalog', 'tl', 'tagalog',1), +('ไทย','thai','th','thai',0), +('Tibetan', 'tibetan', 'bo', 'tibetan', 0), +('繁體中文','trad_chinese','zh-TW','trad_chinese',0), +('Türkçe','turkish','tr','turkish',0), +('Українська','ukrainian','uk','ukrainian',0), +('Tiếng Việt','vietnamese','vi','vietnamese',0), +('isiXhosa', 'xhosa', 'xh', 'xhosa', 0), +('Yorùbá','yoruba','yo','yoruba',0); + + +INSERT INTO course_category VALUES (1,'Language skills','LANG',NULL,1,0,'TRUE','TRUE'),(2,'PC Skills','PC',NULL,2,0,'TRUE','TRUE'),(3,'Projects','PROJ',NULL,3,0,'TRUE','TRUE'); + +INSERT INTO course_module VALUES +(1,'calendar_event','calendar/agenda.php','agenda.gif',1,1,'basic'), +(2,'link','link/link.php','links.gif',4,1,'basic'), +(3,'document','document/document.php','documents.gif',3,1,'basic'), +(4,'student_publication','work/work.php','works.gif',3,2,'basic'), +(5,'announcement','announcements/announcements.php','valves.gif',2,1,'basic'), +(6,'user','user/user.php','members.gif',2,3,'basic'), +(7,'forum','forum/index.php','forum.gif',1,2,'basic'), +(8,'quiz','exercice/exercice.php','quiz.gif',2,2,'basic'), +(9,'group','group/group.php','group.gif',3,3,'basic'), +(10,'course_description','course_description/','info.gif',1,3,'basic'), +(11,'chat','chat/chat.php','chat.gif',0,0,'external'), +(12,'dropbox','dropbox/index.php','dropbox.gif',4,2,'basic'), +(13,'tracking','tracking/courseLog.php','statistics.gif',1,3,'courseadmin'), +(14,'homepage_link','link/link.php?action=addlink','npage.gif',1,1,'courseadmin'), +(15,'course_setting','course_info/infocours.php','reference.gif',1,1,'courseadmin'), +(16,'External','','external.gif',0,0,'external'), +(17,'AddedLearnpath','','scormbuilder.gif',0,0,'external'), +(18,'conference','conference/index.php?type=conference','conf.gif',0,0,'external'), +(19,'conference','conference/index.php?type=classroom','conf.gif',0,0,'external'), +(20,'learnpath','newscorm/lp_controller.php','scorms.gif',5,1,'basic'), +(21,'blog','blog/blog.php','blog.gif',1,2,'basic'), +(22,'blog_management','blog/blog_admin.php','blog_admin.gif',1,2,'courseadmin'), +(23,'course_maintenance','course_info/maintenance.php','backup.gif',2,3,'courseadmin'), +(24,'survey','survey/survey_list.php','survey.gif',2,1,'basic'), +(25,'wiki','wiki/index.php','wiki.gif',2,3,'basic'), +(26,'gradebook','gradebook/index.php','gradebook.gif',2,2,'basic'), +(27,'glossary','glossary/index.php','glossary.gif',2,1,'basic'), +(28,'notebook','notebook/index.php','notebook.gif',2,1,'basic'), +(29,'attendance','attendance/index.php','attendance.gif',2,1,'basic'), +(30,'course_progress','course_progress/index.php','course_progress.gif',2,1,'basic'); + +INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES (1, 'legal_accept','Legal',0,0); +INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES (1, 'already_logged_in','Already logged in',0,0); +INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES (1, 'update_type','Update script type',0,0); +INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES (10, 'tags','tags',0,0); +INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES (1, 'rssfeeds','RSS',0,0); +INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES (1, 'dashboard', 'Dashboard', 0, 0); +INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES (11, 'timezone', 'Timezone', 0, 0); +INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable, field_default_value) values (4, 'mail_notify_invitation', 'MailNotifyInvitation',1,1,'1'); +INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable, field_default_value) values (4, 'mail_notify_message', 'MailNotifyMessage',1,1,'1'); +INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable, field_default_value) values (4, 'mail_notify_group_message','MailNotifyGroupMessage',1,1,'1'); +INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES (1, 'user_chat_status','User chat status',0,0); +INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES (1, 'google_calendar_url','Google Calendar URL',0,0); + +INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values (8, '1', 'AtOnce',1); +INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values (8, '8', 'Daily',2); +INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values (8, '0', 'No',3); + +INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values (9, '1', 'AtOnce',1); +INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values (9, '8', 'Daily',2); +INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values (9, '0', 'No',3); + +INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values (10, '1', 'AtOnce',1); +INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values (10, '8', 'Daily',2); +INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values (10, '0', 'No',3); + +INSERT INTO access_url(url, description, active, created_by) VALUES ('http://localhost/',' ',1,1); + +-- Adding admin to the first portal +INSERT INTO access_url_rel_user VALUES(1, 1); + +-- Adding the platform templates + + +INSERT INTO user_friend_relation_type (id,title) +VALUES +(1,'SocialUnknow'), +(2,'SocialParent'), +(3,'SocialFriend'), +(4,'SocialGoodFriend'), +(5,'SocialEnemy'), +(6,'SocialDeleted'); + +INSERT INTO course_field (field_type, field_variable, field_display_text, field_default_value, field_visible, field_changeable) values (1, 'special_course', 'Special course', '', 1 , 1); + +INSERT INTO skill (name) VALUES ('Root'); + +INSERT INTO skill_rel_skill VALUES(1, 1, 0, 0, 0); + +INSERT INTO course_type (id, name) VALUES (1, 'All tools'); +INSERT INTO course_type (id, name) VALUES (2, 'Entry exam'); + +UPDATE settings_current SET selected_value = '1.10.0.35' WHERE variable = 'chamilo_database_version'; + + + + diff --git a/main/install/database.sql b/main/install/database.sql index f3600641cf..3d54dc6c8b 100644 --- a/main/install/database.sql +++ b/main/install/database.sql @@ -80,7 +80,6 @@ CREATE TABLE IF NOT EXISTS admin ( -- Dumping data for table admin -- - /*!40000 ALTER TABLE admin DISABLE KEYS */; LOCK TABLES admin WRITE; INSERT INTO admin VALUES (1, 1); @@ -189,8 +188,8 @@ CREATE TABLE IF NOT EXISTS course_category ( parent_id varchar(40) default NULL, tree_pos int unsigned default NULL, children_count smallint default NULL, - auth_course_child enum('TRUE','FALSE') default 'TRUE', - auth_cat_child enum('TRUE','FALSE') default 'TRUE', + auth_course_child varchar(40) default 'TRUE', + auth_cat_child varchar(40) default 'TRUE', PRIMARY KEY (id), UNIQUE KEY code (code), KEY parent_id (parent_id), @@ -3624,7 +3623,7 @@ CREATE TABLE c_quiz_answer( ponderation float(6,2) NOT NULL default 0, position mediumint unsigned NOT NULL default 1, hotspot_coordinates text, - hotspot_type enum('square','circle','poly','delineation','oar') default NULL, + hotspot_type varchar(40) default NULL, destination text NOT NULL, answer_code char(10) default '', PRIMARY KEY (id_auto, c_id) @@ -3685,7 +3684,7 @@ CREATE TABLE c_tool( admin varchar(255) default NULL, address varchar(255) default NULL, added_tool tinyint unsigned default 1, - target enum('_self','_blank') NOT NULL default '_self', + target varchar(20) NOT NULL default '_self', category varchar(20) not null default 'authoring', session_id int default 0, PRIMARY KEY (id, c_id) @@ -3796,7 +3795,7 @@ CREATE TABLE c_link( description text, category_id int unsigned default NULL, display_order int unsigned NOT NULL default 0, - on_homepage enum('0','1') NOT NULL default '0', + on_homepage char(10) NOT NULL default '0', target char(10) default '_self', session_id int default 0, PRIMARY KEY (id, c_id) @@ -4252,7 +4251,7 @@ CREATE TABLE c_blog_rating( rating_id int NOT NULL AUTO_INCREMENT , c_id INT NOT NULL, blog_id int NOT NULL default 0, - rating_type enum( 'post', 'comment' ) NOT NULL default 'post', + rating_type char(40) NOT NULL default 'post', item_id int NOT NULL default 0, user_id int NOT NULL default 0, rating int NOT NULL default 0, @@ -4376,7 +4375,7 @@ CREATE TABLE c_course_setting ( PRIMARY KEY (id, c_id) ); -CREATE TABLE c_survey ( +CREATE TABLE c_survey ( survey_id int unsigned NOT NULL auto_increment, c_id INT NOT NULL, code varchar(20) default NULL, @@ -4396,7 +4395,7 @@ CREATE TABLE c_survey ( invite_mail text NOT NULL, reminder_mail text NOT NULL, mail_subject VARCHAR( 255 ) NOT NULL, - anonymous enum('0','1') NOT NULL default '0', + anonymous char(10) NOT NULL default '0', access_condition TEXT DEFAULT NULL, shuffle bool NOT NULL default '0', one_question_per_page bool NOT NULL default '0', @@ -4600,17 +4599,6 @@ CREATE TABLE c_thematic_advance( ALTER TABLE c_thematic_advance ADD INDEX (thematic_id); -CREATE TABLE IF NOT EXISTS c_metadata ( - c_id INT NOT NULL, - eid VARCHAR(250) NOT NULL, - mdxmltext TEXT default '', - md5 CHAR(32) default '', - htmlcache1 TEXT default '', - htmlcache2 TEXT default '', - indexabletext TEXT default '', - PRIMARY KEY (c_id, eid) -); - DROP TABLE IF EXISTS c_student_publication_rel_document; CREATE TABLE IF NOT EXISTS c_student_publication_rel_document (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, work_id INT NOT NULL, document_id INT NOT NULL, c_id INT NOT NULL); DROP TABLE IF EXISTS c_student_publication_rel_user; diff --git a/main/install/i_database.class.php b/main/install/i_database.class.php deleted file mode 100755 index 67eebf3bff..0000000000 --- a/main/install/i_database.class.php +++ /dev/null @@ -1,73 +0,0 @@ - for the Univesity of Geneva - */ -class iDatabase extends Database -{ - - private static $is_logging = true; - - static function is_logging() - { - return self::$is_logging; - } - - static function set_is_logging($value) - { - self::$is_logging = $value; - } - - static function select_db($database_name, $connection = null) - { - if (self::is_logging()) { - Log::notice(__FUNCTION__ . ' ' . $database_name, Log::frame(1)); - } - return parent::select_db($database_name, $connection); - } - - static function query($query, $connection = null, $file = null, $line = null) - { - if (self::is_logging()) { - $query = str_replace("\n", '', $query); - Log::notice(__FUNCTION__ . ' ' . $query, Log::frame(1)); - } - - $result = parent::query($query, $connection, $file, $line); - - if (empty($result)) { - $backtrace = debug_backtrace(); // Retrieving information about the caller statement. - $caller = isset($backtrace[0]) ? $backtrace[0] : array(); - $file = $caller['file']; - $line = $caller['line']; - $message = " sql: $query \n file: $file \n line:$line"; - Log::error($message); - } - return $result; - } - - /** - * Returns true if the table exists in the database, false otherwise. - * @param string $database - * @param string table - * @return boolean - */ - static - - function table_exists($database, $table) - { - $tables = mysql_list_tables($db); - while (list ($temp) = mysql_fetch_array($tables)) { - if (strtolower($temp) == strtolower($table)) { - return true; - } - } - return false; - } - -} - diff --git a/main/install/index.php b/main/install/index.php index 7234881107..4fed21f249 100755 --- a/main/install/index.php +++ b/main/install/index.php @@ -16,13 +16,15 @@ /* CONSTANTS */ -use \ChamiloSession as Session; +use ChamiloSession as Session; -define('SYSTEM_INSTALLATION', 1); -define('INSTALL_TYPE_UPDATE', 'update'); -define('FORM_FIELD_DISPLAY_LENGTH', 40); -define('DATABASE_FORM_FIELD_DISPLAY_LENGTH', 25); -define('MAX_FORM_FIELD_LENGTH', 80); +require_once __DIR__.'/../../vendor/autoload.php'; + +define('SYSTEM_INSTALLATION', 1); +define('INSTALL_TYPE_UPDATE', 'update'); +define('FORM_FIELD_DISPLAY_LENGTH', 40); +define('DATABASE_FORM_FIELD_DISPLAY_LENGTH', 25); +define('MAX_FORM_FIELD_LENGTH', 80); /* PHP VERSION CHECK */ @@ -31,17 +33,12 @@ require_once '../inc/lib/api.lib.php'; api_check_php_version('../inc/'); -/* INITIALIZATION SECTION */ +/* INITIALIZATION SECTION */ ob_implicit_flush(true); session_start(); - -require_once api_get_path(SYS_PATH).'vendor/autoload.php'; require_once api_get_path(LIBRARY_PATH).'database.constants.inc.php'; -require_once api_get_path(LIBRARY_PATH).'database.lib.php'; require_once 'install.lib.php'; -require_once 'install.class.php'; -require_once 'i_database.class.php'; // This value is use in database::query in order to prompt errors in the error log (course databases) Database::$log_queries = true; @@ -103,22 +100,18 @@ error_reporting(E_ALL); // Overriding the timelimit (for large campusses that have to be migrated). @set_time_limit(0); -// Upgrading from any subversion of 1.6 is just like upgrading from 1.6.5 -$update_from_version_6 = array('1.6', '1.6.1', '1.6.2', '1.6.3', '1.6.4', '1.6.5'); -// Upgrading from any subversion of 1.8 avoids the additional step of upgrading from 1.6 -$update_from_version_8 = array('1.8', '1.8.2', '1.8.3', '1.8.4', '1.8.5', '1.8.6', '1.8.6.1', '1.8.6.2','1.8.7','1.8.7.1','1.8.8','1.8.8.2', '1.8.8.4', '1.8.8.6', '1.9.0', '1.9.2','1.9.4','1.9.6', '1.9.6.1', '1.9.8', '1.9.8.1', '1.9.8.2', '1.9.10'); +// Upgrading from any subversion of 1.9 +$update_from_version_8 = array('1.9.0', '1.9.2','1.9.4','1.9.6', '1.9.6.1', '1.9.8', '1.9.8.1', '1.9.8.2', '1.9.10', '1.9.10.2'); $my_old_version = ''; -$tmp_version = get_config_param('dokeos_version'); if (empty($tmp_version)) { $tmp_version = get_config_param('system_version'); } + if (!empty($_POST['old_version'])) { $my_old_version = $_POST['old_version']; } elseif (!empty($tmp_version)) { $my_old_version = $tmp_version; -} elseif (!empty($dokeos_version)) { //variable coming from installedVersion, normally - $my_old_version = $dokeos_version; } require_once __DIR__.'/version.php'; @@ -128,21 +121,22 @@ require_once __DIR__.'/version.php'; if (isAlreadyInstalledSystem()) { // The system has already been installed, so block re-installation. $global_error_code = 6; - require '../inc/global_error_message.inc.php'; - die(); + // @todo uncomment this. + /*require '../inc/global_error_message.inc.php'; + die();*/ } /* STEP 1 : INITIALIZES FORM VARIABLES IF IT IS THE FIRST VISIT */ // Is valid request $is_valid_request = isset($_REQUEST['is_executable']) ? $_REQUEST['is_executable'] : null; -foreach ($_POST as $request_index => $request_value) { +/*foreach ($_POST as $request_index => $request_value) { if (substr($request_index, 0, 4) == 'step') { if ($request_index != $is_valid_request) { unset($_POST[$request_index]); } } -} +}*/ $badUpdatePath = false; $emptyUpdatePath = true; @@ -169,25 +163,6 @@ if (@$_POST['step2_install'] || @$_POST['step2_update_8'] || @$_POST['step2_upda } else { $badUpdatePath = true; } - } else { //step2_update_6, presumably - if (empty($_POST['updatePath'])) { - $_POST['step1'] = 1; - } else { - $emptyUpdatePath = false; - $_POST['updatePath'] = api_add_trailing_slash($_POST['updatePath']); - if (file_exists($_POST['updatePath'])) { - //1.6.x - $my_old_version = get_config_param('clarolineVersion', $_POST['updatePath']); - if (in_array($my_old_version, $update_from_version_6)) { - $_POST['step2'] = 1; - $proposedUpdatePath = $_POST['updatePath']; - } else { - $badUpdatePath = true; - } - } else { - $badUpdatePath = true; - } - } } } } elseif (@$_POST['step1']) { @@ -206,26 +181,19 @@ if ($installType == 'update' && in_array($my_old_version, $update_from_version_8 } if (!isset($_GET['running'])) { - - $dbHostForm = 'localhost'; + $dbHostForm = 'localhost'; $dbUsernameForm = 'root'; - $dbPassForm = ''; - $dbPrefixForm = ''; - $dbNameForm = 'chamilo'; - - $dbStatsForm = 'chamilo'; - $dbScormForm = 'chamilo'; - $dbUserForm = 'chamilo'; + $dbPassForm = ''; + $dbNameForm = 'chamilo'; // Extract the path to append to the url if Chamilo is not installed on the web root directory. $urlAppendPath = api_remove_trailing_slash(api_get_path(REL_PATH)); $urlForm = api_get_path(WEB_PATH); $pathForm = api_get_path(SYS_PATH); - - $emailForm = 'webmaster@localhost'; - if (!empty($_SERVER['SERVER_ADMIN'])) { - $emailForm = $_SERVER['SERVER_ADMIN']; - } + $emailForm = 'webmaster@localhost'; + if (!empty($_SERVER['SERVER_ADMIN'])) { + $emailForm = $_SERVER['SERVER_ADMIN']; + } $email_parts = explode('@', $emailForm); if (isset($email_parts[1]) && $email_parts[1] == 'localhost') { $emailForm .= '.localdomain'; @@ -240,19 +208,15 @@ if (!isset($_GET['running'])) { $adminPhoneForm = '(000) 001 02 03'; $institutionForm = 'My Organisation'; $institutionUrlForm = 'http://www.chamilo.org'; - // TODO: A better choice to be tested: - //$languageForm = 'english'; $languageForm = api_get_interface_language(); - $checkEmailByHashSent = 0; + $checkEmailByHashSent = 0; $ShowEmailnotcheckedToStudent = 1; - $userMailCanBeEmpty = 1; - $allowSelfReg = 1; - $allowSelfRegProf = 1; - $enableTrackingForm = 1; - $singleDbForm = 0; - $encryptPassForm = 'sha1'; - $session_lifetime = 360000; + $userMailCanBeEmpty = 1; + $allowSelfReg = 1; + $allowSelfRegProf = 1; + $encryptPassForm = 'sha1'; + $session_lifetime = 360000; } else { foreach ($_POST as $key => $val) { $magic_quotes_gpc = ini_get('magic_quotes_gpc'); @@ -298,6 +262,7 @@ if ($encryptPassForm == '1') { } elseif ($encryptPassForm == '0') { $encryptPassForm = 'none'; } + ?> @@ -313,25 +278,10 @@ if ($encryptPassForm == '1') { @@ -449,7 +344,7 @@ if ($encryptPassForm == '1') { -
    +
    @@ -473,8 +368,6 @@ if ($encryptPassForm == '1') {
    -
    -

    '.get_lang('ChamiloInstallation').' – '.get_lang('Version_').' '.$new_version.'

    '; ?> @@ -500,7 +393,7 @@ if ($encryptPassForm == '1') {
    -
    + " /> - - - - - - - - - - - @@ -560,12 +436,19 @@ if ($encryptPassForm == '1') {

    -
    '.$loginForm; ?>
    '.$passForm; /* TODO: Maybe this password should be hidden too? */ ?>

    @@ -663,30 +552,7 @@ if (@$_POST['step2']) {


    - '; ?> - '.$dbNameForm; ?> - - '; - echo get_lang('StatDB').' : '.$dbStatsForm.''; - if ($installType == 'new') { - echo ' ('.get_lang('ReadWarningBelow').')'; - } - echo '
    '; - echo get_lang('UserDB').' : '.$dbUserForm.''; - if ($installType == 'new') { - echo ' ('.get_lang('ReadWarningBelow').')'; - } - echo '
    '; - } - } - - //echo get_lang('EnableTracking').' : '.($enableTrackingForm ? get_lang('Yes') : get_lang('No')); ?> -

    + '.$dbNameForm; ?>




    - -
    - - -
    -
    -
    -

    !

    - -
    -
    -
    - + '.get_lang( + 'Warning' + ).'
    '.get_lang('TheInstallScriptWillEraseAllTables'), + false + ); + } + ?>
    - + @@ -730,9 +595,7 @@ if (@$_POST['step2']) { '.get_lang('PleaseWaitThisCouldTakeAWhile').' '; - // Push the web server to send these strings before we start the real // installation process flush(); @@ -753,106 +615,21 @@ if (@$_POST['step2']) { } if ($installType == 'update') { - remove_memory_and_time_limits(); - database_server_connect(); - // Initialization of the database connection encoding intentionaly is not done. - // This is the old style for connecting to the database server, that is implemented here. - // Inializing global variables that are to be used by the included scripts. - $dblist = Database::get_databases(); + $manager = testDbConnect( + $dbHostForm, + $dbUsernameForm, + $dbPassForm, + $dbNameForm + ); + $perm = api_get_permissions_for_new_directories(); $perm_file = api_get_permissions_for_new_files(); - if (empty($my_old_version)) { $my_old_version = '1.8.6.2'; } //we guess - - $_configuration['main_database'] = $dbNameForm; - //$urlAppendPath = get_config_param('urlAppend'); Log::notice('Starting migration process from '.$my_old_version.' ('.time().')'); - if ($userPasswordCrypted == '1') { - $userPasswordCrypted = 'md5'; - } elseif ($userPasswordCrypted == '0') { - $userPasswordCrypted = 'none'; - } - - //Setting the single db form - if (in_array($_POST['old_version'], $update_from_version_6)) { - $singleDbForm = get_config_param('singleDbEnabled'); - } else { - $singleDbForm = isset($_configuration['single_database']) ? $_configuration['single_database'] : false; - } - - Log::notice("singledbForm: '$singleDbForm'"); - - Database::query("SET storage_engine = MYISAM;"); - - if (version_compare($my_old_version, '1.8.7', '>=')) { - Database::query("SET SESSION character_set_server='utf8';"); - Database::query("SET SESSION collation_server='utf8_general_ci';"); - //Database::query("SET CHARACTER SET 'utf8';"); // See task #1802. - Database::query("SET NAMES 'utf8';"); - } - switch ($my_old_version) { - case '1.6': - case '1.6.0': - case '1.6.1': - case '1.6.2': - case '1.6.3': - case '1.6.4': - case '1.6.5': - include 'update-db-1.6.x-1.8.0.inc.php'; - include 'update-files-1.6.x-1.8.0.inc.php'; - //intentionally no break to continue processing - case '1.8': - case '1.8.0': - include 'update-db-1.8.0-1.8.2.inc.php'; - //intentionally no break to continue processing - case '1.8.2': - include 'update-db-1.8.2-1.8.3.inc.php'; - //intentionally no break to continue processing - case '1.8.3': - include 'update-db-1.8.3-1.8.4.inc.php'; - include 'update-files-1.8.3-1.8.4.inc.php'; - case '1.8.4': - include 'update-db-1.8.4-1.8.5.inc.php'; - include 'update-files-1.8.4-1.8.5.inc.php'; - case '1.8.5': - include 'update-db-1.8.5-1.8.6.inc.php'; - include 'update-files-1.8.5-1.8.6.inc.php'; - case '1.8.6': - include 'update-db-1.8.6-1.8.6.1.inc.php'; - include 'update-files-1.8.6-1.8.6.1.inc.php'; - case '1.8.6.1': - include 'update-db-1.8.6.1-1.8.6.2.inc.php'; - include 'update-files-1.8.6.1-1.8.6.2.inc.php'; - case '1.8.6.2': - include 'update-db-1.8.6.2-1.8.7.inc.php'; - include 'update-files-1.8.6.2-1.8.7.inc.php'; - // After database conversion to UTF-8, new encoding initialization is necessary - // to be used for the next upgrade 1.8.7[.1] -> 1.8.8. - Database::query("SET SESSION character_set_server='utf8';"); - Database::query("SET SESSION collation_server='utf8_general_ci';"); - //Database::query("SET CHARACTER SET 'utf8';"); // See task #1802. - Database::query("SET NAMES 'utf8';"); - - case '1.8.7': - case '1.8.7.1': - include 'update-db-1.8.7-1.8.8.inc.php'; - include 'update-files-1.8.7-1.8.8.inc.php'; - case '1.8.8': - case '1.8.8.2': - //Only updates the configuration.inc.php with the new version - include 'update-configuration.inc.php'; - case '1.8.8.4': - case '1.8.8.6': - include 'update-db-1.8.8-1.9.0.inc.php'; - //include 'update-files-1.8.8-1.9.0.inc.php'; - //Only updates the configuration.inc.php with the new version - include 'update-configuration.inc.php'; - - break; case '1.9.0': case '1.9.2': case '1.9.4': @@ -862,9 +639,21 @@ if (@$_POST['step2']) { case '1.9.8.1': case '1.9.8.2': case '1.9.10': - include 'update-db-1.9.0-1.10.0.inc.php'; + case '1.9.10.2': + + // Fix type "enum" before running the migration with Doctrine + Database::query("ALTER TABLE course_category MODIFY COLUMN auth_course_child VARCHAR(40) DEFAULT 'TRUE'"); + Database::query("ALTER TABLE course_category MODIFY COLUMN auth_cat_child VARCHAR(40) DEFAULT 'TRUE'"); + Database::query("ALTER TABLE c_quiz_answer MODIFY COLUMN hotspot_type varchar(40) default NULL"); + Database::query("ALTER TABLE c_tool MODIFY COLUMN target varchar(20) NOT NULL default '_self'"); + Database::query("ALTER TABLE c_link MODIFY COLUMN on_homepage char(10) NOT NULL default '0'"); + Database::query("ALTER TABLE c_blog_rating MODIFY COLUMN rating_type char(40) NOT NULL default 'post'"); + Database::query("ALTER TABLE c_survey MODIFY COLUMN anonymous char(10) NOT NULL default '0'"); + + // Migrate using the file Version110.php + migrate('110', 1, $dbNameForm, $dbUsernameForm, $dbPassForm, $dbHostForm, $manager); include 'update-files-1.9.0-1.10.0.inc.php'; - //Only updates the configuration.inc.php with the new version + // Only updates the configuration.inc.php with the new version include 'update-configuration.inc.php'; break; default: @@ -872,34 +661,115 @@ if (@$_POST['step2']) { } } else { set_file_folder_permissions(); - database_server_connect(); - // Initialization of the database encoding to be used. - Database::query("SET storage_engine = MYISAM;"); - Database::query("SET SESSION character_set_server='utf8';"); - Database::query("SET SESSION collation_server='utf8_general_ci';"); - //Database::query("SET CHARACTER SET 'utf8';"); // See task #1802. - Database::query("SET NAMES 'utf8';"); + $manager = testDbConnect( + $dbHostForm, + $dbUsernameForm, + $dbPassForm, + null + ); + + $dbNameForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbNameForm); + + // Create database + $createDatabase = true; + $databases = $manager->getConnection()->getSchemaManager()->listDatabases(); + + if (in_array($dbNameForm, $databases)) { + $createDatabase = false; + } + + // Create database + if ($createDatabase) { + //$manager->getConnection()->getSchemaManager()->dropAndCreateDatabase($dbNameForm); + //$manager->getConnection()->getSchemaManager()->createDatabase($dbNameForm); + } + // Drop the database anyways + $manager->getConnection()->getSchemaManager()->dropAndCreateDatabase($dbNameForm); + + $manager = testDbConnect( + $dbHostForm, + $dbUsernameForm, + $dbPassForm, + $dbNameForm + ); + + $metadatas = $manager->getMetadataFactory()->getAllMetadata(); + $schema = $manager->getConnection()->getSchemaManager()->createSchema(); + + // Create database + $tool = new \Doctrine\ORM\Tools\SchemaTool($manager); + $tool->createSchema($metadatas); + + // Inserting data + $data = file_get_contents('data.sql'); + $result = $manager->getConnection()->prepare($data); + $result->execute(); + $result->closeCursor(); + + // Create users + switch ($encryptPassForm) { + case 'md5' : + $passToStore = md5($passForm); + break; + case 'sha1' : + $passToStore = sha1($passForm); + break; + case 'none' : + default: + $passToStore = $passForm; + break; + } + + $sql = "INSERT INTO user (user_id, lastname, firstname, username, password, auth_source, email, status, official_code, phone, creator_id, registration_date, expiration_date,active,openid,language) VALUES + (1, '$adminLastName','$adminFirstName','$loginForm','$passToStore','".PLATFORM_AUTH_SOURCE."','$emailForm',1,'ADMIN','$adminPhoneForm',1,NOW(),NULL,'1',NULL,'$languageForm'), + (2, 'Anonymous', 'Joe', '', '', 'platform', 'anonymous@localhost', 6, 'anonymous', NULL, 1, NOW(), NULL, 1,NULL,'$languageForm')"; + Database::query($sql); + + $sql = "INSERT INTO admin VALUES(1, 1)"; + Database::query($sql); + + // The chosen during the installation platform language should be enabled. + $sql = "UPDATE language SET available=1 WHERE dokeos_folder = '$languageForm'"; + Database::query($sql); + + // Install settings + installSettings( + $institutionForm, + $institutionUrlForm, + $campusForm, + $emailForm, + $adminLastName, + $adminFirstName, + $languageForm, + $allowSelfReg, + $allowSelfRegProf + ); + + lockSettings(); + update_dir_and_files_permissions(); - include 'install_db.inc.php'; include 'install_files.inc.php'; } display_after_install_message($installType); - //Hide the "please wait" message sent previously + + // Hide the "please wait" message sent previously echo ''; } elseif (@$_POST['step1'] || $badUpdatePath) { //STEP 1 : REQUIREMENTS //make sure that proposed path is set, shouldn't be necessary but... - if (empty($proposedUpdatePath)) { $proposedUpdatePath = $_POST['updatePath']; } - display_requirements($installType, $badUpdatePath, $proposedUpdatePath, $update_from_version_8, $update_from_version_6); + if (empty($proposedUpdatePath)) { + $proposedUpdatePath = $_POST['updatePath']; + } + display_requirements($installType, $badUpdatePath, $proposedUpdatePath, $update_from_version_8); } else { // This is the start screen. display_language_selection(); } ?> - +
    diff --git a/main/install/install.class.php b/main/install/install.class.php deleted file mode 100755 index 06340cf715..0000000000 --- a/main/install/install.class.php +++ /dev/null @@ -1,16 +0,0 @@ - for the Univesity of Geneva - */ -class Install -{ - static function message($message) - { - echo '
    ' . $message . '
    '; - } - -} \ No newline at end of file diff --git a/main/install/install.lib.php b/main/install/install.lib.php index a67318d1f3..6785a8e86a 100755 --- a/main/install/install.lib.php +++ b/main/install/install.lib.php @@ -11,9 +11,6 @@ */ /* CONSTANTS */ - -define('SYSTEM_MAIN_DATABASE_FILE', 'database.sql'); -define('COUNTRY_DATA_FILENAME', 'country_data.csv'); define('COURSES_HTACCESS_FILENAME', 'htaccess.dist'); define('SYSTEM_CONFIG_FILENAME', 'configuration.dist.php'); @@ -41,10 +38,7 @@ function isAlreadyInstalledSystem() require $current_config_file; $current_version = null; - if (isset($_configuration['dokeos_version'])) { - $current_version = trim($_configuration['dokeos_version']); - } - if (empty($current_version)) { + if (isset($_configuration['system_version'])) { $current_version = trim($_configuration['system_version']); } @@ -108,10 +102,10 @@ function checkPhpSettingExists($phpSetting) if (ini_get($phpSetting) != "") { return ini_get($phpSetting); } + return false; } - /** * Returns a textual value ('ON' or 'OFF') based on a requester 2-state ini- configuration setting. * @@ -282,7 +276,6 @@ function set_file_folder_permissions() { @chmod('.', 0755); //set permissions on install dir @chmod('..', 0755); //set permissions on parent dir of install dir - @chmod('country_data.csv.csv', 0755); } /** @@ -311,13 +304,7 @@ function write_system_config_file($path) global $dbHostForm; global $dbUsernameForm; global $dbPassForm; - global $enableTrackingForm; - global $singleDbForm; - global $dbPrefixForm; global $dbNameForm; - global $dbStatsForm; - global $dbScormForm; - global $dbUserForm; global $urlForm; global $pathForm; global $urlAppendPath; @@ -332,29 +319,21 @@ function write_system_config_file($path) $root_sys = api_add_trailing_slash(str_replace('\\', '/', realpath($pathForm))); $content = file_get_contents(dirname(__FILE__).'/'.SYSTEM_CONFIG_FILENAME); - $config['{DATE_GENERATED}'] = date('r'); - $config['{DATABASE_HOST}'] = $dbHostForm; - $config['{DATABASE_USER}'] = $dbUsernameForm; - $config['{DATABASE_PASSWORD}'] = $dbPassForm; - $config['TRACKING_ENABLED'] = trueFalse($enableTrackingForm); - $config['SINGLE_DATABASE'] = trueFalse($singleDbForm); - $config['{COURSE_TABLE_PREFIX}'] = ($singleDbForm ? 'crs_' : ''); - $config['{DATABASE_GLUE}'] = ($singleDbForm ? '_' : '`.`'); - $config['{DATABASE_PREFIX}'] = ''; - $config['{DATABASE_MAIN}'] = $dbNameForm; - $config['{DATABASE_STATS}'] = $dbNameForm; - $config['{DATABASE_SCORM}'] = $dbNameForm; - $config['{DATABASE_PERSONAL}'] = $dbNameForm; - $config['{ROOT_WEB}'] = $urlForm; - $config['{ROOT_SYS}'] = $root_sys; - $config['{URL_APPEND_PATH}'] = $urlAppendPath; - $config['{PLATFORM_LANGUAGE}'] = $languageForm; - $config['{SECURITY_KEY}'] = md5(uniqid(rand().time())); - $config['{ENCRYPT_PASSWORD}'] = $encryptPassForm; - - $config['SESSION_LIFETIME'] = $session_lifetime; - $config['{NEW_VERSION}'] = $new_version; - $config['NEW_VERSION_STABLE'] = trueFalse($new_version_stable); + $config['{DATE_GENERATED}'] = date('r'); + $config['{DATABASE_HOST}'] = $dbHostForm; + $config['{DATABASE_USER}'] = $dbUsernameForm; + $config['{DATABASE_PASSWORD}'] = $dbPassForm; + $config['{DATABASE_MAIN}'] = $dbNameForm; + $config['{ROOT_WEB}'] = $urlForm; + $config['{ROOT_SYS}'] = $root_sys; + $config['{URL_APPEND_PATH}'] = $urlAppendPath; + $config['{PLATFORM_LANGUAGE}'] = $languageForm; + $config['{SECURITY_KEY}'] = md5(uniqid(rand().time())); + $config['{ENCRYPT_PASSWORD}'] = $encryptPassForm; + + $config['SESSION_LIFETIME'] = $session_lifetime; + $config['{NEW_VERSION}'] = $new_version; + $config['NEW_VERSION_STABLE'] = trueFalse($new_version_stable); foreach ($config as $key => $value) { $content = str_replace($key, $value, $content); @@ -461,6 +440,7 @@ function get_config_param($param, $updatePath = '') if (empty($updatePath) && !empty($_POST['updatePath'])) { $updatePath = $_POST['updatePath']; } + if (empty($updatePath)) { $updatePath = api_get_path(SYS_PATH); } @@ -469,11 +449,9 @@ function get_config_param($param, $updatePath = '') if (empty($updateFromConfigFile)) { // If update from previous install was requested, - // try to recover old config file from dokeos 1.8.x. + // try to recover config file from Chamilo 1.9.x if (file_exists($updatePath.'main/inc/conf/configuration.php')) { $updateFromConfigFile = 'main/inc/conf/configuration.php'; - } elseif (file_exists($updatePath.'claroline/inc/conf/claro_main.conf.php')) { - $updateFromConfigFile = 'claroline/inc/conf/claro_main.conf.php'; } else { // Give up recovering. //error_log('Chamilo Notice: Could not find previous config file at '.$updatePath.'main/inc/conf/configuration.php nor at '.$updatePath.'claroline/inc/conf/claro_main.conf.php in get_config_param(). Will start new config (in '.__FILE__.', line '.__LINE__.')', 0); @@ -481,124 +459,23 @@ function get_config_param($param, $updatePath = '') } } - if (file_exists($updatePath.$updateFromConfigFile) && !is_dir($updatePath.$updateFromConfigFile)) { - - // The parameter was not found among the global variables, so look into the old configuration file. - - // Make sure the installedVersion file is read first so it is overwritten - // by the config file if the config file contains the version (from 1.8.4). - $config_data_2 = array(); - if (file_exists($updatePath.$updateFromInstalledVersionFile)) { - $config_data_2 = file_to_array($updatePath.$updateFromInstalledVersionFile); - } - $configFile = array(); - $config_data = file_to_array($updatePath.$updateFromConfigFile); - $config_data = array_merge($config_data, $config_data_2); - $val = ''; - - // Parse the configuration file, statement by statement (line by line, actually). - foreach ($config_data as $php_statement) { - - if (strpos($php_statement, '=') !== false) { - // Variable assignment statement have been detected (probably). - // It is expected to be as follows: - // $variable = 'some_value'; // A comment that is not mandatory. - - // Split the statement into its left and right sides. - $php_statement = explode('=', $php_statement); - $variable = trim($php_statement[0]); - $value = $php_statement[1]; - - if (substr($variable, 0, 1) == '$') { - // We have for sure a php variable assignment detected. - - // On the left side: Retrieve the pure variable's name - $variable = trim(str_replace('$', '', $variable)); - - // On the right side: Remove the comment, if it exists. - list($value) = explode(' //', $value); - // Remove extra whitespace, if any. Remove the trailing semicolon (;). - $value = substr(trim($value), 0, -1); - // Remove surroundig quotes, restore escaped quotes. - $value = str_replace('\"', '"', preg_replace('/^"|"$/', '', $value)); - $value = str_replace('\'', '"', preg_replace('/^\'|\'$/', '', $value)); - - if (strtolower($value) == 'true') { - - // A boolean true value have been recognized. - $value = 1; - - } elseif (strtolower($value) == 'false') { - - // A boolean false value have been recognized. - $value = 0; - - } else { - - // Probably we have a string value, but also we have to check - // possible string concatenations that may include string values - // and other configuration variables. I this case we have to - // get the calculated result of the concatenation. - $implode_string = ' '; - if (!strstr($value, '." ".') && strstr($value, '.$')) { - // Yes, there is concatenation, insert a special separator string. - $value = str_replace('.$', '." ".$', $value); - $implode_string = ''; - } - - // Split the concatenated values, if they are more than one. - $sub_strings = explode('." ".', $value); - - // Seek for variables and retrieve their values. - foreach ($sub_strings as $key => & $sub_string) { - if (preg_match('/^\$[a-zA-Z_][a-zA-Z0-9_]*$/', $sub_string)) { - // A variable has been detected, read it by recursive call. - $sub_string = get_config_param(str_replace('$', '', $sub_string)); - } - } - - // Concatenate everything into the final, the calculated string value. - $value = implode($implode_string, $sub_strings); - } - - // Cache the result value. - $configFile[$variable] = $value; - - $a = explode("'", $variable); - $key_tmp = isset($a[1]) ? $a[1] : null; - if ($key_tmp == $param) { - $val = $value; - } - } - } - } + if (file_exists($updatePath.$updateFromConfigFile) && + !is_dir($updatePath.$updateFromConfigFile) + ) { + require $updatePath.$updateFromConfigFile; + $config = new Zend\Config\Config($_configuration); + return $config->get($param); } - if ($param == 'dbGlu' && empty($val)) { - return '`.`'; - } - //Special treatment for dokeos_version parameter due to Dokeos 1.8.3 have the dokeos_version in the main/inc/installedVersion.inc.php file - if ($param == 'dokeos_version') { - //dokeos_version from configuration.php if empty - $dokeos_version = $val; - - if (empty($dokeos_version)) { - //checking the dokeos_version value exists in main/inc/installedVersion.inc.php - if (file_exists($updatePath.'main/inc/installedVersion.inc.php')) { - $updateFromInstalledVersionFile = $updatePath.'main/inc/installedVersion.inc.php'; - require ($updateFromInstalledVersionFile); //there are only 2 variables here: $stable & $dokeos_version - $stable = false; - } - } - return $dokeos_version; + error_log('Config array could not be found in get_config_param()', 0); + return null; + + /*if (file_exists($updatePath.$updateFromConfigFile)) { + return $val; } else { - if (file_exists($updatePath.$updateFromConfigFile)) { - return $val; - } else { - error_log('Config array could not be found in get_config_param()', 0); - return null; - } - } + error_log('Config array could not be found in get_config_param()', 0); + return null; + }*/ } /* DATABASE RELATED FUNCTIONS */ @@ -612,13 +489,8 @@ function get_config_param($param, $updatePath = '') * @param string $param Name of param we want * @return mixed The parameter value or null if not found */ -function get_config_param_from_db($host, $login, $pass, $dbName, $param = '') +function get_config_param_from_db($param = '') { - - Database::connect(array('server' => $host, 'username' => $login, 'password' => $pass)); - Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5) - Database::select_db($dbName); - if (($res = Database::query("SELECT * FROM settings_current WHERE variable = '$param'")) !== false) { if (Database::num_rows($res) > 0) { $row = Database::fetch_array($res); @@ -628,49 +500,6 @@ function get_config_param_from_db($host, $login, $pass, $dbName, $param = '') return null; } -/** - * Connects to the database server. - */ -function database_server_connect() -{ - global $dbHostForm, $dbUsernameForm, $dbPassForm; - if (($res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm))) === false) { - $no = Database::errno(); - $msg = Database::error(); - echo '
    #'.$no.': '.$msg.'
    '; - echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.

    '. - get_lang('PleaseCheckTheseValues').' :

    '. - ''.get_lang('DBHost').' : '.$dbHostForm.'
    '. - ''.get_lang('DBLogin').' : '.$dbUsernameForm.'
    '. - ''.get_lang('DBPassword').' : '.$dbPassForm.'

    '. - get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'.'. - '

    '. - '
    '; - exit (); - } - @Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5) -} - -/** - * Database exists for the MYSQL user - * @param string $database_name The name of the database to check - * @return boolean - */ -function database_exists($database_name) -{ - if (empty($database_name)) { - return false; - } - $select_database = @Database::select_db($database_name); - $show_database = false; - $sql = "SHOW DATABASES LIKE '".addslashes($database_name)."'"; - $result = @Database::query($sql); - if (Database::num_rows($result)) { - $show_database = true; - } - return $select_database || $show_database; -} - /** * In step 3. Tests establishing connection to the database server. * If it's a single database environment the function checks if the database exist. @@ -678,346 +507,22 @@ function database_exists($database_name) * @param string $dbHostForm DB host * @param string $dbUsernameForm DB username * @param string $dbPassForm DB password - * @return int 1 when there is no problem; - * 0 when a new database is impossible to be created, then the single/multiple database configuration is impossible too - * -1 when there is no connection established. + * @return \Doctrine\ORM\EntityManager */ function testDbConnect($dbHostForm, $dbUsernameForm, $dbPassForm, $dbNameForm) { - /*$dbParams = array( + $dbParams = array( 'driver' => 'pdo_mysql', 'host' => $dbHostForm, 'user' => $dbUsernameForm, 'password' => $dbPassForm, - '' + 'dbname' => $dbNameForm ); - $config = Database::getDoctrineConfig(); - $entityManager = \Doctrine\ORM\EntityManager::create($dbParams, $config); - $dbConnect = 1; - try { - $entityManager->getConnection()->connect(); - } catch (Exception $e) { - echo $e->getMessage(); - $dbConnect = -1; - }*/ - - //Checking user credentials - if (@Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm)) !== false) { - $dbConnect = 1; - } else { - $dbConnect = -1; - } - - return $dbConnect; //return 1, if no problems, "0" if, in case we can't create a new DB and "-1" if there is no connection. -} - -/** - * Fills the countries table with a list of countries. - * @param string $trackCountriesTable Table name - */ -function fill_track_countries_table($trackCountriesTable) -{ - $file_path = dirname(__FILE__).'/'.COUNTRY_DATA_FILENAME; - $countries = file($file_path); - $addCountrySql = "INSERT INTO $trackCountriesTable (id, code, country, counter) VALUES "; - foreach ($countries as $line) { - $elems = explode(',', $line); - $addCountrySql .= '('.intval($elems[0]).',\''.Database::escape_string($elems[1]).'\',\''.Database::escape_string($elems[2]).'\','.intval($elems[3]).'),'; - } - $addCountrySql = substr($addCountrySql, 0, -1); - @Database::query($addCountrySql); -} - -/** - * Creates the structure of the main database and fills it - * with data. Placeholder symbols in the main database file - * have to be replaced by the settings entered by the user during installation. - * - * @param array $installation_settings list of settings entered by the user - * @param string $dbScript optional path about the script for database - * @return void - */ -function load_main_database($installation_settings, $dbScript = '') -{ - if (!empty($dbScript)) { - if (file_exists($dbScript)) { - $sql_text = file_get_contents($dbScript); - } - } else { - $dbScript = api_get_path(SYS_CODE_PATH).'install/'.SYSTEM_MAIN_DATABASE_FILE; - if (file_exists($dbScript)) { - $sql_text = file_get_contents($dbScript); - } - } - - //replace symbolic parameters with user-specified values - foreach ($installation_settings as $key => $value) { - $sql_text = str_replace($key, Database::escape_string($value), $sql_text); - } - parse_sql_queries($sql_text); -} - -/** - * Creates the structure of the stats database - * @param string $dbScript Name of the file containing the SQL script inside the install directory - */ -function load_database_script($dbScript) -{ - $dbScript = api_get_path(SYS_CODE_PATH).'install/'.$dbScript; - if (file_exists($dbScript)) { - $sql_text = file_get_contents($dbScript); - } - parse_sql_queries($sql_text); -} -/** - * Parse SQL queries - * @param string $sql_text SQL code - */ -function parse_sql_queries($sql_text) -{ + $database = new \Database(); + $database->connect($dbParams); - //split in array of sql strings - $sql_instructions = array(); - split_sql_file($sql_instructions, $sql_text); - - //execute the sql instructions - $count = count($sql_instructions); - for ($i = 0; $i < $count; $i++) { - $this_sql_query = $sql_instructions[$i]['query']; - Database::query($this_sql_query); - //UTF8 fix see #5678 - /* - if (strpos(strtolower($this_sql_query), 'create table') === false) { - Database::query($this_sql_query); - } else { - //$this_sql_query .= substr($this_sql_query, strlen($this_sql_query), strlen($this_sql_query)-1); - $this_sql_query .= ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci '; - Database::query($this_sql_query); - }*/ - } -} - - -/** - * Function copied and adapted from phpMyAdmin 2.6.0 PMA_splitSqlFile (also GNU GPL) - * Removes comment lines and splits up large sql files into individual queries - * Last revision: September 23, 2001 - gandon - * @param array $ret the split sql commands - * @param string $sql the sql commands - * @return boolean always true - */ -function split_sql_file(&$ret, $sql) -{ - // do not trim, see bug #1030644 - //$sql = trim($sql); - $sql = rtrim($sql, "\n\r"); - $sql_len = strlen($sql); - $char = ''; - $string_start = ''; - $in_string = false; - $nothing = true; - $time0 = time(); - - for ($i = 0; $i < $sql_len; ++$i) { - $char = $sql[$i]; - - // We are in a string, check for not escaped end of strings except for - // back-quotes that can't be escaped - if ($in_string) { - for (;;) { - $i = strpos($sql, $string_start, $i); - // No end of string found -> add the current substring to the - // returned array - if (!$i) { - $ret[] = $sql; - return true; - } elseif ($string_start == '`' || $sql[$i - 1] != '\\') { - // Back-quotes or no backslashes before quotes: it's indeed the - // end of the string -> exit the loop - $string_start = ''; - $in_string = false; - break; - } else { // one or more Backslashes before the presumed end of string... - // ... first checks for escaped backslashes - $j = 2; - $escaped_backslash = false; - while ($i - $j > 0 && $sql[$i - $j] == '\\') { - $escaped_backslash = !$escaped_backslash; - $j++; - } - // ... if escaped backslashes: it's really the end of the - // string -> exit the loop - if ($escaped_backslash) { - $string_start = ''; - $in_string = false; - break; - } else { // ... else loop - $i++; - } - } // end if...elseif...else - } // end for - // end if (in string) - - // lets skip comments (/*, -- and #) - } elseif (($char == '-' && $sql_len > $i + 2 && $sql[$i + 1] == '-' && $sql[$i + 2] <= ' ') || - $char == '#' || - ($char == '/' && $sql_len > $i + 1 && $sql[$i + 1] == '*') - ) { - $i = strpos($sql, $char == '/' ? '*/' : "\n", $i); - // didn't we hit end of string? - if ($i === false) { - break; - } - if ($char == '/') { - $i++; - } - - // We are not in a string, first check for delimiter... - } elseif ($char == ';') { - // if delimiter found, add the parsed part to the returned array - $ret[] = array('query' => substr($sql, 0, $i), 'empty' => $nothing); - $nothing = true; - $sql = ltrim(substr($sql, min($i + 1, $sql_len))); - $sql_len = strlen($sql); - if ($sql_len) { - $i = -1; - } else { - // The submitted statement(s) end(s) here - return true; - } - // end elseif (is delimiter) - - // ... then check for start of a string,... - } elseif (($char == '"') || ($char == '\'') || ($char == '`')) { - $in_string = true; - $nothing = false; - $string_start = $char; - // end elseif (is start of string) - - } elseif ($nothing) { - $nothing = false; - } - - // Send a fake header each 30 sec. to bypass browser timeout - $time1 = time(); - if ($time1 >= $time0 + 30) { - $time0 = $time1; - header('X-pmaPing: Pong'); - } // end if - } // end for - - // add any rest to the returned array - if (!empty($sql) && preg_match('@[^[:space:]]+@', $sql)) { - $ret[] = array('query' => $sql, 'empty' => $nothing); - } - - return true; -} // end of the 'split_sql_file()' function - -/** - * Get an SQL file's contents - * - * This function bases its parsing on the pre-set format of the specific SQL files in - * the install/upgrade procedure: - * Lines starting with "--" are comments (but need to be taken into account as they also hold sections names) - * Other lines are considered to be one-line-per-query lines (this is checked quickly by this function) - * @param string File to parse (in the current directory) - * @param string Section to return - * @param boolean Print (true) or hide (false) error texts when they occur - * @return array Array of SQL statements - */ -function get_sql_file_contents($file, $section, $print_errors = true) -{ - //check given parameters - if (empty($file)) { - $error = "Missing name of file to parse in get_sql_file_contents()"; - if ($print_errors) { - echo $error; - } - return false; - } - if (!in_array($section, array('main', 'user', 'stats', 'scorm', 'course'))) { - $error = "Section '$section' is not authorized in get_sql_file_contents()"; - if ($print_errors) { - echo $error; - } - return false; - } - $filePath = getcwd().'/'.$file; - if (!is_file($filePath) or !is_readable($filePath)) { - $error = "File $filePath not found or not readable in get_sql_file_contents()"; - if ($print_errors) { - echo $error; - } - return false; - } - //read the file in an array - // Empty lines should not be executed as SQL statements, because errors occur, see Task #2167. - $fileContents = file($filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); - if (!is_array($fileContents) or count($fileContents) < 1) { - $error = "File $filePath looks empty in get_sql_file_contents()"; - if ($print_errors) { - echo $error; - } - return false; - } - - //prepare the resulting array - $section_contents = array(); - $record = false; - foreach ($fileContents as $index => $line) { - if (substr($line, 0, 2) == '--') { - //This is a comment. Check if section name, otherwise ignore - $result = array(); - if (preg_match('/^-- xx([A-Z]*)xx/', $line, $result)) { //we got a section name here - if ($result[1] == strtoupper($section)) { - //we have the section we are looking for, start recording - $record = true; - } else { - //we have another section's header. If we were recording, stop now and exit loop - if ($record) { - break; - } - $record = false; - } - } - } else { - if ($record) { - if (!empty($line)) { - $section_contents[] = $line; - } - } - } - } - //now we have our section's SQL statements group ready, return - return $section_contents; -} - -/** - * Adds a new document to the database - specific to version 1.8.0 - * - * @param array $_course - * @param string $path - * @param string $fileType - * @param int $fileSize - * @param string $title - * @return id if inserted document - */ -function add_document_180($_course, $path, $fileType, $fileSize, $title, $comment = null) -{ - $table_document = Database::get_course_table(TABLE_DOCUMENT, $_course['dbName']); - $sql = "INSERT INTO $table_document - (`path`,`filetype`,`size`,`title`, `comment`) - VALUES ('$path','$fileType','$fileSize','". - Database::escape_string($title)."', '$comment')"; - if (Database::query($sql)) { - //display_message("Added to database (id ".Database::insert_id().")!"); - return Database::insert_id(); - } else { - //display_error("The uploaded file could not be added to the database (".Database::error().")!"); - return false; - } + return $database->getManager(); } /* DISPLAY FUNCTIONS */ @@ -1130,8 +635,7 @@ function display_language_selection() * @param string $installType * @param boolean $badUpdatePath * @param string The updatePath given (if given) - * @param array $update_from_version_8 The different subversions from version 1.8 - * @param array $update_from_version_6 The different subversions from version 1.6 + * @param array $update_from_version_8 The different subversions from version 1.9 * * @author unknow * @author Patrick Cool , Ghent University @@ -1140,8 +644,7 @@ function display_requirements( $installType, $badUpdatePath, $updatePath = '', - $update_from_version_8 = array(), - $update_from_version_6 = array() + $update_from_version_8 = array() ) { global $_setting; echo '

    '.display_step_sequence().get_lang('Requirements')."

    "; @@ -1463,7 +966,7 @@ function display_requirements( if ($badUpdatePath) { ?>
    !
    - Chamilo . + Chamilo .
    '.$value.''; } echo ''; - } - - // Check wether a Chamilo configuration file already exists. - elseif (file_exists(api_get_path(CONFIGURATION_PATH).'configuration.php')) { + } elseif (file_exists(api_get_path(CONFIGURATION_PATH).'configuration.php')) { + // Check wether a Chamilo configuration file already exists. echo '

    '; echo get_lang('WarningExistingLMSInstallationDetected'); echo '

    '; @@ -1589,16 +1090,10 @@ function display_requirements( '.get_lang('UpgradeFromLMS18x').''; - echo ' '; + echo ' > '.get_lang('UpgradeFromLMS19x').''; + echo '

    '; } } @@ -1839,64 +1334,20 @@ function display_database_settings_form( $dbHostForm, $dbUsernameForm, $dbPassForm, - $dbPrefixForm, - $enableTrackingForm, - $singleDbForm, - $dbNameForm, - $dbStatsForm, - $dbScormForm, - $dbUserForm + $dbNameForm ) { - if ($installType == 'update') { - global $_configuration, $update_from_version_6; - - if (in_array($_POST['old_version'], $update_from_version_6)) { - $dbHostForm = get_config_param('dbHost'); - $dbUsernameForm = get_config_param('dbLogin'); - $dbPassForm = get_config_param('dbPass'); - $dbPrefixForm = get_config_param('dbNamePrefix'); - $enableTrackingForm = get_config_param('is_trackingEnabled'); - $singleDbForm = get_config_param('singleDbEnabled'); - $dbHostForm = get_config_param('mainDbName'); - $dbStatsForm = get_config_param('statsDbName'); - $dbScormForm = get_config_param('scormDbName'); - $dbUserForm = get_config_param('user_personal_database'); - $dbScormExists = true; - } else { - $dbHostForm = $_configuration['db_host']; - $dbUsernameForm = $_configuration['db_user']; - $dbPassForm = $_configuration['db_password']; - $dbPrefixForm = $_configuration['db_prefix']; - $enableTrackingForm = $_configuration['tracking_enabled']; - $singleDbForm = $_configuration['single_database']; - $dbNameForm = $_configuration['main_database']; - $dbStatsForm = $_configuration['statistics_database']; - $dbScormForm = $_configuration['scorm_database']; - $dbUserForm = $_configuration['user_personal_database']; - $dbScormExists = true; - } - - if (empty($dbScormForm)) { - if ($singleDbForm) { - $dbScormForm = $dbNameForm; - } else { - $dbScormForm = $dbPrefixForm.'scorm'; - $dbScormExists = false; - } - } + global $_configuration; + $dbHostForm = $_configuration['db_host']; + $dbUsernameForm = $_configuration['db_user']; + $dbPassForm = $_configuration['db_password']; + $dbNameForm = $_configuration['main_database']; - if (empty($dbUserForm)) { - $dbUserForm = $singleDbForm ? $dbNameForm : $dbPrefixForm.'chamilo_user'; - } echo '

    ' . display_step_sequence() .get_lang('DBSetting') . '

    '; echo '
    '; echo get_lang('DBSettingUpgradeIntro'); echo '
    '; } else { - if (empty($dbPrefixForm)) { //make sure there is a default value for db prefix - $dbPrefixForm = ''; - } echo '

    ' . display_step_sequence() .get_lang('DBSetting') . '

    '; echo '
    '; echo get_lang('DBSettingIntro'); @@ -1928,29 +1379,23 @@ function display_database_settings_form( $example_password = get_lang('EG').' '.api_generate_password(); displayDatabaseParameter($installType, get_lang('DBPassword'), 'dbPassForm', $dbPassForm, $example_password); - echo ''; - - $style = ''; - if ($installType == INSTALL_TYPE_UPDATE) { - $style = ''; - } - //Database Name fix replace weird chars if ($installType != INSTALL_TYPE_UPDATE) { $dbNameForm = str_replace(array('-','*', '$', ' ', '.'), '', $dbNameForm); $dbNameForm = replace_dangerous_char($dbNameForm); } - displayDatabaseParameter($installType, get_lang('MainDB'), 'dbNameForm', $dbNameForm, ' ', null, 'id="optional_param1" '.$style); + displayDatabaseParameter( + $installType, + get_lang('MainDB'), + 'dbNameForm', + $dbNameForm, + ' ', + null, + 'id="optional_param1"' + ); - //Only for updates we show this options - if ($installType == INSTALL_TYPE_UPDATE) { - displayDatabaseParameter($installType, get_lang('StatDB'), 'dbStatsForm', $dbStatsForm, ' ', null, 'id="optional_param2" '.$style); - if ($installType == INSTALL_TYPE_UPDATE && in_array($_POST['old_version'], $update_from_version_6)) { - displayDatabaseParameter($installType, get_lang('ScormDB'), 'dbScormForm', $dbScormForm, ' ', null, 'id="optional_param3" '.$style); - } - displayDatabaseParameter($installType, get_lang('UserDB'), 'dbUserForm', $dbUserForm, ' ', null, 'id="optional_param4" '.$style); - } + if ($installType != INSTALL_TYPE_UPDATE) { ?> @@ -1961,45 +1406,35 @@ function display_database_settings_form( + + '.get_lang('ADatabaseWithTheSameNameAlreadyExists').'
    '; - } else { - if ($dbConnect == -1) { - $database_exists_text = '
    '.sprintf(get_lang('UserXCantHaveAccessInTheDatabaseX'), $dbUsernameForm, $dbNameForm).'
    '; - } else { - //Try to create the database - $user_can_create_databases = false; - $multipleDbCheck = @Database::query("CREATE DATABASE ".mysql_real_escape_string($dbNameForm)); - if ($multipleDbCheck !== false) { - $multipleDbCheck = @Database::query("DROP DATABASE IF EXISTS ".mysql_real_escape_string($dbNameForm)); - $user_can_create_databases = true; - } - - if ($user_can_create_databases) { - $database_exists_text = '
    '.sprintf(get_lang('DatabaseXWillBeCreated'), $dbNameForm, $dbUsernameForm).'
    '; - } else { - $dbConnect = 0; - $database_exists_text = '
    '.sprintf(get_lang('DatabaseXCantBeCreatedUserXDoestHaveEnoughPermissions'), $dbNameForm, $dbUsernameForm).'
    '; - } + $manager = null; + try { + $manager = testDbConnect( + $dbHostForm, + $dbUsernameForm, + $dbPassForm, + null + ); + $databases = $manager->getConnection()->getSchemaManager()->listDatabases(); + if (in_array($dbNameForm, $databases)) { + $database_exists_text = '
    '.get_lang('ADatabaseWithTheSameNameAlreadyExists').'
    '; } + } catch (Exception $e) { + $database_exists_text = $e->getMessage(); } - if ($dbConnect == 1): ?> + if ($manager->getConnection()->isConnected()): ?>
    - Database host:
    - Database server version:
    - Database client version:
    - Database protocol version: + Database host: getConnection()->getHost(); ?>
    + Database driver: getConnection()->getDriver()->getName(); ?>
    @@ -2009,8 +1444,6 @@ function display_database_settings_form(

    - Database error:
    - '; ?>
    @@ -2025,7 +1458,7 @@ function display_database_settings_form(   - + @@ -2095,16 +1528,16 @@ function display_configuration_settings_form( echo ''.get_lang('Administrator').''; echo ''; - //Parameter 1: administrator's login + // Parameter 1: administrator's login display_configuration_parameter($installType, get_lang('AdminLogin'), 'loginForm', $loginForm, $installType == 'update'); - //Parameter 2: administrator's password + // Parameter 2: administrator's password if ($installType != 'update') { display_configuration_parameter($installType, get_lang('AdminPass'), 'passForm', $passForm, false); } - //Parameters 3 and 4: administrator's names + // Parameters 3 and 4: administrator's names if (api_is_western_name_order()) { display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName); display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName); @@ -2152,7 +1585,6 @@ function display_configuration_settings_form( } echo ""; - //Parameter 9: campus name display_configuration_parameter($installType, get_lang('CampusName'), 'campusForm', $campusForm); @@ -2251,7 +1683,9 @@ function display_after_install_message($installType) echo ''; ?>
    - + + + $dbNameForm, + 'user' => $dbUsernameForm, + 'password' => $dbPassForm, + 'host' => $dbHostForm, + 'driver' => 'pdo_mysql', + 'charset' => 'utf8', + 'driverOptions' => array( + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8' + ) + )); + + $config = new \Doctrine\DBAL\Migrations\Configuration\Configuration($db); + + // Table name that will store migrations log (will be created automatically, default name is: doctrine_migration_versions) + $config->setMigrationsTableName('version'); + // Namespace of your migration classes, do not forget escape slashes, do not add last slash + $config->setMigrationsNamespace('Chamilo\CoreBundle\Migrations\Schema\v'.$chamiloVersion); + // Directory where your migrations are located + + $config->setMigrationsDirectory(api_get_path(SYS_PATH).'src/Chamilo/CoreBundle/Migrations/Schema/v'.$chamiloVersion); + // Load your migrations + $config->registerMigrationsFromDirectory($config->getMigrationsDirectory()); + + $migration = new \Doctrine\DBAL\Migrations\Migration($config); + $migrations = $config->getMigrations(); + /** @var Doctrine\DBAL\Migrations\Version $migration */ + foreach ($migrations as $migrationItem) { + $migrationItem->getMigration()->setEntityManager($manager); + } + + //$to = '110'; + // Retrieve SQL queries that should be run to migrate you schema to $to version, if $to == null - schema will be migrated to latest version + $versions = $migration->getSql($to); + if ($debug) { + $nl = '
    '; + foreach ($versions as $version => $queries) { + echo 'VERSION: '.$version.$nl; + echo '----------------------------------------------'.$nl.$nl; + foreach ($queries as $query) { + echo $query.$nl; + } + echo $nl.$nl; + } + } + + try { + $migration->migrate($to); // Execute migration! + if ($debug) { + echo 'DONE'.$nl; + } + } catch (Exception $ex) { + if ($debug) { + echo 'ERROR: '.$ex->getMessage().$nl; + } + } +} + + diff --git a/main/install/install_db.inc.php b/main/install/install_db.inc.php deleted file mode 100755 index 80a1f493d2..0000000000 --- a/main/install/install_db.inc.php +++ /dev/null @@ -1,126 +0,0 @@ - 0) THEN SET @s = CONCAT('DROP INDEX ' , i_name , ' ON ' , t_name ); PREPARE stmt FROM @s; EXECUTE stmt; END IF; END; - -CALL drop_index('settings_current', 'unique_setting'); -CALL drop_index('settings_options', 'unique_setting_option'); - -ALTER TABLE user_friend RENAME TO user_rel_user; -ALTER TABLE session_rel_user ADD COLUMN relation_type int NOT NULL default 0; -ALTER TABLE course_rel_user ADD COLUMN relation_type int NOT NULL default 0; - --- see #4705 INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('course_create_active_tools','notebook','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Notebook',1,0); -ALTER TABLE course DROP PRIMARY KEY , ADD UNIQUE KEY code (code); -ALTER TABLE course ADD id int NOT NULL auto_increment PRIMARY KEY FIRST; -CREATE TABLE block (id INT NOT NULL auto_increment, name VARCHAR(255) NULL, description TEXT NULL, path VARCHAR(255) NOT NULL, controller VARCHAR(100) NOT NULL, active TINYINT NOT NULL default 1, PRIMARY KEY(id)); -ALTER TABLE block ADD UNIQUE(path); -INSERT INTO user_field(field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES(1, 'dashboard', 'Dashboard', 0, 0); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('show_tabs', 'dashboard', 'checkbox', 'Platform', 'true', 'ShowTabsTitle','ShowTabsComment',NULL,'TabsDashboard', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('use_users_timezone', 'timezones', 'radio', 'Timezones', 'true', 'UseUsersTimezoneTitle','UseUsersTimezoneComment',NULL,'Timezones', 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('use_users_timezone', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('use_users_timezone', 'false', 'No'); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('timezone_value', 'timezones', 'select', 'Timezones', '', 'TimezoneValueTitle','TimezoneValueComment',NULL,'Timezones', 1); - -ALTER TABLE user_field CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00'; -ALTER TABLE course_field CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00'; -ALTER TABLE course_field_values CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00'; -ALTER TABLE session_field CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00'; -ALTER TABLE session_field_values CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00'; -ALTER TABLE user_field_options CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00'; -ALTER TABLE user_field_values CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00'; -ALTER TABLE access_url CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00'; - -ALTER TABLE gradebook_certificate CHANGE date_certificate created_at DATETIME NOT NULL default '0000-00-00 00:00:00'; - -ALTER TABLE gradebook_evaluation ADD COLUMN created_at DATETIME NOT NULL default '0000-00-00 00:00:00'; -UPDATE gradebook_evaluation SET created_at = FROM_UNIXTIME(date); -ALTER TABLE gradebook_evaluation DROP date; - -ALTER TABLE gradebook_link ADD COLUMN created_at DATETIME NOT NULL default '0000-00-00 00:00:00'; -UPDATE gradebook_link SET created_at = FROM_UNIXTIME(date); -ALTER TABLE gradebook_link DROP date; - -ALTER TABLE gradebook_linkeval_log ADD COLUMN created_at DATETIME NOT NULL default '0000-00-00 00:00:00'; -UPDATE gradebook_linkeval_log SET created_at = FROM_UNIXTIME(date_log); -ALTER TABLE gradebook_linkeval_log DROP date_log; - -ALTER TABLE gradebook_result ADD COLUMN created_at DATETIME NOT NULL default '0000-00-00 00:00:00'; -UPDATE gradebook_result SET created_at = FROM_UNIXTIME(date); -ALTER TABLE gradebook_result DROP date; - -ALTER TABLE gradebook_result_log CHANGE date_log created_at DATETIME NOT NULL default '0000-00-00 00:00:00'; -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('gradebook_number_decimals', NULL, 'select', 'Gradebook', '0', 'GradebookNumberDecimals', 'GradebookNumberDecimalsComment', NULL, NULL, 0); - -INSERT INTO user_field(field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES(11, 'timezone', 'Timezone', 0, 0); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_create_active_tools','attendances','checkbox','Tools','false','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Attendances', 0); - -ALTER TABLE user_field_values CHANGE id id BIGINT NOT NULL AUTO_INCREMENT; -ALTER TABLE user_field_values ADD INDEX (user_id, field_id); - -UPDATE settings_current SET selected_value = '1.8.7.11571' WHERE variable = 'dokeos_database_version'; - -ALTER TABLE course_rel_user DROP PRIMARY KEY, ADD PRIMARY KEY (course_code, user_id, relation_type); -ALTER TABLE session_rel_user DROP PRIMARY KEY, ADD PRIMARY KEY (id_session, id_user, relation_type); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_create_active_tools','course_progress','checkbox','Tools','false','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'CourseProgress', 0); -INSERT INTO settings_options(variable,value,display_text) VALUES ('homepage_view','vertical_activity','HomepageViewVerticalActivity'); - -UPDATE settings_current SET selected_value = 'UTF-8' WHERE variable = 'platform_charset'; - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_user_course_subscription_by_course_admin', NULL, 'radio', 'Security', 'true', 'AllowUserCourseSubscriptionByCourseAdminTitle', 'AllowUserCourseSubscriptionByCourseAdminComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_user_course_subscription_by_course_admin', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_user_course_subscription_by_course_admin', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('show_link_bug_notification', NULL, 'radio', 'Platform', 'true', 'ShowLinkBugNotificationTitle', 'ShowLinkBugNotificationComment', NULL, NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_link_bug_notification', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_link_bug_notification', 'false', 'No'); - -ALTER TABLE gradebook_score_display ADD category_id int NOT NULL DEFAULT 0; -ALTER TABLE gradebook_score_display ADD INDEX (category_id); -ALTER TABLE gradebook_score_display ADD score_color_percent float unsigned NOT NULL DEFAULT 0; - --- xxSTATSxx -CREATE TABLE track_e_item_property(id int NOT NULL auto_increment PRIMARY KEY, course_id int NOT NULL, item_property_id int NOT NULL, title varchar(255), content text, progress int NOT NULL default 0, lastedit_date datetime NOT NULL default '0000-00-00 00:00:00', lastedit_user_id int NOT NULL, session_id int NOT NULL default 0); -ALTER TABLE track_e_item_property ADD INDEX (course_id, item_property_id, session_id); -ALTER TABLE track_e_access ADD access_session_id INT NOT NULL DEFAULT 0; -ALTER TABLE track_e_access ADD INDEX (access_session_id); -ALTER TABLE track_e_course_access ADD session_id INT NOT NULL DEFAULT 0; -ALTER TABLE track_e_course_access ADD INDEX (session_id); -ALTER TABLE track_e_downloads ADD down_session_id INT NOT NULL DEFAULT 0; -ALTER TABLE track_e_downloads ADD INDEX (down_session_id); -ALTER TABLE track_e_links ADD links_session_id INT NOT NULL DEFAULT 0; -ALTER TABLE track_e_links ADD INDEX (links_session_id); -ALTER TABLE track_e_uploads ADD upload_session_id INT NOT NULL DEFAULT 0; -ALTER TABLE track_e_uploads ADD INDEX (upload_session_id); -ALTER TABLE track_e_online ADD session_id INT NOT NULL DEFAULT 0; -ALTER TABLE track_e_online ADD INDEX (session_id); -ALTER TABLE track_e_attempt ADD session_id INT NOT NULL DEFAULT 0; -ALTER TABLE track_e_attempt ADD INDEX (session_id); -ALTER TABLE track_e_attempt_recording ADD session_id INT NOT NULL DEFAULT 0; -ALTER TABLE track_e_attempt_recording ADD INDEX (question_id); -ALTER TABLE track_e_attempt_recording ADD INDEX (session_id); -ALTER TABLE track_e_online ADD COLUMN access_url_id INT NOT NULL DEFAULT 1; - --- xxUSERxx - --- xxCOURSExx -INSERT INTO tool(name,link,image,visibility,admin,address,added_tool,target,category) VALUES ('attendance','attendance/index.php','attendance.gif',0,'0','squaregrey.gif',0,'_self','authoring'); -ALTER TABLE course_description ADD COLUMN progress INT NOT NULL DEFAULT 0 AFTER description_type; -ALTER TABLE item_property ADD id int NOT NULL auto_increment PRIMARY KEY FIRST; -CREATE TABLE attendance_calendar (id int NOT NULL auto_increment, attendance_id int NOT NULL, date_time datetime NOT NULL default '0000-00-00 00:00:00', done_attendance tinyint NOT NULL default 0, PRIMARY KEY(id)); -ALTER TABLE attendance_calendar ADD INDEX(attendance_id); -ALTER TABLE attendance_calendar ADD INDEX(done_attendance); -CREATE TABLE attendance_sheet (user_id int NOT NULL, attendance_calendar_id int NOT NULL, presence tinyint NOT NULL DEFAULT 0, PRIMARY KEY(user_id, attendance_calendar_id)); -ALTER TABLE attendance_sheet ADD INDEX(presence); -CREATE TABLE attendance_result (id int NOT NULL auto_increment PRIMARY KEY, user_id int NOT NULL, attendance_id int NOT NULL, score int NOT NULL DEFAULT 0); -ALTER TABLE attendance_result ADD INDEX(attendance_id); -ALTER TABLE attendance_result ADD INDEX(user_id); -CREATE TABLE attendance (id int NOT NULL auto_increment PRIMARY KEY, name text NOT NULL, description TEXT NULL, active tinyint NOT NULL default 1, attendance_qualify_title varchar(255) NULL, attendance_qualify_max int NOT NULL default 0, attendance_weight float(6,2) NOT NULL default '0.0', session_id int NOT NULL default 0); -ALTER TABLE attendance ADD INDEX(session_id); -ALTER TABLE attendance ADD INDEX(active); -ALTER TABLE lp_view ADD session_id INT NOT NULL DEFAULT 0; -ALTER TABLE lp_view ADD INDEX(session_id); -INSERT INTO course_setting (variable,value,category) VALUES ('allow_user_view_user_list',1,'user'); -ALTER TABLE tool_intro ADD COLUMN session_id INT NOT NULL DEFAULT 0 AFTER intro_text, DROP PRIMARY KEY, ADD PRIMARY KEY USING BTREE(id, session_id); -CREATE TABLE thematic (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, title VARCHAR( 255 ) NOT NULL, content TEXT NULL, display_order int unsigned not null default 0, active TINYINT NOT NULL default 0, session_id INT NOT NULL DEFAULT 0); -ALTER TABLE thematic ADD INDEX (active, session_id); -CREATE TABLE thematic_plan (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, thematic_id INT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT NULL, description_type INT NOT NULL); -ALTER TABLE thematic_plan ADD INDEX (thematic_id, description_type); -CREATE TABLE thematic_advance (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, thematic_id INT NOT NULL, attendance_id INT NOT NULL DEFAULT 0, content TEXT NOT NULL, start_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', duration INT NOT NULL DEFAULT 0, done_advance tinyint NOT NULL DEFAULT 0); -ALTER TABLE thematic_advance ADD INDEX (thematic_id); -INSERT INTO course_setting (variable,value,category) VALUES ('display_info_advance_inside_homecourse',1,'thematic_advance'); -INSERT INTO tool(name, link, image, visibility, admin, address, added_tool, target, category) VALUES ('course_progress','course_progress/index.php','course_progress.gif',0,'0','squaregrey.gif',0,'_self','authoring'); -ALTER TABLE lp ADD prerequisite int unsigned NOT NULL DEFAULT 0; -ALTER TABLE student_publication MODIFY COLUMN description TEXT DEFAULT NULL; -ALTER TABLE student_publication ADD COLUMN user_id INTEGER NOT NULL AFTER session_id; -INSERT INTO course_setting(variable,value,category) VALUES ('email_alert_students_on_new_homework',0,'work'); -ALTER TABLE course_setting DROP INDEX unique_setting; diff --git a/main/install/migrate-db-1.8.7-1.8.8-pre.sql b/main/install/migrate-db-1.8.7-1.8.8-pre.sql deleted file mode 100755 index 634fc953ef..0000000000 --- a/main/install/migrate-db-1.8.7-1.8.8-pre.sql +++ /dev/null @@ -1,231 +0,0 @@ --- This script updates the databases structure before migrating the data from --- version 1.8.7 (or 1.8.7.1) to version 1.8.8 --- it is intended as a standalone script, however, because of the multiple --- databases related difficulties, it should be parsed by a PHP script in --- order to connect to and update the right databases. --- There is one line per query, allowing the PHP function file() to read --- all lines separately into an array. The xxMAINxx-type markers are there --- to tell the PHP script which database we're talking about. --- By always using the keyword "TABLE" in the queries, we should be able --- to retrieve and modify the table name from the PHP script if needed, which --- will allow us to deal with the unique-database-type installations --- --- This first part is for the main database - --- xxMAINxx - -DROP PROCEDURE IF EXISTS drop_index; -CREATE PROCEDURE drop_index(in t_name varchar(128), in i_name varchar(128) ) BEGIN IF ( (SELECT count(*) AS index_exists FROM information_schema.statistics WHERE table_schema = DATABASE( ) AND table_name = t_name AND index_name = i_name ) > 0) THEN SET @s = CONCAT('DROP INDEX ' , i_name , ' ON ' , t_name ); PREPARE stmt FROM @s; EXECUTE stmt; END IF; END; - -CREATE TABLE course_request (id int NOT NULL AUTO_INCREMENT, code varchar(40) NOT NULL, user_id int unsigned NOT NULL default '0', directory varchar(40) DEFAULT NULL, db_name varchar(40) DEFAULT NULL, course_language varchar(20) DEFAULT NULL, title varchar(250) DEFAULT NULL, description text, category_code varchar(40) DEFAULT NULL, tutor_name varchar(200) DEFAULT NULL, visual_code varchar(40) DEFAULT NULL, request_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00', objetives text, target_audience text, status int unsigned NOT NULL default '0', info int unsigned NOT NULL default '0', exemplary_content int unsigned NOT NULL default '0', PRIMARY KEY (id), UNIQUE KEY code (code)); - -CALL drop_index('settings_current', 'unique_setting'); -CALL drop_index('settings_options', 'unique_setting_option'); - -ALTER TABLE settings_current ADD UNIQUE unique_setting (variable(110), subkey(110), category(110), access_url); -ALTER TABLE settings_options ADD UNIQUE unique_setting_option (variable(165), value(165)); -ALTER TABLE settings_current CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; -ALTER TABLE settings_options CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; - -ALTER TABLE user MODIFY COLUMN username VARCHAR(40) NOT NULL; - -UPDATE settings_current SET variable='chamilo_database_version' WHERE variable='dokeos_database_version'; - -ALTER TABLE sys_announcement ADD COLUMN access_url_id INT NOT NULL default 1; -ALTER TABLE sys_calendar ADD COLUMN access_url_id INT NOT NULL default 1; - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('users_copy_files', NULL, 'radio', 'Tools', 'true', 'AllowUsersCopyFilesTitle','AllowUsersCopyFilesComment', NULL,NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('users_copy_files', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('users_copy_files', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_validation', NULL, 'radio', 'Platform', 'false', 'EnableCourseValidation', 'EnableCourseValidationComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('course_validation', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('course_validation', 'false', 'No'); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_validation_terms_and_conditions_url', NULL, 'textfield', 'Platform', '', 'CourseValidationTermsAndConditionsLink', 'CourseValidationTermsAndConditionsLinkComment', NULL, NULL, 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('sso_authentication',NULL,'radio','Security','false','EnableSSOTitle','EnableSSOComment',NULL,NULL,1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('sso_authentication_domain',NULL,'textfield','Security','','SSOServerDomainTitle','SSOServerDomainComment',NULL,NULL,1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('sso_authentication_auth_uri',NULL,'textfield','Security','/?q=user','SSOServerAuthURITitle','SSOServerAuthURIComment',NULL,NULL,1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('sso_authentication_unauth_uri',NULL,'textfield','Security','/?q=logout','SSOServerUnAuthURITitle','SSOServerUnAuthURIComment',NULL,NULL,1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('sso_authentication_protocol',NULL,'radio','Security','http://','SSOServerProtocolTitle','SSOServerProtocolComment',NULL,NULL,1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('sso_authentication', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('sso_authentication', 'false', 'No'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('sso_authentication_protocol', 'http://', 'http://'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('sso_authentication_protocol', 'https://', 'https://'); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enabled_asciisvg',NULL,'radio','Editor','false','AsciiSvgTitle','AsciiSvgComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_asciisvg', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_asciisvg', 'false', 'No'); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('include_asciimathml_script',NULL,'radio','Editor','false','IncludeAsciiMathMlTitle','IncludeAsciiMathMlComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('include_asciimathml_script', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('include_asciimathml_script', 'false', 'No'); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enabled_wiris',NULL,'radio','Editor','false','EnabledWirisTitle','EnabledWirisComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_wiris', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_wiris', 'false', 'No'); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_spellcheck',NULL,'radio','Editor','false','AllowSpellCheckTitle','AllowSpellCheckComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_spellcheck', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_spellcheck', 'false', 'No'); -ALTER TABLE course ADD INDEX idx_course_category_code (category_code); -ALTER TABLE course ADD INDEX idx_course_directory (directory(10)); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('force_wiki_paste_as_plain_text',NULL,'radio','Editor','false','ForceWikiPasteAsPlainText','ForceWikiPasteAsPlainTextComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('force_wiki_paste_as_plain_text', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('force_wiki_paste_as_plain_text', 'false', 'No'); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enabled_googlemaps',NULL,'radio','Editor','false','EnabledGooglemapsTitle','EnabledGooglemapsComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_googlemaps', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_googlemaps', 'false', 'No'); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enabled_imgmap',NULL,'radio','Editor','true','EnabledImageMapsTitle','EnabledImageMapsComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_imgmap', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_imgmap', 'false', 'No'); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enabled_support_svg',NULL,'radio','Tools','true','EnabledSVGTitle','EnabledSVGComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_support_svg', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_support_svg', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('pdf_export_watermark_enable', NULL,'radio', 'Platform', 'false','PDFExportWatermarkEnableTitle', 'PDFExportWatermarkEnableComment','platform',NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('pdf_export_watermark_enable','true','Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('pdf_export_watermark_enable','false','No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('pdf_export_watermark_by_course', NULL,'radio', 'Platform', 'false','PDFExportWatermarkByCourseTitle', 'PDFExportWatermarkByCourseComment','platform',NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('pdf_export_watermark_by_course','true','Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('pdf_export_watermark_by_course','false','No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('hide_courses_in_sessions', NULL,'radio', 'Platform', 'false','HideCoursesInSessionsTitle', 'HideCoursesInSessionsComment','platform',NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('hide_courses_in_sessions','true','Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('hide_courses_in_sessions','false','No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('pdf_export_watermark_text', NULL,'textfield', 'Platform', '', 'PDFExportWatermarkTextTitle','PDFExportWatermarkTextComment','platform',NULL, 1); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enabled_insertHtml',NULL,'radio','Editor','true','EnabledInsertHtmlTitle','EnabledInsertHtmlComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_insertHtml', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_insertHtml', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('students_export2pdf',NULL,'radio','Tools','true','EnabledStudentExport2PDFTitle','EnabledStudentExport2PDFComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('students_export2pdf', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('students_export2pdf', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('exercise_min_score', NULL,'textfield', 'Course', '', 'ExerciseMinScoreTitle', 'ExerciseMinScoreComment','platform',NULL, 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('exercise_max_score', NULL,'textfield', 'Course', '', 'ExerciseMaxScoreTitle', 'ExerciseMaxScoreComment','platform',NULL, 1); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('show_users_folders',NULL,'radio','Tools','true','ShowUsersFoldersTitle','ShowUsersFoldersComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_users_folders', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_users_folders', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('show_default_folders',NULL,'radio','Tools','true','ShowDefaultFoldersTitle','ShowDefaultFoldersComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_default_folders', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_default_folders', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('show_chat_folder',NULL,'radio','Tools','true','ShowChatFolderTitle','ShowChatFolderComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_chat_folder', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_chat_folder', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enabled_text2audio',NULL,'radio','Tools','false','Text2AudioTitle','Text2AudioComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_text2audio', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_text2audio', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','course_description','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'CourseDescription', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','calendar_event','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Agenda', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','document','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Documents', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','learnpath','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'LearningPath', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','link','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Links', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','announcement','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Announcements', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','forum','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Forums', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','dropbox','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Dropbox', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','quiz','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Quiz', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','user','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Users', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','group','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Groups', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','chat','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Chat', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','student_publication','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'StudentPublications', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','wiki','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Wiki', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','gradebook','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Gradebook', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','survey','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Survey', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','glossary','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Glossary', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','notebook','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Notebook', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','attendance','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Attendances', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','course_progress','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'CourseProgress', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','blog_management','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Blog',1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','tracking','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Stats',1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','course_maintenance','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Maintenance',1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','course_setting','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'CourseSettings',1); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enabled_support_pixlr',NULL,'radio','Tools','false','EnabledPixlrTitle','EnabledPixlrComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_support_pixlr', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_support_pixlr', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('show_groups_to_users',NULL,'radio','Platform','false','ShowGroupsToUsersTitle','ShowGroupsToUsersComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_groups_to_users', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_groups_to_users', 'false', 'No'); - -INSERT INTO language (original_name, english_name, isocode, dokeos_folder, available) VALUES ('हिन्दी', 'hindi', 'hi', 'hindi', 0); - -ALTER TABLE session ADD COLUMN promotion_id INT NOT NULL; - -CREATE TABLE career (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, description TEXT NOT NULL, status INT NOT NULL default '0', created_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00', updated_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id)); -CREATE TABLE promotion (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, description TEXT NOT NULL, status INT NOT NULL default '0', career_id INT NOT NULL, created_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00', updated_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY(id)); - -CREATE TABLE usergroup ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, description TEXT NOT NULL,PRIMARY KEY (id)); -CREATE TABLE usergroup_rel_user ( usergroup_id INT NOT NULL, user_id INT NOT NULL ); -CREATE TABLE usergroup_rel_course ( usergroup_id INT NOT NULL, course_id INT NOT NULL ); -CREATE TABLE usergroup_rel_session ( usergroup_id INT NOT NULL, session_id INT NOT NULL ); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('accessibility_font_resize',NULL,'radio','Platform','false','EnableAccessibilityFontResizeTitle','EnableAccessibilityFontResizeComment',NULL,NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('accessibility_font_resize', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('accessibility_font_resize', 'false', 'No'); - -CREATE TABLE notification (id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT,dest_user_id INT NOT NULL, dest_mail CHAR(255),title CHAR(255), content CHAR(255), send_freq SMALLINT DEFAULT 1, created_at DATETIME NOT NULL, sent_at DATETIME NULL); - -ALTER TABLE notification ADD index mail_notify_sent_index (sent_at); -ALTER TABLE notification ADD index mail_notify_freq_index (sent_at, send_freq, created_at); - -ALTER TABLE session_category ADD COLUMN access_url_id INT NOT NULL default 1; - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enable_quiz_scenario', NULL,'radio','Course','false','EnableQuizScenarioTitle','EnableQuizScenarioComment',NULL,NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_quiz_scenario', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_quiz_scenario', 'false', 'No'); - -UPDATE settings_current SET category='Search' WHERE variable='search_enable'; - -INSERT INTO settings_options (variable, value, display_text) VALUES ('homepage_view', 'activity_big', 'HomepageViewActivityBig'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enable_nanogong',NULL,'radio','Tools','false','EnableNanogongTitle','EnableNanogongComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_nanogong', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_nanogong', 'false', 'No'); - -ALTER TABLE gradebook_evaluation ADD COLUMN locked int NOT NULL DEFAULT 0; - -UPDATE settings_current SET selected_value = '1.8.8.14911' WHERE variable = 'chamilo_database_version'; - --- xxSTATSxx -ALTER TABLE track_e_exercices ADD COLUMN orig_lp_item_view_id INT NOT NULL DEFAULT 0; - --- xxUSERxx -ALTER TABLE personal_agenda ADD PRIMARY KEY (id); -ALTER TABLE personal_agenda ADD INDEX idx_personal_agenda_user (user); -ALTER TABLE personal_agenda ADD INDEX idx_personal_agenda_parent (parent_event_id); -ALTER TABLE user_course_category ADD INDEX idx_user_c_cat_uid (user_id); - --- xxCOURSExx -ALTER TABLE course_setting CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; -ALTER TABLE forum_forum ADD start_time DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'; -ALTER TABLE forum_forum ADD end_time DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'; -ALTER TABLE wiki_mailcue ADD session_id smallint DEFAULT 0; - -ALTER TABLE lp ADD COLUMN use_max_score INT DEFAULT 1; -ALTER TABLE lp_item MODIFY COLUMN max_score FLOAT UNSIGNED DEFAULT 100; -ALTER TABLE tool MODIFY COLUMN category varchar(20) not null default 'authoring'; - -ALTER TABLE lp ADD COLUMN autolunch INT DEFAULT 0; -ALTER TABLE lp ADD COLUMN created_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'; -ALTER TABLE lp ADD COLUMN modified_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'; -ALTER TABLE lp ADD COLUMN expired_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'; -ALTER TABLE lp ADD COLUMN publicated_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'; - -CREATE TABLE quiz_question_option (id int NOT NULL, name varchar(255), position int unsigned NOT NULL, PRIMARY KEY (id)); -ALTER TABLE quiz_question ADD COLUMN extra varchar(255) DEFAULT NULL; -ALTER TABLE quiz_question CHANGE question question TEXT NOT NULL; - -INSERT INTO course_setting(variable,value,category) VALUES ('enable_lp_auto_launch',0,'learning_path'); -INSERT INTO course_setting(variable,value,category) VALUES ('pdf_export_watermark_text','','course'); - -ALTER TABLE quiz ADD COLUMN propagate_neg INT NOT NULL DEFAULT 0; -ALTER TABLE quiz_answer MODIFY COLUMN hotspot_type ENUM('square','circle','poly','delineation','oar'); - -ALTER TABLE attendance ADD COLUMN locked int NOT NULL default 0; -CREATE TABLE attendance_sheet_log (id INT NOT NULL AUTO_INCREMENT, attendance_id INT NOT NULL DEFAULT 0, lastedit_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', lastedit_type VARCHAR(200) NOT NULL, lastedit_user_id INT NOT NULL DEFAULT 0, calendar_date_value DATETIME NULL, PRIMARY KEY (id)); - diff --git a/main/install/migrate-db-1.8.8-1.9.0-pre.sql b/main/install/migrate-db-1.8.8-1.9.0-pre.sql deleted file mode 100755 index 456d18f85d..0000000000 --- a/main/install/migrate-db-1.8.8-1.9.0-pre.sql +++ /dev/null @@ -1,344 +0,0 @@ --- This script updates the databases structure before migrating the data from --- version 1.8.8 (or version 1.8.8.2, 1.8.8.4) to version 1.9.0 --- it is intended as a standalone script, however, because of the multiple --- databases related difficulties, it should be parsed by a PHP script in --- order to connect to and update the right databases. --- There is one line per query, allowing the PHP function file() to read --- all lines separately into an array. The xxMAINxx-type markers are there --- to tell the PHP script which database we're talking about. --- By always using the keyword "TABLE" in the queries, we should be able --- to retrieve and modify the table name from the PHP script if needed, which --- will allow us to deal with the unique-database-type installations --- --- This first part is for the main database - --- xxMAINxx - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('filter_terms', NULL, 'textarea', 'Security', '', 'FilterTermsTitle', 'FilterTermsComment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('header_extra_content', NULL, 'textarea', 'Tracking', '', 'HeaderExtraContentTitle', 'HeaderExtraContentComment', NULL, NULL, 1),('footer_extra_content', NULL, 'textarea', 'Tracking', '', 'FooterExtraContentTitle', 'FooterExtraContentComment', NULL, NULL,1); - -ALTER TABLE sys_calendar ADD COLUMN all_day INTEGER NOT NULL DEFAULT 0; - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('show_documents_preview', NULL, 'radio', 'Tools', 'false', 'ShowDocumentPreviewTitle', 'ShowDocumentPreviewComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_documents_preview', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_documents_preview', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('htmlpurifier_wiki',NULL,'radio','Editor','false','HtmlPurifierWikiTitle','HtmlPurifierWikiComment',NULL,NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('htmlpurifier_wiki', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('htmlpurifier_wiki', 'false', 'No'); - --- CAS feature -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_activate', NULL, 'radio', 'CAS', 'false', 'CasMainActivateTitle', 'CasMainActivateComment', NULL, NULL, 0); -INSERT INTO settings_options (variable, value, display_text) values ('cas_activate', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) values ('cas_activate', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_server', NULL, 'textfield', 'CAS', '', 'CasMainServerTitle', 'CasMainServerComment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_server_uri', NULL, 'textfield', 'CAS', '', 'CasMainServerURITitle', 'CasMainServerURIComment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_port', NULL, 'textfield', 'CAS', '', 'CasMainPortTitle', 'CasMainPortComment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_protocol', NULL, 'radio', 'CAS', '', 'CasMainProtocolTitle', 'CasMainProtocolComment', NULL, NULL, 0); -INSERT INTO settings_options (variable, value, display_text) values ('cas_protocol', 'CAS1', 'CAS1Text'); -INSERT INTO settings_options (variable, value, display_text) values ('cas_protocol', 'CAS2', 'CAS2Text'); -INSERT INTO settings_options (variable, value, display_text) values ('cas_protocol', 'SAML', 'SAMLText'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_add_user_activate', NULL, 'radio', 'CAS', 'false', 'CasUserAddActivateTitle', 'CasUserAddActivateComment', NULL, NULL, 0); -INSERT INTO settings_options (variable, value, display_text) values ('cas_add_user_activate', 'platform', 'casAddUserActivatePlatform'); -INSERT INTO settings_options (variable, value, display_text) values ('cas_add_user_activate', 'extldap', 'casAddUserActivateLDAP'); -INSERT INTO settings_options (variable, value, display_text) values ('cas_add_user_activate', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('update_user_info_cas_with_ldap', NULL, 'radio', 'CAS', 'true', 'UpdateUserInfoCasWithLdapTitle', 'UpdateUserInfoCasWithLdapComment', NULL, NULL, 0) - --- Custom Pages -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('use_custom_pages', NULL, 'radio','Platform','false','UseCustomPagesTitle','UseCustomPagesComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) values ('use_custom_pages', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) values ('use_custom_pages', 'false', 'No'); - --- Pages after login by role -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('student_page_after_login', NULL, 'textfield', 'Platform', '', 'StudentPageAfterLoginTitle', 'StudentPageAfterLoginComment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('teacher_page_after_login', NULL, 'textfield', 'Platform', '', 'TeacherPageAfterLoginTitle', 'TeacherPageAfterLoginComment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('drh_page_after_login', NULL, 'textfield', 'Platform', '', 'DRHPageAfterLoginTitle', 'DRHPageAfterLoginComment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('sessionadmin_page_after_login', NULL, 'textfield', 'Session', '', 'SessionAdminPageAfterLoginTitle', 'SessionAdminPageAfterLoginComment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('student_autosubscribe', NULL, 'textfield', 'Platform', '', 'StudentAutosubscribeTitle', 'StudentAutosubscribeComment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('teacher_autosubscribe', NULL, 'textfield', 'Platform', '', 'TeacherAutosubscribeTitle', 'TeacherAutosubscribeComment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('drh_autosubscribe', NULL, 'textfield', 'Platform', '', 'DRHAutosubscribeTitle', 'DRHAutosubscribeComment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('sessionadmin_autosubscribe', NULL, 'textfield', 'Session', '', 'SessionadminAutosubscribeTitle', 'SessionadminAutosubscribeComment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('show_tabs', 'custom_tab_1', 'checkbox', 'Platform', 'true', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom1', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('show_tabs', 'custom_tab_2', 'checkbox', 'Platform', 'false', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom2', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('show_tabs', 'custom_tab_3', 'checkbox', 'Platform', 'false', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom3', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('languagePriority1', NULL, 'radio', 'Languages', 'course_lang', 'LanguagePriority1Title', 'LanguagePriority1Comment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('languagePriority2', NULL, 'radio', 'Languages', 'user_profil_lang', 'LanguagePriority2Title', 'LanguagePriority2Comment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('languagePriority3', NULL, 'radio', 'Languages', 'user_selected_lang', 'LanguagePriority3Title', 'LanguagePriority3Comment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('languagePriority4', NULL, 'radio', 'Languages', 'platform_lang', 'LanguagePriority4Title', 'LanguagePriority4Comment', NULL, NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('languagePriority1','platform_lang','PlatformLanguage'), ('languagePriority1','user_profil_lang','UserLanguage'), ('languagePriority1','user_selected_lang','UserSelectedLanguage'), ('languagePriority1','course_lang','CourseLanguage'), ('languagePriority2','platform_lang','PlatformLanguage'), ('languagePriority2','user_profil_lang','UserLanguage'), ('languagePriority2','user_selected_lang','UserSelectedLanguage'), ('languagePriority2','course_lang','CourseLanguage'), ('languagePriority3','platform_lang','PlatformLanguage'), ('languagePriority3','user_profil_lang','UserLanguage'), ('languagePriority3','user_selected_lang','UserSelectedLanguage'), ('languagePriority3','course_lang','CourseLanguage'), ('languagePriority4','platform_lang','PlatformLanguage'), ('languagePriority4','user_profil_lang','UserLanguage'), ('languagePriority4','user_selected_lang','UserSelectedLanguage'), ('languagePriority4','course_lang','CourseLanguage'); --- Email is login -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('login_is_email', NULL, 'radio', 'Platform', 'false', 'LoginIsEmailTitle', 'LoginIsEmailComment', NULL, NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('login_is_email','true','Yes'),('login_is_email','false','No') ; -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('scorm_cumulative_session_time', NULL, 'radio', 'Course', 'true', 'ScormCumulativeSessionTimeTitle', 'ScormCumulativeSessionTimeComment', NULL, NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('scorm_cumulative_session_time','true','Yes'), ('scorm_cumulative_session_time','false','No'); -CREATE TABLE event_type ( id int unsigned NOT NULL AUTO_INCREMENT, name varchar(50) NOT NULL, name_lang_var varchar(50) NOT NULL, desc_lang_var varchar(50) NOT NULL, extendable_variables varchar(255) NOT NULL, PRIMARY KEY (id)); -ALTER TABLE event_type ADD INDEX ( name ); -CREATE TABLE event_type_email_template ( id int unsigned NOT NULL AUTO_INCREMENT, event_type_id int NOT NULL, language_id int NOT NULL, message text NOT NULL, subject varchar(60) NOT NULL, PRIMARY KEY (id)); -ALTER TABLE event_type_email_template ADD INDEX ( language_id ); -INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) values (1, 'already_logged_in','Already logged in',0,0); -INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) values (1, 'update_type','Update script type',0,0); -CREATE TABLE announcement_rel_group (group_id int NOT NULL, announcement_id int NOT NULL, PRIMARY KEY (group_id, announcement_id)); -CREATE TABLE group_rel_group ( id int NOT NULL AUTO_INCREMENT, group_id int NOT NULL, subgroup_id int NOT NULL, relation_type int NOT NULL, PRIMARY KEY (id)); -ALTER TABLE group_rel_group ADD INDEX ( group_id ); -ALTER TABLE group_rel_group ADD INDEX ( subgroup_id ); -ALTER TABLE group_rel_group ADD INDEX ( relation_type ); - - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('gradebook_enable_grade_model', NULL, 'radio', 'Gradebook', 'false', 'GradebookEnableGradeModelTitle', 'GradebookEnableGradeModelComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('gradebook_enable_grade_model', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('gradebook_enable_grade_model', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('teachers_can_change_grade_model_settings', NULL, 'radio', 'Gradebook', 'true', 'TeachersCanChangeGradeModelSettingsTitle', 'TeachersCanChangeGradeModelSettingsComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('teachers_can_change_grade_model_settings', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('teachers_can_change_grade_model_settings', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('gradebook_locking_enabled', NULL, 'radio', 'Gradebook', 'false', 'GradebookEnableLockingTitle', 'GradebookEnableLockingComment', NULL, NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('gradebook_locking_enabled', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('gradebook_locking_enabled', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('teachers_can_change_score_settings', NULL, 'radio', 'Gradebook', 'true', 'TeachersCanChangeScoreSettingsTitle', 'TeachersCanChangeScoreSettingsComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('teachers_can_change_score_settings', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('teachers_can_change_score_settings', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_users_to_change_email_with_no_password', NULL, 'radio', 'User', 'false', 'AllowUsersToChangeEmailWithNoPasswordTitle', 'AllowUsersToChangeEmailWithNoPasswordComment', NULL, NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_users_to_change_email_with_no_password', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_users_to_change_email_with_no_password', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_session_admins_to_manage_all_sessions', NULL, 'radio', 'Session', 'false', 'AllowSessionAdminsToSeeAllSessionsTitle', 'AllowSessionAdminsToSeeAllSessionsComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_session_admins_to_manage_all_sessions', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_session_admins_to_manage_all_sessions', 'false', 'No'); - --- Shibboleth and Facebook auth and ldap -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('shibboleth_description', NULL, 'radio', 'Shibboleth', 'false', 'ShibbolethMainActivateTitle', 'ShibbolethMainActivateComment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('facebook_description', NULL, 'radio', 'Facebook', 'false', 'FacebookMainActivateTitle', 'FacebookMainActivateComment', NULL, NULL, 0); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('ldap_description', NULL, 'radio', 'LDAP', NULL, 'LdapDescriptionTitle', 'LdapDescriptionComment', NULL, NULL, 0); - -ALTER TABLE course_rel_user ADD COLUMN legal_agreement INTEGER DEFAULT 0; -ALTER TABLE session_rel_course_rel_user ADD COLUMN legal_agreement INTEGER DEFAULT 0; -ALTER TABLE course ADD COLUMN legal TEXT NOT NULL; -ALTER TABLE course ADD COLUMN activate_legal INT NOT NULL DEFAULT 0; - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enable_help_link', NULL, 'radio', 'Platform', 'true', 'EnableHelpLinkTitle', 'EnableHelpLinkComment', NULL, NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_help_link', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_help_link', 'false', 'No'); - -ALTER TABLE gradebook_category MODIFY COLUMN weight FLOAT NOT NULL; -ALTER TABLE gradebook_link MODIFY COLUMN weight FLOAT NOT NULL; -ALTER TABLE gradebook_link ADD COLUMN locked INT DEFAULT 0; -ALTER TABLE gradebook_category ADD COLUMN locked INT DEFAULT 0; -ALTER TABLE gradebook_category ADD COLUMN default_lowest_eval_exclude TINYINT default null; - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_hr_skills_management', NULL, 'radio', 'Gradebook', 'true', 'AllowHRSkillsManagementTitle', 'AllowHRSkillsManagementComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_hr_skills_management', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_hr_skills_management', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('show_admin_toolbar', NULL, 'radio', 'Platform', 'show_to_admin', 'ShowAdminToolbarTitle', 'ShowAdminToolbarComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_admin_toolbar', 'do_not_show', 'DoNotShow'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_admin_toolbar', 'show_to_admin', 'ShowToAdminsOnly'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_admin_toolbar', 'show_to_admin_and_teachers', 'ShowToAdminsAndTeachers'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_admin_toolbar', 'show_to_all', 'ShowToAllUsers'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_global_chat', NULL, 'radio', 'Platform', 'true', 'AllowGlobalChatTitle', 'AllowGlobalChatComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_global_chat', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_global_chat', 'false', 'No'); - -CREATE TABLE chat (id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, from_user INTEGER, to_user INTEGER, message TEXT NOT NULL, sent DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', recd INTEGER UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (id)); -ALTER TABLE chat ADD INDEX idx_chat_to_user (to_user); -ALTER TABLE chat ADD INDEX idx_chat_from_user (from_user); - -INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES (1, 'google_calendar_url','Google Calendar URL',0,0); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('courses_default_creation_visibility', NULL, 'radio', 'Course', '2', 'CoursesDefaultCreationVisibilityTitle', 'CoursesDefaultCreationVisibilityComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('courses_default_creation_visibility', '3', 'OpenToTheWorld'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('courses_default_creation_visibility', '2', 'OpenToThePlatform'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('courses_default_creation_visibility', '1', 'Private'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('courses_default_creation_visibility', '0', 'CourseVisibilityClosed'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_browser_sniffer', NULL, 'radio', 'Tuning', 'false', 'AllowBrowserSnifferTitle', 'AllowBrowserSnifferComment', NULL, NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_browser_sniffer', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_browser_sniffer', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enable_wami_record', NULL, 'radio', 'Tools', 'false', 'EnableWamiRecordTitle', 'EnableWamiRecordComment', NULL, NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_wami_record', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_wami_record', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_public_certificates', NULL, 'radio', 'Course', 'false', 'AllowPublicCertificatesTitle', 'AllowPublicCertificatesComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_public_certificates', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_public_certificates', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enable_iframe_inclusion', NULL, 'radio', 'Editor', 'false', 'EnableIframeInclusionTitle', 'EnableIframeInclusionComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_iframe_inclusion', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_iframe_inclusion', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('show_hot_courses', NULL, 'radio', 'Platform', 'true', 'ShowHotCoursesTitle', 'ShowHotCoursesComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_hot_courses', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_hot_courses', 'false', 'No'); - - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('gradebook_default_weight', NULL, 'textfield', 'Gradebook', '100', 'GradebookDefaultWeightTitle', 'GradebookDefaultWeightComment', NULL, NULL, 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('gradebook_default_grade_model_id', NULL, 'select', 'Gradebook', '', 'GradebookDefaultGradeModelTitle', 'GradebookDefaultGradeModelComment', NULL, NULL, 1); - -UPDATE settings_current SET category = 'Session' WHERE variable IN ('show_tutor_data', 'use_session_mode', 'add_users_by_coach', 'show_session_coach', 'show_session_data', 'allow_coach_to_edit_course_session','hide_courses_in_sessions', 'show_groups_to_users'); - -INSERT INTO language (original_name, english_name, isocode, dokeos_folder, available) VALUES ('বাংলা','bengali','bn','bengali',0), ('الصومالية','somali','so','somali',0); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enable_webcam_clip', NULL, 'radio', 'Tools', 'false', 'EnableWebCamClipTitle', 'EnableWebCamClipComment', NULL, NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_webcam_clip', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_webcam_clip', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('tool_visible_by_default_at_creation','documents','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Documents', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('tool_visible_by_default_at_creation','learning_path','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'LearningPath', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('tool_visible_by_default_at_creation','links','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Links', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('tool_visible_by_default_at_creation','announcements','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Announcements', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('tool_visible_by_default_at_creation','forums','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Forums', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('tool_visible_by_default_at_creation','quiz','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Quiz', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('tool_visible_by_default_at_creation','gradebook','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Gradebook', 1); - --- Course ranking -CREATE TABLE track_course_ranking (id int unsigned not null PRIMARY KEY AUTO_INCREMENT, c_id int unsigned not null, session_id int unsigned not null default 0, url_id int unsigned not null default 0, accesses int unsigned not null default 0, total_score int unsigned not null default 0, users int unsigned not null default 0, creation_date datetime not null); - -ALTER TABLE track_course_ranking ADD INDEX idx_tcc_cid (c_id); -ALTER TABLE track_course_ranking ADD INDEX idx_tcc_sid (session_id); -ALTER TABLE track_course_ranking ADD INDEX idx_tcc_urlid (url_id); -ALTER TABLE track_course_ranking ADD INDEX idx_tcc_creation_date (creation_date); - -CREATE TABLE user_rel_course_vote ( id int unsigned not null AUTO_INCREMENT PRIMARY KEY, c_id int unsigned not null, user_id int unsigned not null, session_id int unsigned not null default 0, url_id int unsigned not null default 0, vote int unsigned not null default 0); - -ALTER TABLE user_rel_course_vote ADD INDEX idx_ucv_cid (c_id); -ALTER TABLE user_rel_course_vote ADD INDEX idx_ucv_uid (user_id); -ALTER TABLE user_rel_course_vote ADD INDEX idx_ucv_cuid (user_id, c_id); - ---User chat status -INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES (1, 'user_chat_status','User chat status', 0, 0); -UPDATE settings_current SET selected_value = 'true' WHERE variable = 'more_buttons_maximized_mode'; - ---Grade model -CREATE TABLE grade_model (id INTEGER NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, description TEXT, default_lowest_eval_exclude TINYINT default null, default_external_eval_prefix VARCHAR(140) default null, PRIMARY KEY (id)); -CREATE TABLE grade_components (id INTEGER NOT NULL AUTO_INCREMENT, percentage VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL, acronym VARCHAR(255) NOT NULL, grade_model_id INTEGER NOT NULL, PRIMARY KEY (id)); -ALTER TABLE gradebook_category ADD COLUMN grade_model_id INT DEFAULT 0; - -UPDATE settings_current SET title = 'DatabaseVersion' WHERE variable = 'chamilo_database_version'; -ALTER TABLE gradebook_evaluation MODIFY COLUMN weight FLOAT NOT NULL; - -INSERT INTO settings_options(variable, value, display_text) VALUES ('page_after_login', 'main/auth/courses.php', 'CourseCatalog'); - -ALTER TABLE settings_current ADD COLUMN access_url_locked INTEGER NOT NULL DEFAULT 0; - --- Event mail -CREATE TABLE event_email_template ( id int NOT NULL AUTO_INCREMENT, message text, subject varchar(255) DEFAULT NULL, event_type_name varchar(255) DEFAULT NULL, activated tinyint NOT NULL DEFAULT '0', language_id int DEFAULT NULL, PRIMARY KEY (id)); -ALTER TABLE event_email_template ADD INDEX event_name_index (event_type_name); - -CREATE TABLE event_sent ( id int NOT NULL AUTO_INCREMENT, user_from int NOT NULL, user_to int DEFAULT NULL, event_type_name varchar(100) DEFAULT NULL, PRIMARY KEY (id)); -ALTER TABLE event_sent ADD INDEX event_name_index (event_type_name); - -CREATE TABLE user_rel_event_type ( id int NOT NULL AUTO_INCREMENT, user_id int NOT NULL, event_type_name varchar(255) NOT NULL, PRIMARY KEY (id)); -ALTER TABLE user_rel_event_type ADD INDEX event_name_index (event_type_name); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('activate_email_template', NULL, 'radio', 'Platform', 'false', 'ActivateEmailTemplateTitle', 'ActivateEmailTemplateComment', NULL, NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('activate_email_template', 'true', 'Yes'),('activate_email_template', 'false', 'No'); - --- Skills -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_skills_tool', NULL, 'radio', 'Platform', 'false', 'AllowSkillsToolTitle', 'AllowSkillsToolComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_skills_tool', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_skills_tool', 'false', 'No'); - -CREATE TABLE IF NOT EXISTS skill ( id int NOT NULL AUTO_INCREMENT, name varchar(255) NOT NULL, short_code varchar(100) NOT NULL, description TEXT NOT NULL, access_url_id int NOT NULL, icon varchar(255) NOT NULL, PRIMARY KEY (id)); -INSERT INTO skill (name) VALUES ('Root'); - -CREATE TABLE IF NOT EXISTS skill_rel_gradebook ( id int NOT NULL AUTO_INCREMENT, gradebook_id int NOT NULL, skill_id int NOT NULL, type varchar(10) NOT NULL, PRIMARY KEY (id)); -CREATE TABLE IF NOT EXISTS skill_rel_skill (id int NOT NULL AUTO_INCREMENT, skill_id int NOT NULL, parent_id int NOT NULL, relation_type int NOT NULL, level int NOT NULL, PRIMARY KEY (id)); -INSERT INTO skill_rel_skill VALUES(1, 1, 0, 0, 0); - -CREATE TABLE IF NOT EXISTS skill_rel_user ( id int NOT NULL AUTO_INCREMENT, user_id int NOT NULL, skill_id int NOT NULL, acquired_skill_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00',assigned_by int NOT NULL,PRIMARY KEY (id)); -CREATE TABLE IF NOT EXISTS skill_profile ( id INTEGER NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, description TEXT NOT NULL, PRIMARY KEY (id)); -CREATE TABLE IF NOT EXISTS skill_rel_profile ( id INTEGER NOT NULL AUTO_INCREMENT, skill_id INTEGER NOT NULL, profile_id INTEGER NOT NULL, PRIMARY KEY (id)); - --- Removing use_document_title -DELETE FROM settings_current WHERE variable = 'use_document_title'; -DELETE FROM settings_options WHERE variable = 'use_document_title'; - -ALTER TABLE course MODIFY COLUMN disk_quota bigint unsigned DEFAULT NULL; -ALTER TABLE user MODIFY COLUMN username VARCHAR(100) NOT NULL; - -UPDATE language SET english_name = 'basque' , dokeos_folder = 'basque' where english_name = 'euskera'; -UPDATE language SET english_name = 'turkish', dokeos_folder = 'turkish' where english_name = 'turkce'; - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('platform_unsubscribe_allowed', NULL, 'radio', 'Platform', 'false', 'PlatformUnsubscribeTitle', 'PlatformUnsubscribeComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) values ('platform_unsubscribe_allowed', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) values ('platform_unsubscribe_allowed', 'false', 'No'); - -ALTER TABLE usergroup_rel_session ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); -ALTER TABLE usergroup_rel_course ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); -ALTER TABLE usergroup_rel_user ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); -ALTER TABLE admin ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); -ALTER TABLE reservation_category_rights ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); - - -CREATE TABLE course_type (id int unsigned not null auto_increment primary key, name varchar(50) not null, translation_var char(40) default 'UndefinedCourseTypeLabel', description TEXT default '', props text default ''); - -INSERT INTO course_type (id, name) VALUES (1, 'All tools'); -INSERT INTO course_type (id, name) VALUES (2, 'Entry exam'); - -ALTER TABLE course add course_type_id int unsigned default 1; - -CREATE TABLE usergroup_rel_question (id int unsigned not null auto_increment primary key, c_id int unsigned not null, question_id int unsigned not null, usergroup_id int unsigned not null, coefficient float(6,2)); - --- Remove settings entry that doesnt exist anymore - -DELETE FROM settings_current WHERE variable = 'read_more_limit'; -DELETE FROM settings_current WHERE variable = 'user_order_by'; -DELETE FROM settings_options WHERE variable = 'user_order_by'; - -ALTER TABLE user_api_key ADD COLUMN api_end_point text DEFAULT NULL; -ALTER TABLE user_api_key ADD COLUMN created_date datetime DEFAULT NULL; -ALTER TABLE user_api_key ADD COLUMN validity_start_date datetime DEFAULT NULL; -ALTER TABLE user_api_key ADD COLUMN validity_end_date datetime DEFAULT NULL; -ALTER TABLE user_api_key ADD COLUMN description text DEFAULT NULL; - --- Do not move this query -UPDATE settings_current SET selected_value = '1.9.0.18715' WHERE variable = 'chamilo_database_version'; - --- xxSTATSxx -ALTER TABLE track_e_default MODIFY COLUMN default_value TEXT; -ALTER TABLE track_e_exercices ADD COLUMN questions_to_check TEXT NOT NULL DEFAULT ''; ---CREATE TABLE track_filtered_terms (id int, user_id int, course_id int, session_id int, tool_id char(12), filtered_term varchar(255), created_at datetime); -CREATE TABLE track_stored_values (id int unsigned not null AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, sco_id INT NOT NULL, course_id CHAR(40) NOT NULL, sv_key CHAR(64) NOT NULL, sv_value TEXT NOT NULL); -ALTER TABLE track_stored_values ADD KEY (user_id, sco_id, course_id, sv_key); -ALTER TABLE track_stored_values ADD UNIQUE (user_id, sco_id, course_id, sv_key); - -CREATE TABLE track_stored_values_stack (id int unsigned not null AUTO_INCREMENT PRIMARY KEY,user_id INT NOT NULL, sco_id INT NOT NULL, stack_order INT NOT NULL, course_id CHAR(40) NOT NULL, sv_key CHAR(64) NOT NULL, sv_value TEXT NOT NULL); -ALTER TABLE track_stored_values_stack ADD KEY (user_id, sco_id, course_id, sv_key, stack_order); -ALTER TABLE track_stored_values_stack ADD UNIQUE (user_id, sco_id, course_id, sv_key, stack_order); - -ALTER TABLE track_e_attempt ADD COLUMN filename VARCHAR(255) DEFAULT NULL; -ALTER TABLE track_e_default ADD COLUMN c_id INTEGER DEFAULT NULL; - -ALTER TABLE track_e_attempt_recording ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); -ALTER TABLE track_e_attempt ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); -ALTER TABLE track_e_hotpotatoes ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); - -CREATE TABLE track_e_attempt_coeff ( id int unsigned not null auto_increment primary key, attempt_id INT NOT NULL, marks_coeff float(6,2)); - --- xxUSERxx -ALTER TABLE personal_agenda ADD COLUMN all_day INTEGER NOT NULL DEFAULT 0; - --- xxCOURSExx -CREATE TABLE IF NOT EXISTS metadata (c_id INT NOT NULL, eid VARCHAR(250) NOT NULL, mdxmltext TEXT default '', md5 CHAR(32) default '', htmlcache1 TEXT default '', htmlcache2 TEXT default '', indexabletext TEXT default '', PRIMARY KEY (c_id, eid)) - -ALTER TABLE lp ADD COLUMN hide_toc_frame INT NOT NULL DEFAULT 0; -ALTER TABLE lp ADD COLUMN seriousgame_mode INT NOT NULL DEFAULT 0; -ALTER TABLE lp_item_view modify column suspend_data longtext; -ALTER TABLE quiz ADD COLUMN review_answers INT NOT NULL DEFAULT 0; -ALTER TABLE student_publication ADD COLUMN contains_file INTEGER NOT NULL DEFAULT 1; -ALTER TABLE student_publication ADD COLUMN allow_text_assignment INTEGER NOT NULL DEFAULT 0; -ALTER TABLE quiz ADD COLUMN random_by_category INT NOT NULL DEFAULT 0; -ALTER TABLE quiz ADD COLUMN text_when_finished TEXT DEFAULT NULL; -ALTER TABLE quiz ADD COLUMN display_category_name INT NOT NULL DEFAULT 1; -ALTER TABLE quiz ADD COLUMN pass_percentage INT DEFAULT NULL; -INSERT INTO course_setting(variable,value,category) VALUES ('allow_public_certificates', 0, 'certificates'); - -ALTER TABLE quiz_answer ADD COLUMN answer_code char(10) default ''; -ALTER TABLE quiz_question ADD COLUMN question_code char(10) default ''; \ No newline at end of file diff --git a/main/install/migrate-db-1.8.8-1.9.0-pre.sql.optimized b/main/install/migrate-db-1.8.8-1.9.0-pre.sql.optimized deleted file mode 100755 index faed069bd6..0000000000 --- a/main/install/migrate-db-1.8.8-1.9.0-pre.sql.optimized +++ /dev/null @@ -1,216 +0,0 @@ --- This script updates the databases structure before migrating the data from --- version 1.8.8 (or version 1.8.8.2, 1.8.8.4) to version 1.9.0 --- it is intended as a standalone script, however, because of the multiple --- databases related difficulties, it should be parsed by a PHP script in --- order to connect to and update the right databases. --- There is one line per query, allowing the PHP function file() to read --- all lines separately into an array. The xxMAINxx-type markers are there --- to tell the PHP script which database we're talking about. --- By always using the keyword "TABLE" in the queries, we should be able --- to retrieve and modify the table name from the PHP script if needed, which --- will allow us to deal with the unique-database-type installations --- --- This first part is for the main database - --- xxMAINxx - -LOCK TABLES sys_calendar; -ALTER TABLE sys_calendar ADD COLUMN all_day INTEGER NOT NULL DEFAULT 0; -UNLOCK TABLES; - -CREATE TABLE event_type ( id int unsigned NOT NULL AUTO_INCREMENT, name varchar(50) NOT NULL, name_lang_var varchar(50) NOT NULL, desc_lang_var varchar(50) NOT NULL, extendable_variables varchar(255) NOT NULL, PRIMARY KEY (id)); -LOCK TABLES event_type; -ALTER TABLE event_type ADD INDEX ( name ); - -CREATE TABLE event_type_email_template ( id int unsigned NOT NULL AUTO_INCREMENT, event_type_id int NOT NULL, language_id int NOT NULL, message text NOT NULL, subject varchar(60) NOT NULL, PRIMARY KEY (id)); -LOCK TABLES event_type_email_template; -ALTER TABLE event_type_email_template ADD INDEX ( language_id ); - - -CREATE TABLE announcement_rel_group (group_id int NOT NULL, announcement_id int NOT NULL, PRIMARY KEY (group_id, announcement_id)); - -CREATE TABLE group_rel_group ( id int NOT NULL AUTO_INCREMENT, group_id int NOT NULL, subgroup_id int NOT NULL, relation_type int NOT NULL, PRIMARY KEY (id)); - -CREATE TABLE chat (id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, from_user INTEGER, to_user INTEGER, message TEXT NOT NULL, sent DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', recd INTEGER UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (id)); - -CREATE TABLE track_course_ranking (id int unsigned not null PRIMARY KEY AUTO_INCREMENT, c_id int unsigned not null, session_id int unsigned not null default 0, url_id int unsigned not null default 0, accesses int unsigned not null default 0, total_score int unsigned not null default 0, users int unsigned not null default 0, creation_date datetime not null); - -CREATE TABLE user_rel_course_vote ( id int unsigned not null AUTO_INCREMENT PRIMARY KEY, c_id int unsigned not null, user_id int unsigned not null, session_id int unsigned not null default 0, url_id int unsigned not null default 0, vote int unsigned not null default 0); - -CREATE TABLE grade_model (id INTEGER NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, description TEXT, default_lowest_eval_exclude TINYINT default null, default_external_eval_prefix VARCHAR(140) default null, PRIMARY KEY (id)); - -CREATE TABLE grade_components (id INTEGER NOT NULL AUTO_INCREMENT, percentage VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL, acronym VARCHAR(255) NOT NULL, grade_model_id INTEGER NOT NULL, PRIMARY KEY (id)); - -CREATE TABLE event_email_template ( id int NOT NULL AUTO_INCREMENT, message text, subject varchar(255) DEFAULT NULL, event_type_name varchar(255) DEFAULT NULL, activated tinyint NOT NULL DEFAULT '0', language_id int DEFAULT NULL, PRIMARY KEY (id)); - -CREATE TABLE event_sent ( id int NOT NULL AUTO_INCREMENT, user_from int NOT NULL, user_to int DEFAULT NULL, event_type_name varchar(100) DEFAULT NULL, PRIMARY KEY (id)); - -CREATE TABLE user_rel_event_type ( id int NOT NULL AUTO_INCREMENT, user_id int NOT NULL, event_type_name varchar(255) NOT NULL, PRIMARY KEY (id)); - -CREATE TABLE IF NOT EXISTS skill ( id int NOT NULL AUTO_INCREMENT, name varchar(255) NOT NULL, short_code varchar(100) NOT NULL, description TEXT NOT NULL, access_url_id int NOT NULL, icon varchar(255) NOT NULL, PRIMARY KEY (id)); - -CREATE TABLE IF NOT EXISTS skill_rel_gradebook ( id int NOT NULL AUTO_INCREMENT, gradebook_id int NOT NULL, skill_id int NOT NULL, type varchar(10) NOT NULL, PRIMARY KEY (id)); - -CREATE TABLE IF NOT EXISTS skill_rel_skill (id int NOT NULL AUTO_INCREMENT, skill_id int NOT NULL, parent_id int NOT NULL, relation_type int NOT NULL, level int NOT NULL, PRIMARY KEY (id)); - -CREATE TABLE IF NOT EXISTS skill_rel_user ( id int NOT NULL AUTO_INCREMENT, user_id int NOT NULL, skill_id int NOT NULL, acquired_skill_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00',assigned_by int NOT NULL,PRIMARY KEY (id)); - -CREATE TABLE IF NOT EXISTS skill_profile ( id INTEGER NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, description TEXT NOT NULL, PRIMARY KEY (id)); - -CREATE TABLE IF NOT EXISTS skill_rel_profile ( id INTEGER NOT NULL AUTO_INCREMENT, skill_id INTEGER NOT NULL, profile_id INTEGER NOT NULL, PRIMARY KEY (id)); - -CREATE TABLE course_type (id int unsigned not null auto_increment primary key, name varchar(50) not null, translation_var char(40) default 'UndefinedCourseTypeLabel', description TEXT default '', props text default ''); - -CREATE TABLE usergroup_rel_question (id int unsigned not null auto_increment primary key, c_id int unsigned not null, question_id int unsigned not null, usergroup_id int unsigned not null, coefficient float(6,2)); - -CREATE TABLE track_stored_values (id int unsigned not null AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, sco_id INT NOT NULL, course_id CHAR(40) NOT NULL, sv_key CHAR(64) NOT NULL, sv_value TEXT NOT NULL); - -CREATE TABLE track_stored_values_stack (id int unsigned not null AUTO_INCREMENT PRIMARY KEY,user_id INT NOT NULL, sco_id INT NOT NULL, stack_order INT NOT NULL, course_id CHAR(40) NOT NULL, sv_key CHAR(64) NOT NULL, sv_value TEXT NOT NULL); - -CREATE TABLE track_e_attempt_coeff ( id int unsigned not null auto_increment primary key, attempt_id INT NOT NULL, marks_coeff float(6,2)); - - -LOCK TABLES group_rel_group, course_rel_user, session_rel_course_rel_user, course, gradebook_category, gradebook_link, chat, track_course_ranking, user_rel_course_vote, user; -ALTER TABLE group_rel_group ADD INDEX ( group_id ); -ALTER TABLE group_rel_group ADD INDEX ( subgroup_id ); -ALTER TABLE group_rel_group ADD INDEX ( relation_type ); -ALTER TABLE course_rel_user ADD COLUMN legal_agreement INTEGER DEFAULT 0; -ALTER TABLE session_rel_course_rel_user ADD COLUMN legal_agreement INTEGER DEFAULT 0; -ALTER TABLE course ADD COLUMN legal TEXT NOT NULL; -ALTER TABLE course ADD COLUMN activate_legal INT NOT NULL DEFAULT 0; -ALTER TABLE gradebook_category MODIFY COLUMN weight FLOAT NOT NULL; -ALTER TABLE gradebook_category ADD COLUMN locked INT DEFAULT 0; -ALTER TABLE gradebook_category ADD COLUMN default_lowest_eval_exclude TINYINT default null; -ALTER TABLE gradebook_link MODIFY COLUMN weight FLOAT NOT NULL; -ALTER TABLE gradebook_link ADD COLUMN locked INT DEFAULT 0; -ALTER TABLE chat ADD INDEX idx_chat_to_user (to_user); -ALTER TABLE chat ADD INDEX idx_chat_from_user (from_user); -ALTER TABLE track_course_ranking ADD INDEX idx_tcc_cid (c_id); -ALTER TABLE track_course_ranking ADD INDEX idx_tcc_sid (session_id); -ALTER TABLE track_course_ranking ADD INDEX idx_tcc_urlid (url_id); -ALTER TABLE track_course_ranking ADD INDEX idx_tcc_creation_date (creation_date); -ALTER TABLE user_rel_course_vote ADD INDEX idx_ucv_cid (c_id); -ALTER TABLE user_rel_course_vote ADD INDEX idx_ucv_uid (user_id); -ALTER TABLE user_rel_course_vote ADD INDEX idx_ucv_cuid (user_id, c_id); -ALTER TABLE course MODIFY COLUMN disk_quota bigint unsigned DEFAULT NULL; -ALTER TABLE user MODIFY COLUMN username VARCHAR(100) NOT NULL; -UNLOCK TABLES; - -LOCK_TABLES gradebook_category, settings_current, event_email_template, event_sent, user_rel_event_type, usergroup_rel_session, usergroup_rel_course, usergroup_rel_user, admin, reservation_category_rights, course, user_api_key, track_e_default, track_e_exercises; -ALTER TABLE gradebook_category ADD COLUMN grade_model_id INT DEFAULT 0; -ALTER TABLE gradebook_evaluation MODIFY COLUMN weight FLOAT NOT NULL; -ALTER TABLE settings_current ADD COLUMN access_url_locked INTEGER NOT NULL DEFAULT 0; -ALTER TABLE event_email_template ADD INDEX event_name_index (event_type_name); -ALTER TABLE event_sent ADD INDEX event_name_index (event_type_name); -ALTER TABLE user_rel_event_type ADD INDEX event_name_index (event_type_name); -ALTER TABLE usergroup_rel_session ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); -ALTER TABLE usergroup_rel_course ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); -ALTER TABLE usergroup_rel_user ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); -ALTER TABLE admin ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); -ALTER TABLE reservation_category_rights ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); -ALTER TABLE course add course_type_id int unsigned default 1; -ALTER TABLE user_api_key ADD COLUMN api_end_point text DEFAULT NULL; -ALTER TABLE user_api_key ADD COLUMN created_date datetime DEFAULT NULL; -ALTER TABLE user_api_key ADD COLUMN validity_start_date datetime DEFAULT NULL; -ALTER TABLE user_api_key ADD COLUMN validity_end_date datetime DEFAULT NULL; -ALTER TABLE user_api_key ADD COLUMN description text DEFAULT NULL; -ALTER TABLE track_e_default MODIFY COLUMN default_value TEXT; -ALTER TABLE track_e_exercices ADD COLUMN questions_to_check TEXT NOT NULL DEFAULT ''; -UNLOCK TABLES; - -LOCK TABLES track_stored_values, track_stored_values_stack, track_e_attempt, track_e_attempt_recording, track_e_hotpotatoes, personal_agenda; -ALTER TABLE track_stored_values ADD KEY (user_id, sco_id, course_id, sv_key); -ALTER TABLE track_stored_values ADD UNIQUE (user_id, sco_id, course_id, sv_key); -ALTER TABLE track_stored_values_stack ADD KEY (user_id, sco_id, course_id, sv_key, stack_order); -ALTER TABLE track_stored_values_stack ADD UNIQUE (user_id, sco_id, course_id, sv_key, stack_order); -ALTER TABLE track_e_attempt ADD COLUMN filename VARCHAR(255) DEFAULT NULL; -ALTER TABLE track_e_default ADD COLUMN c_id INTEGER DEFAULT NULL; -ALTER TABLE track_e_attempt_recording ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); -ALTER TABLE track_e_attempt ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); -ALTER TABLE track_e_hotpotatoes ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id); -ALTER TABLE personal_agenda ADD COLUMN all_day INTEGER NOT NULL DEFAULT 0; -UNLOCK TABLES; - -INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) values (1, 'already_logged_in','Already logged in',0,0), (1, 'update_type','Update script type',0,0), (1, 'google_calendar_url','Google Calendar URL',0,0), (1, 'user_chat_status','User chat status', 0, 0); - - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('filter_terms', NULL, 'textarea', 'Security', '', 'FilterTermsTitle', 'FilterTermsComment', NULL, NULL, 0), ('header_extra_content', NULL, 'textarea', 'Tracking', '', 'HeaderExtraContentTitle', 'HeaderExtraContentComment', NULL, NULL, 1),('footer_extra_content', NULL, 'textarea', 'Tracking', '', 'FooterExtraContentTitle', 'FooterExtraContentComment', NULL, NULL,1), ('show_documents_preview', NULL, 'radio', 'Tools', 'false', 'ShowDocumentPreviewTitle', 'ShowDocumentPreviewComment', NULL, NULL, 1), ('htmlpurifier_wiki',NULL,'radio','Editor','false','HtmlPurifierWikiTitle','HtmlPurifierWikiComment',NULL,NULL, 0), ('cas_activate', NULL, 'radio', 'CAS', 'false', 'CasMainActivateTitle', 'CasMainActivateComment', NULL, NULL, 0), ('cas_server', NULL, 'textfield', 'CAS', '', 'CasMainServerTitle', 'CasMainServerComment', NULL, NULL, 0), ('cas_server_uri', NULL, 'textfield', 'CAS', '', 'CasMainServerURITitle', 'CasMainServerURIComment', NULL, NULL, 0), ('cas_port', NULL, 'textfield', 'CAS', '', 'CasMainPortTitle', 'CasMainPortComment', NULL, NULL, 0), ('cas_protocol', NULL, 'radio', 'CAS', '', 'CasMainProtocolTitle', 'CasMainProtocolComment', NULL, NULL, 0), ('cas_add_user_activate', NULL, 'radio', 'CAS', 'false', 'CasUserAddActivateTitle', 'CasUserAddActivateComment', NULL, NULL, 0), ('update_user_info_cas_with_ldap', NULL, 'radio', 'CAS', 'true', 'UpdateUserInfoCasWithLdapTitle', 'UpdateUserInfoCasWithLdapComment', NULL, NULL, 0), ('use_custom_pages', NULL, 'radio','Platform','false','UseCustomPagesTitle','UseCustomPagesComment', NULL, NULL, 1); - -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_documents_preview', 'true', 'Yes'), ('show_documents_preview', 'false', 'No'), ('htmlpurifier_wiki', 'true', 'Yes'), ('htmlpurifier_wiki', 'false', 'No'), ('cas_activate', 'true', 'Yes'), ('cas_activate', 'false', 'No'), ('cas_protocol', 'CAS1', 'CAS1Text'), ('cas_protocol', 'CAS2', 'CAS2Text'), ('cas_protocol', 'SAML', 'SAMLText'), ('cas_add_user_activate', 'platform', 'casAddUserActivatePlatform'), ('cas_add_user_activate', 'extldap', 'casAddUserActivateLDAP'), ('cas_add_user_activate', 'false', 'No'), ('use_custom_pages', 'true', 'Yes'), ('use_custom_pages', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('student_page_after_login', NULL, 'textfield', 'Platform', '', 'StudentPageAfterLoginTitle', 'StudentPageAfterLoginComment', NULL, NULL, 0), ('teacher_page_after_login', NULL, 'textfield', 'Platform', '', 'TeacherPageAfterLoginTitle', 'TeacherPageAfterLoginComment', NULL, NULL, 0), ('drh_page_after_login', NULL, 'textfield', 'Platform', '', 'DRHPageAfterLoginTitle', 'DRHPageAfterLoginComment', NULL, NULL, 0), ('sessionadmin_page_after_login', NULL, 'textfield', 'Session', '', 'SessionAdminPageAfterLoginTitle', 'SessionAdminPageAfterLoginComment', NULL, NULL, 0), ('student_autosubscribe', NULL, 'textfield', 'Platform', '', 'StudentAutosubscribeTitle', 'StudentAutosubscribeComment', NULL, NULL, 0), ('teacher_autosubscribe', NULL, 'textfield', 'Platform', '', 'TeacherAutosubscribeTitle', 'TeacherAutosubscribeComment', NULL, NULL, 0), ('drh_autosubscribe', NULL, 'textfield', 'Platform', '', 'DRHAutosubscribeTitle', 'DRHAutosubscribeComment', NULL, NULL, 0), ('sessionadmin_autosubscribe', NULL, 'textfield', 'Session', '', 'SessionadminAutosubscribeTitle', 'SessionadminAutosubscribeComment', NULL, NULL, 0), ('show_tabs', 'custom_tab_1', 'checkbox', 'Platform', 'true', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom1', 1), ('show_tabs', 'custom_tab_2', 'checkbox', 'Platform', 'false', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom2', 1), ('show_tabs', 'custom_tab_3', 'checkbox', 'Platform', 'false', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom3', 1), ('languagePriority1', NULL, 'radio', 'Languages', 'course_lang', 'LanguagePriority1Title', 'LanguagePriority1Comment', NULL, NULL, 0), ('languagePriority2', NULL, 'radio', 'Languages', 'user_profil_lang', 'LanguagePriority2Title', 'LanguagePriority2Comment', NULL, NULL, 0), ('languagePriority3', NULL, 'radio', 'Languages', 'user_selected_lang', 'LanguagePriority3Title', 'LanguagePriority3Comment', NULL, NULL, 0), ('languagePriority4', NULL, 'radio', 'Languages', 'platform_lang', 'LanguagePriority4Title', 'LanguagePriority4Comment', NULL, NULL, 0); - -INSERT INTO settings_options (variable, value, display_text) VALUES ('languagePriority1','platform_lang','PlatformLanguage'), ('languagePriority1','user_profil_lang','UserLanguage'), ('languagePriority1','user_selected_lang','UserSelectedLanguage'), ('languagePriority1','course_lang','CourseLanguage'), ('languagePriority2','platform_lang','PlatformLanguage'), ('languagePriority2','user_profil_lang','UserLanguage'), ('languagePriority2','user_selected_lang','UserSelectedLanguage'), ('languagePriority2','course_lang','CourseLanguage'), ('languagePriority3','platform_lang','PlatformLanguage'), ('languagePriority3','user_profil_lang','UserLanguage'), ('languagePriority3','user_selected_lang','UserSelectedLanguage'), ('languagePriority3','course_lang','CourseLanguage'), ('languagePriority4','platform_lang','PlatformLanguage'), ('languagePriority4','user_profil_lang','UserLanguage'), ('languagePriority4','user_selected_lang','UserSelectedLanguage'), ('languagePriority4','course_lang','CourseLanguage'), ('login_is_email', NULL, 'radio', 'Platform', 'false', 'LoginIsEmailTitle', 'LoginIsEmailComment', NULL, NULL, 0), ('scorm_cumulative_session_time', NULL, 'radio', 'Course', 'true', 'ScormCumulativeSessionTimeTitle', 'ScormCumulativeSessionTimeComment', NULL, NULL, 0), ('login_is_email','true','Yes'),('login_is_email','false','No'), ('scorm_cumulative_session_time','true','Yes'), ('scorm_cumulative_session_time','false','No'); - - - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('gradebook_enable_grade_model', NULL, 'radio', 'Gradebook', 'false', 'GradebookEnableGradeModelTitle', 'GradebookEnableGradeModelComment', NULL, NULL, 1), ('teachers_can_change_grade_model_settings', NULL, 'radio', 'Gradebook', 'true', 'TeachersCanChangeGradeModelSettingsTitle', 'TeachersCanChangeGradeModelSettingsComment', NULL, NULL, 1), ('gradebook_locking_enabled', NULL, 'radio', 'Gradebook', 'false', 'GradebookEnableLockingTitle', 'GradebookEnableLockingComment', NULL, NULL, 0), ('teachers_can_change_score_settings', NULL, 'radio', 'Gradebook', 'true', 'TeachersCanChangeScoreSettingsTitle', 'TeachersCanChangeScoreSettingsComment', NULL, NULL, 1), ('allow_users_to_change_email_with_no_password', NULL, 'radio', 'User', 'false', 'AllowUsersToChangeEmailWithNoPasswordTitle', 'AllowUsersToChangeEmailWithNoPasswordComment', NULL, NULL, 0), ('allow_session_admins_to_manage_all_sessions', NULL, 'radio', 'Session', 'false', 'AllowSessionAdminsToSeeAllSessionsTitle', 'AllowSessionAdminsToSeeAllSessionsComment', NULL, NULL, 1), ('shibboleth_description', NULL, 'radio', 'Shibboleth', 'false', 'ShibbolethMainActivateTitle', 'ShibbolethMainActivateComment', NULL, NULL, 0), ('facebook_description', NULL, 'radio', 'Facebook', 'false', 'FacebookMainActivateTitle', 'FacebookMainActivateComment', NULL, NULL, 0), ('ldap_description', NULL, 'radio', 'LDAP', NULL, 'LdapDescriptionTitle', 'LdapDescriptionComment', NULL, NULL, 0), ('enable_help_link', NULL, 'radio', 'Platform', 'true', 'EnableHelpLinkTitle', 'EnableHelpLinkComment', NULL, NULL, 0), ('allow_hr_skills_management', NULL, 'radio', 'Gradebook', 'true', 'AllowHRSkillsManagementTitle', 'AllowHRSkillsManagementComment', NULL, NULL, 1); - -INSERT INTO settings_options (variable, value, display_text) VALUES ('gradebook_enable_grade_model', 'true', 'Yes'), ('gradebook_enable_grade_model', 'false', 'No'), ('teachers_can_change_grade_model_settings', 'true', 'Yes'), ('teachers_can_change_grade_model_settings', 'false', 'No'), ('gradebook_locking_enabled', 'true', 'Yes'), ('gradebook_locking_enabled', 'false', 'No'), ('teachers_can_change_score_settings', 'true', 'Yes'), ('teachers_can_change_score_settings', 'false', 'No'), ('allow_users_to_change_email_with_no_password', 'true', 'Yes'), ('allow_users_to_change_email_with_no_password', 'false', 'No'), ('allow_session_admins_to_manage_all_sessions', 'true', 'Yes'), ('allow_session_admins_to_manage_all_sessions', 'false', 'No'), ('enable_help_link', 'true', 'Yes'), (variable, value, display_text) VALUES ('enable_help_link', 'false', 'No'), ('allow_hr_skills_management', 'true', 'Yes'), ('allow_hr_skills_management', 'false', 'No'); - - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('show_admin_toolbar', NULL, 'radio', 'Platform', 'show_to_admin', 'ShowAdminToolbarTitle', 'ShowAdminToolbarComment', NULL, NULL, 1), ('allow_global_chat', NULL, 'radio', 'Platform', 'true', 'AllowGlobalChatTitle', 'AllowGlobalChatComment', NULL, NULL, 1), ('courses_default_creation_visibility', NULL, 'radio', 'Course', '2', 'CoursesDefaultCreationVisibilityTitle', 'CoursesDefaultCreationVisibilityComment', NULL, NULL, 1), ('allow_browser_sniffer', NULL, 'radio', 'Tuning', 'false', 'AllowBrowserSnifferTitle', 'AllowBrowserSnifferComment', NULL, NULL, 0), ('enable_wami_record', NULL, 'radio', 'Tools', 'false', 'EnableWamiRecordTitle', 'EnableWamiRecordComment', NULL, NULL, 0), ('allow_public_certificates', NULL, 'radio', 'Course', 'false', 'AllowPublicCertificatesTitle', 'AllowPublicCertificatesComment', NULL, NULL, 1), ('enable_iframe_inclusion', NULL, 'radio', 'Editor', 'false', 'EnableIframeInclusionTitle', 'EnableIframeInclusionComment', NULL, NULL, 1); - -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_admin_toolbar', 'do_not_show', 'DoNotShow'), ('show_admin_toolbar', 'show_to_admin', 'ShowToAdminsOnly'), ('show_admin_toolbar', 'show_to_admin_and_teachers', 'ShowToAdminsAndTeachers'), ('show_admin_toolbar', 'show_to_all', 'ShowToAllUsers'), ('allow_global_chat', 'true', 'Yes'), ('allow_global_chat', 'false', 'No'), ('courses_default_creation_visibility', '3', 'OpenToTheWorld'), ('courses_default_creation_visibility', '2', 'OpenToThePlatform'), ('courses_default_creation_visibility', '1', 'Private'), ('courses_default_creation_visibility', '0', 'CourseVisibilityClosed'), ('allow_browser_sniffer', 'true', 'Yes'), ('allow_browser_sniffer', 'false', 'No'), ('enable_wami_record', 'true', 'Yes'), ('enable_wami_record', 'false', 'No'), ('allow_public_certificates', 'true', 'Yes'), ('allow_public_certificates', 'false', 'No'), ('enable_iframe_inclusion', 'true', 'Yes'), ('enable_iframe_inclusion', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('show_hot_courses', NULL, 'radio', 'Platform', 'true', 'ShowHotCoursesTitle', 'ShowHotCoursesComment', NULL, NULL, 1), ('gradebook_default_weight', NULL, 'textfield', 'Gradebook', '100', 'GradebookDefaultWeightTitle', 'GradebookDefaultWeightComment', NULL, NULL, 1), ('gradebook_default_grade_model_id', NULL, 'select', 'Gradebook', '', 'GradebookDefaultGradeModelTitle', 'GradebookDefaultGradeModelComment', NULL, NULL, 1); - -UPDATE settings_current SET category = 'Session' WHERE variable IN ('show_tutor_data', 'use_session_mode', 'add_users_by_coach', 'show_session_coach', 'show_session_data', 'allow_coach_to_edit_course_session','hide_courses_in_sessions', 'show_groups_to_users'); - - -INSERT INTO language (original_name, english_name, isocode, dokeos_folder, available) VALUES ('বাংলা','bengali','bn','bengali',0), ('الصومالية','somali','so','somali',0); - - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enable_webcam_clip', NULL, 'radio', 'Tools', 'false', 'EnableWebCamClipTitle', 'EnableWebCamClipComment', NULL, NULL, 0), ('tool_visible_by_default_at_creation','documents','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Documents', 1), ('tool_visible_by_default_at_creation','learning_path','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'LearningPath', 1), ('tool_visible_by_default_at_creation','links','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Links', 1), ('tool_visible_by_default_at_creation','announcements','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Announcements', 1), ('tool_visible_by_default_at_creation','forums','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Forums', 1), ('tool_visible_by_default_at_creation','quiz','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Quiz', 1), ('tool_visible_by_default_at_creation','gradebook','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Gradebook', 1), ('activate_email_template', NULL, 'radio', 'Platform', 'false', 'ActivateEmailTemplateTitle', 'ActivateEmailTemplateComment', NULL, NULL, 0); - -UPDATE settings_current SET title = 'DatabaseVersion' WHERE variable = 'chamilo_database_version'; -UPDATE settings_current SET selected_value = 'true' WHERE variable = 'more_buttons_maximized_mode'; - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_skills_tool', NULL, 'radio', 'Platform', 'false', 'AllowSkillsToolTitle', 'AllowSkillsToolComment', NULL, NULL, 1); - -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_hot_courses', 'true', 'Yes'), ('show_hot_courses', 'false', 'No'), ('enable_webcam_clip', 'true', 'Yes'), ('enable_webcam_clip', 'false', 'No'), ('page_after_login', 'main/auth/courses.php', 'CourseCatalog'), ('activate_email_template', 'true', 'Yes'),('activate_email_template', 'false', 'No'), ('allow_skills_tool', 'true', 'Yes'), ('allow_skills_tool', 'false', 'No'); - -INSERT INTO skill (name) VALUES ('Root'); -INSERT INTO skill_rel_skill VALUES(1, 1, 0, 0, 0); - -DELETE FROM settings_current WHERE variable = 'use_document_title'; -DELETE FROM settings_options WHERE variable = 'use_document_title'; - -UPDATE language SET english_name = 'basque' , dokeos_folder = 'basque' where english_name = 'euskera'; -UPDATE language SET english_name = 'turkish', dokeos_folder = 'turkish' where english_name = 'turkce'; - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('platform_unsubscribe_allowed', NULL, 'radio', 'Platform', 'false', 'PlatformUnsubscribeTitle', 'PlatformUnsubscribeComment', NULL, NULL, 1); - -INSERT INTO settings_options (variable, value, display_text) values ('platform_unsubscribe_allowed', 'true', 'Yes'), ('platform_unsubscribe_allowed', 'false', 'No'); - -INSERT INTO course_type (id, name) VALUES (1, 'All tools'); -INSERT INTO course_type (id, name) VALUES (2, 'Entry exam'); - -DELETE FROM settings_current WHERE variable = 'read_more_limit'; -DELETE FROM settings_current WHERE variable = 'user_order_by'; -DELETE FROM settings_options WHERE variable = 'user_order_by'; - - --- Do not move this query -UPDATE settings_current SET selected_value = '1.9.0.18715b' WHERE variable = 'chamilo_database_version'; - --- xxSTATSxx - --- xxUSERxx - --- xxCOURSExx - -CREATE TABLE IF NOT EXISTS metadata (c_id INT NOT NULL, eid VARCHAR(250) NOT NULL, mdxmltext TEXT default '', md5 CHAR(32) default '', htmlcache1 TEXT default '', htmlcache2 TEXT default '', indexabletext TEXT default '', PRIMARY KEY (c_id, eid)) -ALTER TABLE lp ADD COLUMN hide_toc_frame INT NOT NULL DEFAULT 0; -ALTER TABLE lp ADD COLUMN seriousgame_mode INT NOT NULL DEFAULT 0; -ALTER TABLE lp_item_view modify column suspend_data longtext; -ALTER TABLE quiz ADD COLUMN review_answers INT NOT NULL DEFAULT 0; -ALTER TABLE student_publication ADD COLUMN contains_file INTEGER NOT NULL DEFAULT 1; -ALTER TABLE student_publication ADD COLUMN allow_text_assignment INTEGER NOT NULL DEFAULT 0; -ALTER TABLE quiz ADD COLUMN random_by_category INT NOT NULL DEFAULT 0; -ALTER TABLE quiz ADD COLUMN text_when_finished TEXT DEFAULT NULL; -ALTER TABLE quiz ADD COLUMN display_category_name INT NOT NULL DEFAULT 1; -ALTER TABLE quiz ADD COLUMN pass_percentage INT DEFAULT NULL; -ALTER TABLE quiz_answer ADD COLUMN answer_code char(10) default ''; -ALTER TABLE quiz_question ADD COLUMN question_code char(10) default ''; -INSERT INTO course_setting(variable,value,category) VALUES ('allow_public_certificates', 0, 'certificates'); diff --git a/main/install/migrate-db-1.9.0-1.10.0-post.sql b/main/install/migrate-db-1.9.0-1.10.0-post.sql deleted file mode 100644 index 9e61eb72c9..0000000000 --- a/main/install/migrate-db-1.9.0-1.10.0-post.sql +++ /dev/null @@ -1,34 +0,0 @@ --- This script updates the databases structure after migrating the data from --- version 1.9.0 (or version 1.9.*) to version 1.10.0 --- it is intended as a standalone script, however, because of the multiple --- databases related difficulties, it should be parsed by a PHP script in --- order to connect to and update the right databases. --- There is one line per query, allowing the PHP function file() to read --- all lines separately into an array. The xxMAINxx-type markers are there --- to tell the PHP script which database we're talking about. --- By always using the keyword "TABLE" in the queries, we should be able --- to retrieve and modify the table name from the PHP script if needed, which --- will allow us to deal with the unique-database-type installations --- --- This first part is for the main database - --- xxMAINxx - -ALTER TABLE track_e_access DROP COLUMN access_cours_code; -ALTER TABLE track_e_default DROP COLUMN default_cours_code; -ALTER TABLE track_e_lastaccess DROP COLUMN access_cours_code; -ALTER TABLE track_e_exercises DROP COLUMN exe_cours_id; -ALTER TABLE track_e_downloads DROP COLUMN down_cours_id; -ALTER TABLE track_e_hotpotatoes DROP COLUMN exe_cours_id; -ALTER TABLE track_e_links DROP COLUMN links_cours_id; -ALTER TABLE track_e_course_access DROP COLUMN course_code; -ALTER TABLE track_e_online DROP COLUMN course; -ALTER TABLE track_e_attempt DROP COLUMN course_code; - --- not yet ready, uncomment when all user_id have been replaced by id --- ALTER TABLE user DROP COLUMN user_id; - --- xxCOURSExx - - - diff --git a/main/install/migrate-db-1.9.0-1.10.0-pre.sql b/main/install/migrate-db-1.9.0-1.10.0-pre.sql deleted file mode 100644 index 86bdc9f99e..0000000000 --- a/main/install/migrate-db-1.9.0-1.10.0-pre.sql +++ /dev/null @@ -1,136 +0,0 @@ --- This script updates the databases structure before migrating the data from --- version 1.9.0 (or version 1.9.*) to version 1.10.0 - --- Main DB changes - -ALTER TABLE skill_rel_user ADD COLUMN course_id INT NOT NULL DEFAULT 0 AFTER id; -ALTER TABLE skill_rel_user ADD COLUMN session_id INT NOT NULL DEFAULT 0 AFTER course_id; -ALTER TABLE skill_rel_user ADD INDEX idx_select_cs (course_id, session_id); - -CREATE TABLE IF NOT EXISTS hook_observer( id int UNSIGNED NOT NULL AUTO_INCREMENT, class_name varchar(255) UNIQUE, path varchar(255) NOT NULL, plugin_name varchar(255) NULL, PRIMARY KEY PK_hook_management_hook_observer(id)); -CREATE TABLE IF NOT EXISTS hook_event( id int UNSIGNED NOT NULL AUTO_INCREMENT, class_name varchar(255) UNIQUE, description varchar(255), PRIMARY KEY PK_hook_management_hook_event(id)); -CREATE TABLE IF NOT EXISTS hook_call( id int UNSIGNED NOT NULL AUTO_INCREMENT, hook_event_id int UNSIGNED NOT NULL, hook_observer_id int UNSIGNED NOT NULL, type tinyint NOT NULL, hook_order int UNSIGNED NOT NULL, enabled tinyint NOT NULL, PRIMARY KEY PK_hook_management_hook_call(id)); - -ALTER TABLE session ADD COLUMN description TEXT DEFAULT NULL; -ALTER TABLE session ADD COLUMN show_description TINYINT UNSIGNED DEFAULT 0 AFTER description; - -ALTER TABLE session_rel_course ADD COLUMN position int NOT NULL default 0; -ALTER TABLE session_rel_course ADD COLUMN category varchar(255) default ''; -ALTER TABLE session ADD COLUMN duration int; -ALTER TABLE session_rel_user ADD COLUMN duration int; - -CREATE TABLE course_field_options (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, field_id INT NOT NULL, option_value TEXT, option_display_text VARCHAR(64), option_order INT, tms DATETIME); -CREATE TABLE session_field_options (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, field_id INT NOT NULL, option_value TEXT, option_display_text VARCHAR(64), option_order INT, tms DATETIME); - -ALTER TABLE skill ADD COLUMN criteria text DEFAULT ''; - -ALTER TABLE gradebook_category ADD COLUMN generate_certificates TINYINT NOT NULL DEFAULT 0; - -RENAME TABLE track_e_exercices TO track_e_exercises; - -ALTER TABLE track_e_access ADD COLUMN c_id int NOT NULL; -UPDATE track_e_access SET c_id = (SELECT id FROM course WHERE code = access_cours_code); -ALTER TABLE track_e_default ADD COLUMN c_id int NOT NULL; -UPDATE track_e_default SET c_id = (SELECT id FROM course WHERE code = default_cours_code); -ALTER TABLE track_e_lastaccess ADD COLUMN c_id int NOT NULL; -UPDATE track_e_lastaccess SET c_id = (SELECT id FROM course WHERE code = access_cours_code); -ALTER TABLE track_e_exercises ADD COLUMN c_id int NOT NULL; -UPDATE track_e_exercises SET c_id = (SELECT id FROM course WHERE code = exe_cours_id); -ALTER TABLE track_e_downloads ADD COLUMN c_id int NOT NULL; -UPDATE track_e_downloads SET c_id = (SELECT id FROM course WHERE code = down_cours_id); -ALTER TABLE track_e_hotpotatoes ADD COLUMN c_id int NOT NULL; -UPDATE track_e_hotpotatoes SET c_id = (SELECT id FROM course WHERE code = exe_cours_id); -ALTER TABLE track_e_links ADD COLUMN c_id int NOT NULL; -UPDATE track_e_links SET c_id = (SELECT id FROM course WHERE code = links_cours_id); -ALTER TABLE track_e_course_access ADD COLUMN c_id int NOT NULL; -UPDATE track_e_course_access SET c_id = (SELECT id FROM course WHERE code = course_code); -ALTER TABLE track_e_online ADD COLUMN c_id int NOT NULL; -UPDATE track_e_online SET c_id = (SELECT id FROM course WHERE code = course); -ALTER TABLE track_e_attempt ADD COLUMN c_id int NOT NULL; -UPDATE track_e_attempt SET c_id = (SELECT id FROM course WHERE code = course_code); -ALTER TABLE track_e_default ADD COLUMN session_id int NOT NULL; - - -DELETE FROM settings_current WHERE variable = 'wcag_anysurfer_public_pages'; -DELETE FROM settings_options WHERE variable = 'wcag_anysurfer_public_pages'; -DELETE FROM settings_current WHERE variable = 'advanced_filemanager'; -DELETE FROM settings_options WHERE variable = 'advanced_filemanager'; - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('prevent_session_admins_to_manage_all_users', NULL, 'radio', 'Session', 'false', 'PreventSessionAdminsToManageAllUsersTitle', 'PreventSessionAdminsToManageAllUsersComment', NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('prevent_session_admins_to_manage_all_users', 'true', 'Yes'), ('prevent_session_admins_to_manage_all_users', 'false', 'No'); - -ALTER TABLE track_e_access ADD COLUMN user_ip varchar(39) NOT NULL default ''; -ALTER TABLE track_e_exercises ADD COLUMN user_ip varchar(39) NOT NULL default ''; -ALTER TABLE track_e_course_access ADD COLUMN user_ip varchar(39) NOT NULL default ''; -ALTER TABLE track_e_online CHANGE COLUMN login_ip user_ip varchar(39) NOT NULL DEFAULT ''; -ALTER TABLE track_e_login CHANGE COLUMN login_ip user_ip varchar(39) NOT NULL DEFAULT ''; - -ALTER TABLE user MODIFY COLUMN user_id int unsigned DEFAULT null; -ALTER TABLE user DROP PRIMARY KEY; -ALTER TABLE user ADD COLUMN id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT AFTER user_id; -UPDATE user SET id = user_id; - -ALTER TABLE user MODIFY COLUMN chatcall_date datetime default NULL; -ALTER TABLE user MODIFY COLUMN chatcall_text varchar(50) default NULL; -ALTER TABLE user MODIFY COLUMN chatcall_user_id int unsigned default '0'; -ALTER TABLE user MODIFY COLUMN expiration_date datetime default NULL; -ALTER TABLE user MODIFY COLUMN registration_date datetime NOT NULL; -UPDATE user SET registration_date = NULL WHERE registration_date = '0000-00-00 00:00:00'; -UPDATE user SET expiration_date = NULL WHERE expiration_date = '0000-00-00 00:00:00'; - -UPDATE track_e_default SET default_date = NULL WHERE default_date = '0000-00-00 00:00:00'; -UPDATE track_e_lastaccess SET access_date = NULL WHERE access_date = '0000-00-00 00:00:00'; -UPDATE track_e_downloads SET down_date = NULL WHERE down_date = '0000-00-00 00:00:00'; -UPDATE track_e_access SET access_date = NULL WHERE access_date = '0000-00-00 00:00:00'; - -ALTER TABLE course ADD COLUMN add_teachers_to_sessions_courses tinyint NOT NULL default 0; - -DELETE FROM settings_options WHERE variable = 'show_glossary_in_extra_tools'; - -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'none', 'None'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'exercise', 'Exercise'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'lp', 'Learning path'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'exercise_and_lp', 'ExerciseAndLearningPath'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('documents_default_visibility_defined_in_course', NULL,'radio','Tools','false','DocumentsDefaultVisibilityDefinedInCourseTitle','DocumentsDefaultVisibilityDefinedInCourseComment',NULL, NULL, 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('documents_default_visibility_defined_in_course', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('documents_default_visibility_defined_in_course', 'false', 'No'); - -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enabled_mathjax', NULL, 'radio', 'Editor', 'false', 'EnableMathJaxTitle', 'EnableMathJaxComment', NULL, NULL, 0); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'false', 'No'); - -ALTER TABLE session MODIFY COLUMN name char(100) NOT NULL DEFAULT ''; -ALTER TABLE track_e_default MODIFY COLUMN c_id int default NULL; -UPDATE course_field SET field_type = 1 WHERE field_variable = 'special_course'; - --- v1.10.0.34 -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('meta_twitter_site', NULL, 'textfield', 'Tracking', '', 'MetaTwitterSiteTitle', 'MetaTwitterSiteComment', NULL, NULL, 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('meta_twitter_creator', NULL, 'textfield', 'Tracking', '', 'MetaTwitterCreatorTitle', 'MetaTwitterCreatorComment', NULL, NULL, 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('meta_title', NULL, 'textfield', 'Tracking', '', 'MetaTitleTitle', 'MetaTitleComment', NULL, NULL, 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('meta_description', NULL, 'textfield', 'Tracking', '', 'MetaDescriptionTitle', 'MetaDescriptionComment', NULL, NULL, 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('meta_image_path', NULL, 'textfield', 'Tracking', '', 'MetaImagePathTitle', 'MetaImagePathComment', NULL, NULL, 1); - --- v1.10.0.35 -INSERT INTO language (original_name, english_name, isocode, dokeos_folder, available) VALUES ('Føroyskt', 'faroese', 'fo', 'faroese', 0), ('Tagalog', 'tagalog', 'tl', 'tagalog',1), ('Tibetan', 'tibetan', 'bo', 'tibetan', 0), ('isiXhosa', 'xhosa', 'xh', 'xhosa', 0); - --- Course DB changes (c_*) - -ALTER TABLE c_survey ADD COLUMN visible_results INT UNSIGNED DEFAULT 0; -ALTER TABLE c_survey_invitation ADD COLUMN group_id INT NOT NULL; -ALTER TABLE c_lp_item ADD COLUMN prerequisite_min_score float; -ALTER TABLE c_lp_item ADD COLUMN prerequisite_max_score float; -ALTER TABLE c_lp_item MODIFY COLUMN description VARCHAR(511) DEFAULT ''; -ALTER TABLE c_student_publication ADD COLUMN document_id int DEFAULT 0; -ALTER TABLE c_group_info ADD COLUMN status tinyint DEFAULT 1; - -ALTER TABLE c_course_setting MODIFY COLUMN value varchar(255) default ''; - -CREATE TABLE IF NOT EXISTS c_student_publication_rel_document (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, work_id INT NOT NULL, document_id INT NOT NULL, c_id INT NOT NULL); -CREATE TABLE IF NOT EXISTS c_student_publication_rel_user (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, work_id INT NOT NULL, user_id INT NOT NULL, c_id INT NOT NULL); -CREATE TABLE IF NOT EXISTS c_student_publication_comment (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, work_id INT NOT NULL, c_id INT NOT NULL, comment text, file VARCHAR(255), user_id int NOT NULL, sent_at datetime NOT NULL); -CREATE TABLE IF NOT EXISTS c_attendance_calendar_rel_group (id int NOT NULL auto_increment PRIMARY KEY, c_id INT NOT NULL, group_id INT NOT NULL, calendar_id INT NOT NULL); - - --- Do not move this query -UPDATE settings_current SET selected_value = '1.10.0.35' WHERE variable = 'chamilo_database_version'; diff --git a/main/install/update-configuration.inc.php b/main/install/update-configuration.inc.php index 2eef2d1bf6..8dd31c1649 100755 --- a/main/install/update-configuration.inc.php +++ b/main/install/update-configuration.inc.php @@ -1,11 +1,11 @@ ') !== false) { $ignore = true; } @@ -55,7 +47,7 @@ if (defined('SYSTEM_INSTALLATION')) { fwrite($fh, $line); } } - + if (!$found_version) { fwrite($fh, '$_configuration[\'system_version\'] = \'' . $new_version . '\';' . "\r\n"); } @@ -67,9 +59,9 @@ if (defined('SYSTEM_INSTALLATION')) { } if (!$found_software_url) { fwrite($fh, '$_configuration[\'software_url\'] = \'' . $software_url . '\';' . "\r\n"); - } + } fwrite($fh, '?>'); fclose($fh); } else { echo 'You are not allowed here !'. __FILE__; -} \ No newline at end of file +} diff --git a/main/install/update-db-1.6.x-1.8.0.inc.php b/main/install/update-db-1.6.x-1.8.0.inc.php deleted file mode 100755 index ae03098edf..0000000000 --- a/main/install/update-db-1.6.x-1.8.0.inc.php +++ /dev/null @@ -1,538 +0,0 @@ -' . get_lang('Error') . ' ! Dokeos ' . implode('|', $updateFromVersion) . ' ' . get_lang('HasNotBeenFound') . '.

    - ' . get_lang('PleasGoBackToStep1') . '. -

    -
    '; - exit(); - } - - $_configuration['db_glue'] = get_config_param('dbGlu'); - - if ($singleDbForm) { - $_configuration['table_prefix'] = get_config_param('courseTablePrefix'); - $_configuration['main_database'] = get_config_param('mainDbName'); - $_configuration['db_prefix'] = get_config_param('dbNamePrefix'); - } - - $dbScormForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbScormForm); - - if (!empty($dbPrefixForm) && strpos($dbScormForm, $dbPrefixForm) !== 0) { - $dbScormForm = $dbPrefixForm . $dbScormForm; - } - - if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) { - $dbScormForm = $dbPrefixForm . 'scorm'; - } - - /* Normal upgrade procedure: start by updating main, statistic, user databases */ - - // If this script has been included by index.php, not update_courses.php, so - // that we want to change the main databases as well... - $only_test = false; - $log = 0; - - if (defined('SYSTEM_INSTALLATION')) { - - if ($singleDbForm) { - if (empty($dbStatsForm)) - $dbStatsForm = $dbNameForm; - if (empty($dbScormForm)) - $dbScormForm = $dbNameForm; - if (empty($dbUserForm)) - $dbUserForm = $dbNameForm; - } - /** - * Update the databases "pre" migration - */ - include_once '../lang/english/trad4all.inc.php'; - - if ($languageForm != 'english') { - // languageForm has been escaped in index.php - include_once '../lang/' . $languageForm . '/trad4all.inc.php'; - } - - //get the main queries list (m_q_list) - $m_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'main'); - if (count($m_q_list) > 0) { - // Now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - error_log('Database name ' . $dbNameForm . ' is too long, skipping', 0); - } elseif (!in_array($dbNameForm, $dblist)) { - error_log('Database ' . $dbNameForm . ' was not found, skipping', 0); - } else { - Database::select_db($dbNameForm); - foreach ($m_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbNameForm,$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In $dbNameForm, executed: $query", 0); - } - } - } - } - } - - // Get the stats queries list (s_q_list) - $s_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'stats'); - if (count($s_q_list) > 0) { - // Now use the $s_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbStatsForm) > 40) { - error_log('Database name ' . $dbStatsForm . ' is too long, skipping', 0); - } elseif (!in_array($dbStatsForm, $dblist)) { - error_log('Database ' . $dbStatsForm . ' was not found, skipping', 0); - } else { - Database::select_db($dbStatsForm); - foreach ($s_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbStatsForm,$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In $dbStatsForm, executed: $query", 0); - } - } - } - } - } - - // Get the user queries list (u_q_list) - $u_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'user'); - if (count($u_q_list) > 0) { - // Now use the $u_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbUserForm) > 40) { - error_log('Database name ' . $dbUserForm . ' is too long, skipping', 0); - } elseif (!in_array($dbUserForm, $dblist)) { - error_log('Database ' . $dbUserForm . ' was not found, skipping', 0); - } else { - Database::select_db($dbUserForm); - foreach ($u_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbUserForm,$query)", 0); - error_log("In $dbUserForm, executed: $query", 0); - } else { - $res = Database::query($query); - } - } - } - } - // The SCORM database doesn't need a change in the pre-migrate part - ignore. - } - - $prefix = ''; - if ($singleDbForm) { - $prefix = $_configuration['table_prefix']; - } - - // Get the courses databases queries list (c_q_list) - $c_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'course'); - if (count($c_q_list) > 0) { - - // Get the courses list - if (strlen($dbNameForm) > 40) { - error_log('Database name ' . $dbNameForm . ' is too long, skipping', 0); - } elseif (!in_array($dbNameForm, $dblist)) { - error_log('Database ' . $dbNameForm . ' was not found, skipping', 0); - } else { - Database::select_db($dbNameForm); - $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); - if ($res === false) { - die('Error while querying the courses list in update_db-1.6.x-1.8.0.inc.php'); - } - if (Database::num_rows($res) > 0) { - $i = 0; - $list = array(); - while ($row = Database::fetch_array($res)) { - $list[] = $row; - $i++; - } - foreach ($list as $row_course) { - // Now use the $c_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (!$singleDbForm) { // otherwise just use the main one - Database::select_db($row_course['db_name']); - } - - foreach ($c_q_list as $query) { - if ($singleDbForm) { - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query); - } - - if ($only_test) { - error_log("Database::query(" . $row_course['db_name'] . ",$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In " . $row_course['db_name'] . ", executed: $query", 0); - } - } - } - - // Prepare reusable users list to avoid repetition of the SQL query, but only select - // users from the current course to avoid blowing the memory limit - $users_list = array(); - $sql_uc = "SELECT u.user_id as ui, u.firstname as fn, u.lastname as ln " . - " FROM $dbNameForm.user u, $dbNameForm.course_rel_user cu " . - " WHERE cu.course_code = '" . $row_course['code'] . "' " . - " AND u.user_id = cu.user_id"; - $res_uc = Database::query($sql_uc); - while ($user_row = Database::fetch_array($res_uc)) { - $users_list[$user_row['fn'] . ' ' . $user_row['ln']] = $user_row['ui']; - } - - // Update course manually - // Update group_category.forum_state ? - // Update group_info.tutor_id (put it in group_tutor table?) ? - // Update group_info.forum_state, forum_id ? - // Update forum tables (migrate from bb_ tables to forum_ tables) - // Migrate categories - $prefix_course = $prefix; - if ($singleDbForm) { - $prefix_course = $prefix . $row_course['db_name'] . "_"; - } - - $sql_orig = "SELECT * FROM " . $prefix_course . "bb_categories"; - $res_orig = Database::query($sql_orig); - $order = 1; - while ($row = Database::fetch_array($res_orig)) { - $myorder = (empty($row['cat_order']) ? $order : $row['cat_order']); - $sql = "INSERT INTO " . $prefix_course . "forum_category " . - "(cat_id,cat_title,cat_comment,cat_order,locked) VALUES " . - "('" . $row['cat_id'] . "','" . Database::escape_string($row['cat_title']) . "','','" . $myorder . "',0)"; - $res = Database::query($sql); - $lastcatid = Database::insert_id(); - //error_log($sql,0); - $order++; - // Add item_property - forum categories were not put into item_properties before - $sql = "INSERT INTO " . $prefix_course . "item_property (tool,insert_user_id,ref,lastedit_type,lastedit_user_id,visibility) " . - "VALUES ('forum_category','1','$lastcatid','ForumCategoryAdded','1','1')"; - $res = Database::query($sql); - //error_log($sql,0); - } - - $sql_orig = "SELECT * FROM " . $prefix_course . "bb_forums ORDER BY forum_last_post_id desc"; - $res_orig = Database::query($sql_orig); - $order = 1; - while ($row = Database::fetch_array($res_orig)) { - $sql = "INSERT INTO " . $prefix_course . "forum_forum " . - "(forum_id,forum_category,allow_edit,forum_comment," . - "forum_title," . - "forum_last_post, forum_threads," . - "locked, forum_posts, " . - "allow_new_threads, forum_order) VALUES " . - "('" . $row['forum_id'] . "','" . $row['cat_id'] . "',1,'" . Database::escape_string($row['forum_desc']) . "'," . - "'" . Database::escape_string($row['forum_name']) . "'," . - "'" . $row['forum_last_post_id'] . "','" . $row['forum_topics'] . "'," . - "0,'" . $row['forum_posts'] . "'," . - "1,$order)"; - //error_log($sql,0); - $res = Database::query($sql); - $lastforumid = Database::insert_id(); - $order++; - - // Add item_property - forums were not put into item_properties before - $sql = "INSERT INTO " . $prefix_course . "item_property (tool,insert_user_id,ref,lastedit_type,lastedit_user_id,visibility) " . - "VALUES ('forum','1','$lastforumid','ForumAdded','1','1')"; - $res = Database::query($sql); - //error_log($sql,0); - } - - $sql_orig = "SELECT * FROM " . $prefix_course . "bb_topics"; - $res_orig = Database::query($sql_orig); - while ($row = Database::fetch_array($res_orig)) { - $name = $row['prenom'] . ' ' . $row['nom']; - // Check whether user id is reusable - if ($row['topic_poster'] <= 1) { - if (isset($users_list[$name])) { - $poster_id = $users_list[$name]; - } else { - $poster_id = $row['topic_poster']; - } - } - // Convert time from varchar to datetime - $time = $row['topic_time']; - $name = Database::escape_string($name); - $sql = "INSERT INTO " . $prefix_course . "forum_thread " . - "(thread_id,forum_id,thread_poster_id," . - "locked,thread_replies,thread_sticky,thread_title," . - "thread_poster_name, thread_date, thread_last_post," . - "thread_views) VALUES " . - "('" . $row['topic_id'] . "','" . $row['forum_id'] . "','" . $poster_id . "'," . - "0,'" . $row['topic_replies'] . "',0,'" . Database::escape_string($row['topic_title']) . "'," . - "'$name','$time','" . $row['topic_last_post_id'] . "'," . - "'" . $row['topic_views'] . "')"; - //error_log($sql,0); - $res = Database::query($sql); - $lastthreadid = Database::insert_id(); - - // Add item_property - forum threads were not put into item_properties before - $sql = "INSERT INTO " . $prefix_course . "item_property (tool,insert_user_id,ref,lastedit_type,lastedit_user_id,visibility) " . - "VALUES ('forum_thread','1','$lastthreadid','ForumThreadAdded','1','1')"; - $res = Database::query($sql); - //error_log($sql,0); - } - - $sql_orig = "SELECT * FROM " . $prefix_course . "bb_posts bp, " . $prefix_course . "bb_posts_text bpt WHERE bp.post_id = bpt.post_id"; - $res_orig = Database::query($sql_orig); - while ($row = Database::fetch_array($res_orig)) { - $name = $row['prenom'] . ' ' . $row['nom']; - // Check whether user id is reusable - if ($row['poster_id'] <= 0) { - if (isset($users_list[$name])) { - $poster_id = $users_list[$name]; - } else { - $poster_id = $row['poster_id']; - } - } - // Convert time from varchar to datetime - $time = $row['post_time']; - $name = Database::escape_string($name); - $sql = "INSERT INTO " . $prefix_course . "forum_post " . - "(post_id,forum_id,thread_id," . - "poster_id,post_parent_id,visible, " . - "post_title,poster_name, post_text, " . - "post_date, post_notification) VALUES " . - "('" . $row['post_id'] . "','" . $row['forum_id'] . "','" . $row['topic_id'] . "'," . - "'" . $poster_id . "','" . $row['parent_id'] . "',1," . - "'" . Database::escape_string($row['post_title']) . "','$name', '" . Database::escape_string($row['post_text']) . "'," . - "'$time',0)"; - //error_log($sql,0); - $res = Database::query($sql); - $lastpostid = Database::insert_id(); - - // Add item_property - forum threads were not put into item_properties before - $sql = "INSERT INTO " . $prefix_course . "item_property(tool,insert_user_id,ref,lastedit_type,lastedit_user_id,visibility) " . - "VALUES ('forum_post','1','$lastpostid','ForumPostAdded','1','1')"; - $res = Database::query($sql); - //error_log($sql,0); - } - unset($users_list); - - $sql_orig = "SELECT id, tutor_id FROM " . $prefix_course . "group_info"; - $res_orig = Database::query($sql_orig); - $order = 1; - while ($row = Database::fetch_array($res_orig)) { - $sql = "INSERT INTO " . $prefix_course . "group_rel_tutor " . - "(user_id,group_id) VALUES " . - "('" . $row['tutor_id'] . "','" . $row['id'] . "')"; - $res = Database::query($sql); - } - } - } - } - } - - // Load the old-scorm to new-scorm migration script - if (!$only_test) { - include('update-db-scorm-1.6.x-1.8.0.inc.php'); - } - if (defined('SYSTEM_INSTALLATION')) { - if ($singleDbForm) { - if (empty($dbStatsForm)) - $dbStatsForm = $dbNameForm; - if (empty($dbScormForm)) - $dbScormForm = $dbNameForm; - if (empty($dbUserForm)) - $dbUserForm = $dbNameForm; - } - // Deal with migrate-db-1.6.x-1.8.0-post.sql - // Get the main queries list (m_q_list) - $m_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'main'); - if (count($m_q_list) > 0) { - // Now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - error_log('Database name ' . $dbNameForm . ' is too long, skipping', 0); - } elseif (!in_array($dbNameForm, $dblist)) { - error_log('Database ' . $dbNameForm . ' was not found, skipping', 0); - } else { - Database::select_db($dbNameForm); - foreach ($m_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbNameForm,$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In $dbNameForm, executed: $query", 0); - } - } - } - } - } - - // Get the stats queries list (s_q_list) - $s_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'stats'); - if (count($s_q_list) > 0) { - // Now use the $s_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbStatsForm) > 40) { - error_log('Database name ' . $dbStatsForm . ' is too long, skipping', 0); - } elseif (!in_array($dbNameForm, $dblist)) { - error_log('Database ' . $dbNameForm . ' was not found, skipping', 0); - } else { - Database::select_db($dbStatsForm); - foreach ($s_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbStatsForm,$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In $dbStatsForm, executed: $query", 0); - } - } - } - } - } - - // Get the user queries list (u_q_list) - $u_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'user'); - if (count($u_q_list) > 0) { - //now use the $u_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbUserForm) > 40) { - error_log('Database name ' . $dbUserForm . ' is too long, skipping', 0); - } elseif (!in_array($dbUserForm, $dblist)) { - error_log('Database ' . $dbUserForm . ' was not found, skipping', 0); - } else { - Database::select_db($dbUserForm); - foreach ($u_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbUserForm,$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In $dbUserForm, executed: $query", 0); - } - } - } - } - } - // The SCORM database should need a drop in the post-migrate part. However, we will keep these tables a bit more, just in case... - } - - // Get the courses databases queries list (c_q_list) - $c_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'course'); - if (count($c_q_list) > 0) { - // Get the courses list - if (strlen($dbNameForm) > 40) { - error_log('Database name ' . $dbNameForm . ' is too long, skipping', 0); - } elseif (!in_array($dbNameForm, $dblist)) { - error_log('Database ' . $dbNameForm . ' was not found, skipping', 0); - } else { - Database::select_db($dbNameForm); - $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); - if ($res === false) { - die('Error while querying the courses list in update_db-1.6.x-1.8.0.inc.php'); - } - if (Database::num_rows($res) > 0) { - $i = 0; - while ($row = Database::fetch_array($res)) { - $list[] = $row; - $i++; - } - foreach ($list as $row) { - // Now use the $c_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - $prefix_course = $prefix; - if ($singleDbForm) { - $prefix_course = $prefix . $row['db_name'] . "_"; - } else { - Database::select_db($row['db_name']); - } - - foreach ($c_q_list as $query) { - if ($singleDbForm) { //otherwise just use the main one - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix$2$3", $query); - } - if ($only_test) { - error_log("Database::query(" . $row['db_name'] . ",$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In " . $row['db_name'] . ", executed: $query", 0); - } - } - } - } - } - } - } - - // Upgrade user categories sort - $table_user_categories = $dbUserForm . '.user_course_category'; - - $sql = 'SELECT * FROM ' . $table_user_categories . ' ORDER BY user_id, title'; - $rs = Database::query($sql); - - $sort = 0; - $old_user = 0; - while ($cat = Database::fetch_array($rs)) { - if ($old_user != $cat['user_id']) { - $old_user = $cat['user_id']; - $sort = 0; - } - $sort++; - $sql = 'UPDATE ' . $table_user_categories . ' SET - sort = ' . intval($sort) . ' - WHERE id=' . intval($cat['id']); - Database::query($sql); - } -} else { - - echo 'You are not allowed here !' . __FILE__; -} diff --git a/main/install/update-db-1.8.0-1.8.2.inc.php b/main/install/update-db-1.8.0-1.8.2.inc.php deleted file mode 100755 index 99c9ec6faf..0000000000 --- a/main/install/update-db-1.8.0-1.8.2.inc.php +++ /dev/null @@ -1,212 +0,0 @@ -' . get_lang('Error') . ' ! Dokeos ' . implode('|', $updateFromVersion) . ' ' . get_lang('HasNotBeenFound') . '.

    - ' . get_lang('PleasGoBackToStep1') . '. -

    - '; - exit(); - } - - $_configuration['db_glue'] = get_config_param('dbGlu'); - - if ($singleDbForm) { - $_configuration['table_prefix'] = get_config_param('courseTablePrefix'); - $_configuration['main_database'] = get_config_param('mainDbName'); - $_configuration['db_prefix'] = get_config_param('dbNamePrefix'); - } - - $dbScormForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbScormForm); - - if (!empty($dbPrefixForm) && strpos($dbScormForm, $dbPrefixForm) !== 0) { - $dbScormForm = $dbPrefixForm . $dbScormForm; - } - - if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) { - $dbScormForm = $dbPrefixForm . 'scorm'; - } - - /* Normal upgrade procedure: start by updating main, statistic, user databases */ - - // If this script has been included by index.php, not update_courses.php, so - // that we want to change the main databases as well... - $only_test = false; - $log = 0; - if (defined('SYSTEM_INSTALLATION')) { - if ($singleDbForm) { - $dbStatsForm = $dbNameForm; - $dbScormForm = $dbNameForm; - $dbUserForm = $dbNameForm; - } - /** - * Update the databases "pre" migration - */ - include_once '../lang/english/trad4all.inc.php'; - - if ($languageForm != 'english') { - //languageForm has been escaped in index.php - include_once '../lang/' . $languageForm . '/trad4all.inc.php'; - } - - // Get the main queries list (m_q_list) - $m_q_list = get_sql_file_contents('migrate-db-1.8.0-1.8.2-pre.sql', 'main'); - if (count($m_q_list) > 0) { - //now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - error_log('Database name ' . $dbNameForm . ' is too long, skipping', 0); - } elseif (!in_array($dbNameForm, $dblist)) { - error_log('Database ' . $dbNameForm . ' was not found, skipping', 0); - } else { - Database::select_db($dbNameForm); - foreach ($m_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbNameForm,$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In $dbNameForm, executed: $query", 0); - } - } - } - } - } - - // Get the stats queries list (s_q_list) - $s_q_list = get_sql_file_contents('migrate-db-1.8.0-1.8.2-pre.sql', 'stats'); - - if (count($s_q_list) > 0) { - // Now use the $s_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbStatsForm) > 40) { - error_log('Database name ' . $dbStatsForm . ' is too long, skipping', 0); - } elseif (!in_array($dbStatsForm, $dblist)) { - error_log('Database ' . $dbStatsForm . ' was not found, skipping', 0); - } else { - Database::select_db($dbStatsForm); - foreach ($s_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbStatsForm,$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In $dbStatsForm, executed: $query", 0); - } - } - } - } - } - // Get the user queries list (u_q_list) - $u_q_list = get_sql_file_contents('migrate-db-1.8.0-1.8.2-pre.sql', 'user'); - if (count($u_q_list) > 0) { - //now use the $u_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbUserForm) > 40) { - error_log('Database name ' . $dbUserForm . ' is too long, skipping', 0); - } elseif (!in_array($dbUserForm, $dblist)) { - error_log('Database ' . $dbUserForm . ' was not found, skipping', 0); - } else { - Database::select_db($dbUserForm); - foreach ($u_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbUserForm,$query)", 0); - error_log("In $dbUserForm, executed: $query", 0); - } else { - $res = Database::query($query); - } - } - } - } - // The SCORM database doesn't need a change in the pre-migrate part - ignore - } - - $prefix = ''; - if ($singleDbForm) { - $prefix = $_configuration['table_prefix']; - } - // Get the courses databases queries list (c_q_list) - $c_q_list = get_sql_file_contents('migrate-db-1.8.0-1.8.2-pre.sql', 'course'); - if (count($c_q_list) > 0) { - // Get the courses list - if (strlen($dbNameForm) > 40) { - error_log('Database name ' . $dbNameForm . ' is too long, skipping', 0); - } elseif (!in_array($dbNameForm, $dblist)) { - error_log('Database ' . $dbNameForm . ' was not found, skipping', 0); - } else { - Database::select_db($dbNameForm); - $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); - if ($res === false) { - die('Error while querying the courses list in update_db-1.8.0-1.8.2.inc.php'); - } - if (Database::num_rows($res) > 0) { - $i = 0; - $list = array(); - while ($row = Database::fetch_array($res)) { - $list[] = $row; - $i++; - } - foreach ($list as $row_course) { - // Now use the $c_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (!$singleDbForm) { // otherwise just use the main one - Database::select_db($row_course['db_name']); - } - Log::notice('Course db ' . $row_course['db_name']); - - foreach ($c_q_list as $query) { - if ($singleDbForm) { - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query); - } - - if ($only_test) { - error_log("Database::query(" . $row_course['db_name'] . ",$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In " . $row_course['db_name'] . ", executed: $query", 0); - } - } - } - } - } - } - } -} else { - - echo 'You are not allowed here !' . __FILE__; -} diff --git a/main/install/update-db-1.8.2-1.8.3.inc.php b/main/install/update-db-1.8.2-1.8.3.inc.php deleted file mode 100755 index 126698e781..0000000000 --- a/main/install/update-db-1.8.2-1.8.3.inc.php +++ /dev/null @@ -1,212 +0,0 @@ -'.get_lang('Error').' ! Dokeos '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').'.

    - '.get_lang('PleasGoBackToStep1').'. -

    - '; - exit (); - } - - $_configuration['db_glue'] = get_config_param('dbGlu'); - - if ($singleDbForm) { - $_configuration['table_prefix'] = get_config_param('courseTablePrefix'); - $_configuration['main_database'] = get_config_param('mainDbName'); - $_configuration['db_prefix'] = get_config_param('dbNamePrefix'); - } - - $dbScormForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbScormForm); - - if (!empty($dbPrefixForm) && strpos($dbScormForm, $dbPrefixForm) !== 0) { - $dbScormForm = $dbPrefixForm.$dbScormForm; - } - - if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) { - $dbScormForm = $dbPrefixForm.'scorm'; - } - - /* Normal upgrade procedure: start by updating main, statistic, user databases */ - - // If this script has been included by index.php, not update_courses.php, so - // that we want to change the main databases as well... - $only_test = false; - $log = 0; - if (defined('SYSTEM_INSTALLATION')) { - - if ($singleDbForm) { - $dbStatsForm = $dbNameForm; - $dbScormForm = $dbNameForm; - $dbUserForm = $dbNameForm; - } - /** - * Update the databases "pre" migration - */ - include_once '../lang/english/trad4all.inc.php'; - - if ($languageForm != 'english') { - // languageForm has been escaped in index.php - include_once '../lang/'.$languageForm.'/trad4all.inc.php'; - } - - // get the main queries list (m_q_list) - $m_q_list = get_sql_file_contents('migrate-db-1.8.2-1.8.3-pre.sql', 'main'); - if (count($m_q_list) > 0) { - // Now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - error_log('Database name '.$dbNameForm.' is too long, skipping', 0); - } elseif (!in_array($dbNameForm,$dblist)) { - error_log('Database '.$dbNameForm.' was not found, skipping', 0); - } else { - Database::select_db($dbNameForm); - foreach ($m_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbNameForm,$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In $dbNameForm, executed: $query", 0); - } - } - } - } - } - - // Get the stats queries list (s_q_list) - $s_q_list = get_sql_file_contents('migrate-db-1.8.2-1.8.3-pre.sql', 'stats'); - - if (count($s_q_list) > 0) { - // Now use the $s_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbStatsForm) > 40) { - error_log('Database name '.$dbStatsForm.' is too long, skipping', 0); - } elseif (!in_array($dbStatsForm, $dblist)) { - error_log('Database '.$dbStatsForm.' was not found, skipping', 0); - } else { - Database::select_db($dbStatsForm); - foreach ($s_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbStatsForm,$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In $dbStatsForm, executed: $query", 0); - } - } - } - } - } - // Get the user queries list (u_q_list) - $u_q_list = get_sql_file_contents('migrate-db-1.8.2-1.8.3-pre.sql', 'user'); - if (count($u_q_list) > 0) { - // Now use the $u_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbUserForm) > 40) { - error_log('Database name '.$dbUserForm.' is too long, skipping', 0); - } elseif (!in_array($dbUserForm, $dblist)) { - error_log('Database '.$dbUserForm.' was not found, skipping', 0); - } else { - Database::select_db($dbUserForm); - foreach ($u_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbUserForm, $query)", 0); - error_log("In $dbUserForm, executed: $query", 0); - } else { - $res = Database::query($query); - } - } - } - } - // The SCORM database doesn't need a change in the pre-migrate part - ignore - } - - $prefix = ''; - if ($singleDbForm) { - $prefix = $_configuration['table_prefix']; - } - // Get the courses databases queries list (c_q_list) - $c_q_list = get_sql_file_contents('migrate-db-1.8.2-1.8.3-pre.sql', 'course'); - if (count($c_q_list) > 0) { - // Get the courses list - if (strlen($dbNameForm) > 40) { - error_log('Database name '.$dbNameForm.' is too long, skipping', 0); - } elseif (!in_array($dbNameForm, $dblist)) { - error_log('Database '.$dbNameForm.' was not found, skipping', 0); - } else { - Database::select_db($dbNameForm); - $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); - if ($res === false) { die('Error while querying the courses list in update_db-1.8.2-1.8.3.inc.php'); } - if (Database::num_rows($res) > 0) { - $i = 0; - $list = array(); - while ($row = Database::fetch_array($res)) { - $list[] = $row; - $i++; - } - foreach ($list as $row_course) { - // Now use the $c_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (!$singleDbForm) { //otherwise just use the main one - Database::select_db($row_course['db_name']); - } - Log::notice('Course db ' . $row_course['db_name']); - - foreach ($c_q_list as $query) { - if ($singleDbForm) { //otherwise just use the main one - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query); - } - - if ($only_test) { - error_log("Database::query(".$row_course['db_name'].",$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In ".$row_course['db_name'].", executed: $query", 0); - } - } - } - } - } - } - } - -} else { - - echo 'You are not allowed here !' . __FILE__; - -} diff --git a/main/install/update-db-1.8.3-1.8.4.inc.php b/main/install/update-db-1.8.3-1.8.4.inc.php deleted file mode 100755 index b180aac379..0000000000 --- a/main/install/update-db-1.8.3-1.8.4.inc.php +++ /dev/null @@ -1,265 +0,0 @@ -'.get_lang('Error').' ! Dokeos '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').'.

    - '.get_lang('PleasGoBackToStep1').'. -

    - '; - exit (); - } - - $_configuration['db_glue'] = get_config_param('dbGlu'); - - if ($singleDbForm) { - $_configuration['table_prefix'] = get_config_param('courseTablePrefix'); - $_configuration['main_database'] = get_config_param('mainDbName'); - $_configuration['db_prefix'] = get_config_param('dbNamePrefix'); - } - - $dbScormForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbScormForm); - - if (!empty($dbPrefixForm) && strpos($dbScormForm, $dbPrefixForm) !== 0) { - $dbScormForm = $dbPrefixForm.$dbScormForm; - } - - if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) { - $dbScormForm = $dbPrefixForm.'scorm'; - } - - /* Normal upgrade procedure: start by updating main, statistic, user databases */ - - // If this script has been included by index.php, not update_courses.php, so - // that we want to change the main databases as well... - $only_test = false; - $log = 0; - if (defined('SYSTEM_INSTALLATION')) { - - if ($singleDbForm) { - $dbStatsForm = $dbNameForm; - $dbScormForm = $dbNameForm; - $dbUserForm = $dbNameForm; - } - /** - * Update the databases "pre" migration - */ - include_once '../lang/english/trad4all.inc.php'; - - if ($languageForm != 'english') { - // languageForm has been escaped in index.php - include_once '../lang/'.$languageForm.'/trad4all.inc.php'; - } - - //get the main queries list (m_q_list) - $m_q_list = get_sql_file_contents('migrate-db-1.8.3-1.8.4-pre.sql', 'main'); - if (count($m_q_list) > 0) { - // Now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - error_log('Database name '.$dbNameForm.' is too long, skipping', 0); - } elseif (!in_array($dbNameForm, $dblist)) { - error_log('Database '.$dbNameForm.' was not found, skipping', 0); - } else { - Database::select_db($dbNameForm); - foreach ($m_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbNameForm, $query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In $dbNameForm, executed: $query", 0); - } - } - } - } - } - - // Get the stats queries list (s_q_list) - $s_q_list = get_sql_file_contents('migrate-db-1.8.3-1.8.4-pre.sql', 'stats'); - - if (count($s_q_list) > 0) { - // Now use the $s_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbStatsForm) > 40) { - error_log('Database name '.$dbStatsForm.' is too long, skipping', 0); - } elseif (!in_array($dbStatsForm, $dblist)) { - error_log('Database '.$dbStatsForm.' was not found, skipping', 0); - } else { - Database::select_db($dbStatsForm); - foreach ($s_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbStatsForm,$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In $dbStatsForm, executed: $query", 0); - } - } - } - } - } - // Get the user queries list (u_q_list) - $u_q_list = get_sql_file_contents('migrate-db-1.8.3-1.8.4-pre.sql', 'user'); - if (count($u_q_list) > 0) { - // Now use the $u_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbUserForm) > 40) { - error_log('Database name '.$dbUserForm.' is too long, skipping', 0); - } elseif (!in_array($dbUserForm, $dblist)){ - error_log('Database '.$dbUserForm.' was not found, skipping', 0); - } else { - Database::select_db($dbUserForm); - foreach ($u_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbUserForm,$query)", 0); - error_log("In $dbUserForm, executed: $query", 0); - } else { - $res = Database::query($query); - } - } - } - } - // The SCORM database doesn't need a change in the pre-migrate part - ignore - } - - $prefix = ''; - if ($singleDbForm) { - $prefix = $_configuration['table_prefix']; - } - // Get the courses databases queries list (c_q_list) - $c_q_list = get_sql_file_contents('migrate-db-1.8.3-1.8.4-pre.sql', 'course'); - if (count($c_q_list) > 0) { - // Get the courses list - if (strlen($dbNameForm) > 40) { - error_log('Database name '.$dbNameForm.' is too long, skipping', 0); - } elseif (!in_array($dbNameForm, $dblist)) { - error_log('Database '.$dbNameForm.' was not found, skipping', 0); - } else { - Database::select_db($dbNameForm); - $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); - if ($res === false) { die('Error while querying the courses list in update_db-1.8.3-1.8.4.inc.php'); } - if (Database::num_rows($res) > 0) { - $i = 0; - $list = array(); - while ($row = Database::fetch_array($res)) { - $list[] = $row; - $i++; - } - foreach ($list as $row_course) { - // Now use the $c_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (!$singleDbForm) { //otherwise just use the main one - Database::select_db($row_course['db_name']); - } - Log::notice('Course db ' . $row_course['db_name']); - - foreach ($c_q_list as $query) { - if ($singleDbForm) { - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query); - } - - if ($only_test) { - error_log("Database::query(".$row_course['db_name'].",$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In ".$row_course['db_name'].", executed: $query", 0); - } - } - } - // Ensure each learnpath is present in the item_property table - $prefix_course = ''; - if ($singleDbForm) { - $prefix_course = $prefix.$row_course['db_name']."_"; - } - - $sql_ip = "SELECT * FROM ".$prefix_course."item_property WHERE tool='learnpath'"; - $res_ip = Database::query($sql_ip); - $paths = array(); - while ($row_ip = Database::fetch_array($res_ip)) { - $paths[] = $row_ip['ref']; - } - $sql_lp = "SELECT * FROM ".$prefix_course."lp"; - $res_lp = Database::query($sql_lp); - $tbl_tool = $prefix_course."tool"; - while ($row_lp = Database::fetch_array($res_lp)) { - $time = date("Y-m-d H:i:s", time()); - $vis = 'v'; - $input = stripslashes($row_lp['name']); - $input = str_replace("'", "''", $input); - $input = str_replace('"', "''", $input); - $mylink = 'newscorm/lp_controller.php?action=view&lp_id='.$row_lp['id']; - $sql2 = "SELECT * FROM $tbl_tool where (name='$input' and image='scormbuilder.gif' and link LIKE '$mylink%')"; - - if (in_array($row_lp['id'], $paths)) { - // The path is already in item_property, check the visibility is the - // same as the homepage tool's - $res2 = Database::query($sql2); - if (Database::num_rows($res2) > 0) { - $row2 = Database::fetch_array($res2); - $vis = $row2['visibility']; - } - $visi = array('v' => 1, 'i' => 0); - if ($visi[$vis] != $row_ip['visibility']) { - $sql_upd = "UPDATE ".$prefix_course."item_propery SET visibility=".$visi[$vis]." WHERE tool='learnpath' AND ref='".$row_lp['id']."'"; - $res_upd = Database::query($sql_upd); - } - } else { - // The path is not in item_property, insert it - $res2 = Database::query($sql2); - if (Database::num_rows($res2) > 0) { - $row2 = Database::fetch_array($res2); - $vis = $row2['visibility']; - } - $visi = array('v' => 1, 'i' => 0); - - $sql_ins = "INSERT INTO ".$prefix_course."item_property " . - "(tool,ref,insert_date,last_edit_date,insert_user_id,lastedit_type,lastedit_user_id,visibility)" . - "VALUES" . - "('learnpath',".$row_lp['id'].",'$time','$time',1,'learnpathAdded',1,".$visi[$vis].")"; - $res_ins = Database::query($sql_ins); - } - } - } - } - } - } - -} else { - - echo 'You are not allowed here !' . __FILE__; - -} diff --git a/main/install/update-db-1.8.4-1.8.5.inc.php b/main/install/update-db-1.8.4-1.8.5.inc.php deleted file mode 100755 index e95b7778af..0000000000 --- a/main/install/update-db-1.8.4-1.8.5.inc.php +++ /dev/null @@ -1,283 +0,0 @@ -'.get_lang('Error').' ! Dokeos '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').'.

    - '.get_lang('PleasGoBackToStep1').'. -

    - '; - exit (); - } - - $_configuration['db_glue'] = get_config_param('dbGlu'); - - if ($singleDbForm) { - $_configuration['table_prefix'] = get_config_param('courseTablePrefix'); - $_configuration['main_database'] = get_config_param('mainDbName'); - $_configuration['db_prefix'] = get_config_param('dbNamePrefix'); - } - - $dbScormForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbScormForm); - - if (!empty($dbPrefixForm) && strpos($dbScormForm, $dbPrefixForm) !== 0) { - $dbScormForm = $dbPrefixForm.$dbScormForm; - } - - if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) { - $dbScormForm = $dbPrefixForm.'scorm'; - } - - /* Normal upgrade procedure: start by updating main, statistic, user databases */ - - // If this script has been included by index.php, not update_courses.php, so - // that we want to change the main databases as well... - $only_test = false; - $log = 0; - if (defined('SYSTEM_INSTALLATION')) { - - if ($singleDbForm) { - $dbStatsForm = $dbNameForm; - $dbScormForm = $dbNameForm; - $dbUserForm = $dbNameForm; - } - /** - * Update the databases "pre" migration - */ - include_once '../lang/english/trad4all.inc.php'; - - if ($languageForm != 'english') { - // languageForm has been escaped in index.php - include_once '../lang/'.$languageForm.'/trad4all.inc.php'; - } - - //get the main queries list (m_q_list) - $m_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'main'); - if (count($m_q_list) > 0) { - // Now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - error_log('Database name '.$dbNameForm.' is too long, skipping', 0); - } elseif (!in_array($dbNameForm, $dblist)) { - error_log('Database '.$dbNameForm.' was not found, skipping', 0); - } else { - Database::select_db($dbNameForm); - foreach ($m_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbNameForm,$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In $dbNameForm, executed: $query", 0); - } - } - } - } - } - - // Get the stats queries list (s_q_list) - $s_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'stats'); - - if (count($s_q_list) > 0) { - // Now use the $s_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbStatsForm) > 40) { - error_log('Database name '.$dbStatsForm.' is too long, skipping', 0); - } elseif (!in_array($dbStatsForm, $dblist)) { - error_log('Database '.$dbStatsForm.' was not found, skipping', 0); - } else { - Database::select_db($dbStatsForm); - foreach ($s_q_list as $query) { - if ($only_test) { - error_log("Database::query($dbStatsForm,$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In $dbStatsForm, executed: $query", 0); - } - } - } - } - } - // Get the user queries list (u_q_list) - $u_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'user'); - if (count($u_q_list) > 0) { - // Now use the $u_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbUserForm) > 40) { - error_log('Database name '.$dbUserForm.' is too long, skipping', 0); - } elseif (!in_array($dbUserForm, $dblist)) { - error_log('Database '.$dbUserForm.' was not found, skipping', 0); - } else { - Database::select_db($dbUserForm); - foreach ($u_q_list as $query){ - if ($only_test) { - error_log("Database::query($dbUserForm,$query)", 0); - error_log("In $dbUserForm, executed: $query", 0); - } else { - $res = Database::query($query); - } - } - } - } - // The SCORM database doesn't need a change in the pre-migrate part - ignore - } - - $prefix = ''; - if ($singleDbForm) { - $prefix = get_config_param ('table_prefix'); - } - - // Get the courses databases queries list (c_q_list) - $c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'course'); - - if (count($c_q_list) > 0) { - //get the courses list - if (strlen($dbNameForm) > 40) { - error_log('Database name '.$dbNameForm.' is too long, skipping', 0); - } elseif (!in_array($dbNameForm, $dblist)) { - error_log('Database '.$dbNameForm.' was not found, skipping', 0); - } else { - Database::select_db($dbNameForm); - $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code"); - - if ($res === false) { die('Error while querying the courses list in update_db-1.8.4-1.8.5.inc.php'); } - - if (Database::num_rows($res) > 0) { - $i = 0; - $list = array(); - while($row = Database::fetch_array($res)) { - $list[] = $row; - $i++; - } - foreach ($list as $row_course) { - // Now use the $c_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (!$singleDbForm) { //otherwise just use the main one - Database::select_db($row_course['db_name']); - } - Log::notice('Course db ' . $row_course['db_name']); - - foreach ($c_q_list as $query) { - if ($singleDbForm) { - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query); - } - - if ($only_test) { - error_log("Database::query(".$row_course['db_name'].",$query)", 0); - } else { - $res = Database::query($query); - if ($log) { - error_log("In ".$row_course['db_name'].", executed: $query", 0); - } - } - } - - $mytable = $row_course['db_name'].".lp_item"; - - if ($singleDbForm) { - $mytable = "$prefix{$row_course['db_name']}_lp_item"; - } - - $mysql = "SELECT * FROM $mytable WHERE min_score != 0 AND prerequisite != ''"; - $myres = Database::query($query); - - if ($myres !== false && Database::num_rows($myres) > 0) { - while ($myrow = Database::fetch_array($myres)) { - if (is_numeric($myrow['prerequisite'])) { - $mysql2 = "UPDATE $mytable SET mastery_score = '".$myrow['min_score']."' WHERE id = '".$myrow['prerequisite']."'"; - $myres2 = Database::query($mysql2); - //echo $mysql2."
    "; - if ($myres2 !== false) { - $mysql3 = "UPDATE $mytable SET min_score = 0 WHERE id = '".$myrow['id']."'"; - $myres3 = Database::query($mysql3); - //echo $mysql3."
    "; - } - } - } - } - - // Work Tool Folder Update - // We search into DB all the folders in the work tool - if ($singleDbForm) { - $my_course_table = "$prefix{$row_course['db_name']}_student_publication"; - } else { - $my_course_table = $row_course['db_name'].".student_publication"; - } - - $sys_course_path = $_configuration['root_sys'].$_configuration['course_folder']; - - $course_dir = $sys_course_path.$row_course['directory'].'/work'; - - $dir_to_array = my_directory_to_array($course_dir, true); - $only_dir = array(); - - $sql_select = "SELECT filetype FROM " . $my_course_table . " WHERE filetype = 'folder'"; - $result = Database::query($sql_select); - $num_row = Database::num_rows($result); - - // Check if there are already folder registered - if ($num_row == 0) { - for ($i = 0; $i < count($dir_to_array); $i++) { - $only_dir[] = substr($dir_to_array[$i], strlen($course_dir), strlen($dir_to_array[$i])); - } - - for ($i = 0; $i < count($only_dir); $i++) { - $sql_insert_all= "INSERT INTO " . $my_course_table . " SET url = '" . $only_dir[$i] . "', " . - "title = '', - description = '', - author = '', - active = '0', - accepted = '1', - filetype = 'folder', - post_group_id = '0', - sent_date = '0000-00-00 00:00:00' "; - Database::query($sql_insert_all); - } - } - - } - } - } - } - -} else { - - echo 'You are not allowed here !' . __FILE__; - -} diff --git a/main/install/update-db-1.8.5-1.8.6.inc.php b/main/install/update-db-1.8.5-1.8.6.inc.php deleted file mode 100755 index 8c989a298d..0000000000 --- a/main/install/update-db-1.8.5-1.8.6.inc.php +++ /dev/null @@ -1,1147 +0,0 @@ -' . get_lang('Error') . ' ! Dokeos ' . implode('|', $updateFromVersion) . ' ' . get_lang('HasNotBeenFound') . '.

    - ' . get_lang('PleasGoBackToStep1') . '. -

    - '; - exit(); - } - - $_configuration['db_glue'] = get_config_param('dbGlu'); - - if ($singleDbForm) { - $_configuration['table_prefix'] = get_config_param('courseTablePrefix'); - $_configuration['main_database'] = get_config_param('mainDbName'); - $_configuration['db_prefix'] = get_config_param('dbNamePrefix'); - } - - $dbScormForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbScormForm); - - if (!empty($dbPrefixForm) && strpos($dbScormForm, $dbPrefixForm) !== 0) { - $dbScormForm = $dbPrefixForm . $dbScormForm; - } - - if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) { - $dbScormForm = $dbPrefixForm . 'scorm'; - } - - /* Normal upgrade procedure: start by updating main, statistic, user databases */ - - // If this script has been included by index.php, not update_courses.php, so - // that we want to change the main databases as well... - $only_test = false; - $log = 0; - if (defined('SYSTEM_INSTALLATION')) { - - if ($singleDbForm) { - $dbStatsForm = $dbNameForm; - $dbScormForm = $dbNameForm; - $dbUserForm = $dbNameForm; - } - /** - * Update the databases "pre" migration - */ - include_once '../lang/english/trad4all.inc.php'; - - if ($languageForm != 'english') { - // languageForm has been escaped in index.php - include_once '../lang/' . $languageForm . '/trad4all.inc.php'; - } - - // Get the main queries list (m_q_list) - $m_q_list = get_sql_file_contents('migrate-db-' . $old_file_version . '-' . $new_file_version . '-pre.sql', 'main'); - if (count($m_q_list) > 0) { - //now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - Log::error('Database name ' . $dbNameForm . ' is too long, skipping'); - } elseif (!in_array($dbNameForm, $dblist)) { - Log::error('Database ' . $dbNameForm . ' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - foreach ($m_q_list as $query) { - if ($only_test) { - Log::notice("iDatabase::query($dbNameForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In $dbNameForm, executed: $query"); - } - } - } - } - } - - require_once '../inc/lib/image.lib.php'; //this library has been created - // in 1.8.8, which makes this inclusion retroactively necessary in - // updates from 1.8.5 - // Filling the access_url_rel_user table with access_url_id by default = 1 - $query = "SELECT user_id FROM $dbNameForm.user"; - - $result_users = iDatabase::query($query); - while ($row = iDatabase::fetch_array($result_users, 'NUM')) { - $user_id = $row[0]; - $sql = "INSERT INTO $dbNameForm.access_url_rel_user SET user_id=$user_id, access_url_id=1"; - $res = iDatabase::query($sql); - //Updating user image - $query = "SELECT picture_uri FROM $dbNameForm.user WHERE user_id=$user_id"; - $res = iDatabase::query($query); - $picture_uri = iDatabase::fetch_array($res, 'NUM'); - $file = $picture_uri[0]; - $dir = api_get_path(SYS_CODE_PATH) . 'upload/users/'; - $image_repository = file_exists($dir . $file) ? $dir . $file : $dir . $user_id . '/' . $file; - - if (!is_dir($dir . $user_id)) { - @mkdir($dir . $user_id, $perm); - } - - if (file_exists($image_repository) && is_file($image_repository)) { - chmod($dir . $user_id, 0777); - if (is_dir($dir . $user_id)) { - $picture_location = $dir . $user_id . '/' . $file; - $big_picture_location = $dir . $user_id . '/big_' . $file; - - $temp = new Image($image_repository); - - $picture_infos = getimagesize($image_repository); - - $thumbwidth = 150; - if (empty($thumbwidth) or $thumbwidth == 0) { - $thumbwidth = 150; - } - - $new_height = ($picture_infos[0] > 0) ? round(($thumbwidth / $picture_infos[0]) * $picture_infos[1]) : 0; - - $temp->resize($thumbwidth, $new_height, 0); - - $type = $picture_infos[2]; - - // Original picture - $big_temp = new Image($image_repository); - - switch (!empty($type)) { - case 2 : $temp->send_image('JPG', $picture_location); - $big_temp->send_image('JPG', $big_picture_location); - break; - case 3 : $temp->send_image('PNG', $picture_location); - $big_temp->send_image('JPG', $big_picture_location); - break; - case 1 : $temp->send_image('GIF', $picture_location); - $big_temp->send_image('JPG', $big_picture_location); - break; - } - if ($image_repository == $dir . $file) { - @unlink($image_repository); - } - } - } - } - // Filling the access_url_rel_session table with access_url_id by default = 1 - $query = "SELECT id FROM $dbNameForm.session"; - $result = iDatabase::query($query); - while ($row = iDatabase::fetch_array($result, 'NUM')) { - $sql = "INSERT INTO $dbNameForm.access_url_rel_session SET session_id=" . $row[0] . ", access_url_id=1"; - $res = iDatabase::query($sql); - } - - // Since the parser of the migration DB does not work for this kind of inserts (HTML) we move it here - - $sql = 'INSERT INTO ' . $dbNameForm . '.system_template (title, comment, image, content) VALUES - (\'TemplateTitleCourseTitle\', \'TemplateTitleCourseTitleDescription\', \'coursetitle.gif\', \' - - {CSS} - - - - - - - - - - - -
    -

    TITULUS 1
    - TITULUS 2
    -

    -
    - Chamilo logo
    -


    -
    -

    - - \');'; - $res = iDatabase::query($sql); - - /* - $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES - (\'TemplateTitleCheckList\', \'TemplateTitleCheckListDescription\', \'checklist.gif\', \' - - {CSS} - - - - - - - - - -
    -

    Lorem ipsum dolor sit amet

    -
      -
    • consectetur adipisicing elit
    • -
    • sed do eiusmod tempor incididunt
    • -
    • ut labore et dolore magna aliqua
    • -
    - -

    Ut enim ad minim veniam

    -
      -
    • quis nostrud exercitation ullamco
    • -
    • laboris nisi ut aliquip ex ea commodo consequat
    • -
    • Excepteur sint occaecat cupidatat non proident
    • -
    - -

    Sed ut perspiciatis unde omnis

    -
      -
    • iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam
    • -
    • eaque ipsa quae ab illo inventore veritatis
    • -
    • et quasi architecto beatae vitae dicta sunt explicabo. 
    • -
    - -
    -

    Ut enim ad minima

    - Veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur.
    -

    - trainer

    -
    -


    -
    -

    - - \');'; - - $res = iDatabase::query($sql); - */ - - $sql = 'INSERT INTO ' . $dbNameForm . '.system_template (title, comment, image, content) VALUES - (\'TemplateTitleTeacher\', \'TemplateTitleTeacherDescription\', \'yourinstructor.gif\', \' - - {CSS} - - - - - - - - - - - - - - - - -
    - -
    - Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis pellentesque.
    -
    - trainer
    -


    -
    -

    - - \'); - '; - $res = iDatabase::query($sql); - - $sql = 'INSERT INTO ' . $dbNameForm . '.system_template (title, comment, image, content) VALUES - (\'TemplateTitleLeftList\', \'TemplateTitleListLeftListDescription\', \'leftlist.gif\', \' - - {CSS} - - - - - - - - - - - - - - - - - - -
     trainer
    -
    Lorem - ipsum dolor sit amet. -
    - Vivamus - a quam. 
    -
    - Proin - a est stibulum ante ipsum.
    -


    -
    -

    - - \');'; - $res = iDatabase::query($sql); - - $sql = 'INSERT INTO ' . $dbNameForm . '.system_template (title, comment, image, content) VALUES - (\'TemplateTitleLeftRightList\', \'TemplateTitleLeftRightListDescription\', \'leftrightlist.gif\', \' - - - {CSS} - - - - - - - - - - - - - - - - - - - - - - -
     Trainer
    -
    Lorem - ipsum dolor sit amet. - - Convallis - ut. Cras dui magna.
    - Vivamus - a quam. 
    -
    - Etiam - lacinia stibulum ante.
    -
    - Proin - a est stibulum ante ipsum. - Consectetuer - adipiscing elit.
    -
    -


    -
    -

    - - - \');'; - $res = iDatabase::query($sql); - - $sql = 'INSERT INTO ' . $dbNameForm . '.system_template (title, comment, image, content) VALUES - (\'TemplateTitleRightList\', \'TemplateTitleRightListDescription\', \'rightlist.gif\', \' - - {CSS} - - - - - - - - - - - - - - - - - - -
    trainer
    -
    - Convallis - ut. Cras dui magna.
    - Etiam - lacinia.
    -
    - Consectetuer - adipiscing elit.
    -
    -


    -
    -

    - - \');'; - $res = iDatabase::query($sql); - - /* - $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES - (\'TemplateTitleComparison\', \'TemplateTitleComparisonDescription\', \'compare.gif\', \' - - {CSS} - - - - - - - - - - - - - - - \');'; - $res = iDatabase::query($sql); - */ - - $sql = 'INSERT INTO ' . $dbNameForm . '.system_template (title, comment, image, content) VALUES - (\'TemplateTitleDiagram\', \'TemplateTitleDiagramDescription\', \'diagram.gif\', \' - - {CSS} - - - -
     trainer
    -
    - Lorem ipsum dolor sit amet. - - Convallis - ut. Cras dui magna.
    - - - - - - - - - - - -
    -
    - Etiam - lacinia stibulum ante. - Convallis - ut. Cras dui magna.
    - Alaska chart
    - trainer
    -


    -
    -

    - - \'); - '; - $res = iDatabase::query($sql); - - $sql = 'INSERT INTO ' . $dbNameForm . '.system_template (title, comment, image, content) VALUES - (\'TemplateTitleDesc\', \'TemplateTitleCheckListDescription\', \'description.gif\', \' - - {CSS} - - - - - - - - - - -
    - 01
    Lorem ipsum dolor sit amet


    - 02 -
    Ut enim ad minim veniam


    - 03Duis aute irure dolor in reprehenderit


    - 04Neque porro quisquam est
    - Gearbox
    -


    -
    -

    - - \'); - '; - $res = iDatabase::query($sql); - - /* - $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES - (\'TemplateTitleObjectives\', \'TemplateTitleObjectivesDescription\', \'courseobjectives.gif\', \' - - {CSS} - - - - - - - - - - - - - -
    - trainer
    -
    -

    Lorem ipsum dolor sit amet

    -
      -
    • consectetur adipisicing elit
    • -
    • sed do eiusmod tempor incididunt
    • -
    • ut labore et dolore magna aliqua
    • -
    -

    Ut enim ad minim veniam

    -
      -
    • quis nostrud exercitation ullamco
    • -
    • laboris nisi ut aliquip ex ea commodo consequat
    • -
    • Excepteur sint occaecat cupidatat non proident
    • -
    -
    -


    -
    -

    - - \');'; - $res = iDatabase::query($sql); - */ - - $sql = 'INSERT INTO ' . $dbNameForm . '.system_template (title, comment, image, content) VALUES - (\'TemplateTitleCycle\', \'TemplateTitleCycleDescription\', \'cyclechart.gif\', \' - - {CSS} - - - - - - - - - - - - - - - - - - - - - - - - - -
    - arrow -
    - Lorem ipsum - - Sed ut perspiciatis -
    -
      -
    • dolor sit amet
    • -
    • consectetur adipisicing elit
    • -
    • sed do eiusmod tempor 
    • -
    • adipisci velit, sed quia non numquam
    • -
    • eius modi tempora incidunt ut labore et dolore magnam
    • -
    -
    -
      -
    • ut enim ad minim veniam
    • -
    • quis nostrud exercitation
    • ullamco laboris nisi ut
    • -
    • Quis autem vel eum iure reprehenderit qui in ea
    • -
    • voluptate velit esse quam nihil molestiae consequatur,
    • -
    -
    - arrow         -
    -


    -
    -

    - - \');'; - $res = iDatabase::query($sql); - - /* - $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES - (\'TemplateTitleLearnerWonder\', \'TemplateTitleLearnerWonderDescription\', \'learnerwonder.gif\', \' - - {CSS} - - - - - - - - - - - - - - - - - - - -
    - learner wonders
    -
    - Convallis - ut. Cras dui magna.
    - Etiam - lacinia stibulum ante.
    -
    - Consectetuer - adipiscing elit.
    -
    -


    -
    -

    - - \'); - '; - $res = iDatabase::query($sql); - */ - - $sql = 'INSERT INTO ' . $dbNameForm . '.system_template (title, comment, image, content) VALUES - (\'TemplateTitleTimeline\', \'TemplateTitleTimelineDescription\', \'phasetimeline.gif\', \' - - {CSS} - - - - - - - - - - - - - - - - - - - - - - - - -
    Lorem ipsumPerspiciatisNemo enim
    -
      -
    • dolor sit amet
    • -
    • consectetur
    • -
    • adipisicing elit
    • -
    -
    -
    - arrow - -
      -
    • ut labore
    • -
    • et dolore
    • -
    • magni dolores
    • -
    -
    - arrow - -
      -
    • neque porro
    • -
    • quisquam est
    • -
    • qui dolorem  
    • -
    -

    -
    -


    -
    -

    - - \'); - '; - $res = iDatabase::query($sql); - - /* - $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES - (\'TemplateTitleStopAndThink\', \'TemplateTitleStopAndThinkDescription\', \'stopthink.gif\', \' - - {CSS} - - - - - - - - - - - - -
    - trainer -
    -
    -

    Attentio sectetur adipisicing elit

    -
      -
    • sed do eiusmod tempor incididunt
    • -
    • ut labore et dolore magna aliqua
    • -
    • quis nostrud exercitation ullamco
    • -

    -


    -
    -

    - - \');'; - $res = iDatabase::query($sql); - */ - - $sql = 'INSERT INTO ' . $dbNameForm . '.system_template (title, comment, image, content) VALUES - (\'TemplateTitleTable\', \'TemplateTitleCheckListDescription\', \'table.gif\', \' - - {CSS} - - - - -
    -

    A table

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    City2005200620072008
    Lima10,408,959,199,76
    New York18,3917,5216,5716,60
    Barcelona0,100,100,050,05
    Paris3,383,633,633,54
    -
    - - \');'; - $res = iDatabase::query($sql); - - $sql = 'INSERT INTO ' . $dbNameForm . '.system_template (title, comment, image, content) VALUES - (\'TemplateTitleAudio\', \'TemplateTitleAudioDescription\', \'audiocomment.gif\', \' - - {CSS} - - - - - - - - - - - - - - -
    -
    - - -
    - -
    -

    - image
    - trainer
    -


    -
    -

    - - \');'; - $res = iDatabase::query($sql); - - $sql = 'INSERT INTO ' . $dbNameForm . '.system_template (title, comment, image, content) VALUES - (\'TemplateTitleVideo\', \'TemplateTitleVideoDescription\', \'video.gif\', \' - - {CSS} - - - - - - - - - - -
    - -
    -
    - -
    - -
    - - - -
    -
    - -
    -


    -

    -

    Lorem ipsum dolor sit amet

    -
      -
    • consectetur adipisicing elit
    • -
    • sed do eiusmod tempor incididunt
    • -
    • ut labore et dolore magna aliqua
    • -
    -

    Ut enim ad minim veniam

    -
      -
    • quis nostrud exercitation ullamco
    • -
    • laboris nisi ut aliquip ex ea commodo consequat
    • -
    • Excepteur sint occaecat cupidatat non proident
    • -
    -
    -


    -
    -

    - - - \'); '; - $res = iDatabase::query($sql); - - $sql = 'INSERT INTO ' . $dbNameForm . '.system_template (title, comment, image, content) VALUES - (\'TemplateTitleFlash\', \'TemplateTitleFlashDescription\', \'flash.gif\', \' - - {CSS} - - -
    - - - - - - -
    -
    -
    -


    -
    -

    -
    - - \'); '; - $res = iDatabase::query($sql); - - // Check if course_module exists, as it was not installed in Dokeos 1.8.5 because of a broken query, and $sql = 'INSERT it if necessary - $query = "SELECT * FROM $dbNameForm.course_module"; - $result = iDatabase::query($query); - if ($result === false) { - //the course_module table doesn't exist, create it - $sql = "CREATE TABLE $dbNameForm.course_module ( - id int unsigned NOT NULL auto_increment, - name varchar(100) NOT NULL, - link varchar(255) NOT NULL, - image varchar(100) default NULL, - `row` int unsigned NOT NULL default '0', - `column` int unsigned NOT NULL default '0', - position varchar(20) NOT NULL default 'basic', - PRIMARY KEY (id) - ) - "; - $result = iDatabase::query($sql); - if ($result !== false) { - $sql = "INSERT INTO $dbNameForm.course_module (name, link, image, `row`,`column`, position) VALUES - ('calendar_event','calendar/agenda.php','agenda.gif',1,1,'basic'), - ('link','link/link.php','links.gif',4,1,'basic'), - ('document','document/document.php','documents.gif',3,1,'basic'), - ('student_publication','work/work.php','works.gif',3,2,'basic'), - ('announcement','announcements/announcements.php','valves.gif',2,1,'basic'), - ('user','user/user.php','members.gif',2,3,'basic'), - ('forum','forum/index.php','forum.gif',1,2,'basic'), - ('quiz','exercice/exercice.php','quiz.gif',2,2,'basic'), - ('group','group/group.php','group.gif',3,3,'basic'), - ('course_description','course_description/','info.gif',1,3,'basic'), - ('chat','chat/chat.php','chat.gif',0,0,'external'), - ('dropbox','dropbox/index.php','dropbox.gif',4,2,'basic'), - ('tracking','tracking/courseLog.php','statistics.gif',1,3,'courseadmin'), - ('homepage_link','link/link.php?action=addlink','npage.gif',1,1,'courseadmin'), - ('course_setting','course_info/infocours.php','reference.gif',1,1,'courseadmin'), - ('External','','external.gif',0,0,'external'), - ('AddedLearnpath','','scormbuilder.gif',0,0,'external'), - ('conference','conference/index.php?type=conference','conf.gif',0,0,'external'), - ('conference','conference/index.php?type=classroom','conf.gif',0,0,'external'), - ('learnpath','newscorm/lp_controller.php','scorm.gif',5,1,'basic'), - ('blog','blog/blog.php','blog.gif',1,2,'basic'), - ('blog_management','blog/blog_admin.php','blog_admin.gif',1,2,'courseadmin'), - ('course_maintenance','course_info/maintenance.php','backup.gif',2,3,'courseadmin'), - ('survey','survey/survey_list.php','survey.gif',2,1,'basic'), - ('wiki','wiki/index.php','wiki.gif',2,3,'basic'), - ('gradebook','gradebook/index.php','gradebook.gif',2,2,'basic'), - ('glossary','glossary/index.php','glossary.gif',2,1,'basic'), - ('notebook','notebook/index.php','notebook.gif',2,1,'basic')"; - $res = iDatabase::query($sql); - } - } - - // Get the stats queries list (s_q_list) - $s_q_list = get_sql_file_contents('migrate-db-' . $old_file_version . '-' . $new_file_version . '-pre.sql', 'stats'); - - if (count($s_q_list) > 0) { - // Now use the $s_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbStatsForm) > 40) { - Log::error('Database name ' . $dbStatsForm . ' is too long, skipping'); - } elseif (!in_array($dbStatsForm, $dblist)) { - Log::error('Database ' . $dbStatsForm . ' was not found, skipping'); - } else { - iDatabase::select_db($dbStatsForm); - foreach ($s_q_list as $query) { - if ($only_test) { - Log::notice("iDatabase::query($dbStatsForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In $dbStatsForm, executed: $query"); - } - } - } - } - } - // Get the user queries list (u_q_list) - $u_q_list = get_sql_file_contents('migrate-db-' . $old_file_version . '-' . $new_file_version . '-pre.sql', 'user'); - if (count($u_q_list) > 0) { - // Now use the $u_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbUserForm) > 40) { - Log::error('Database name ' . $dbUserForm . ' is too long, skipping'); - } elseif (!in_array($dbUserForm, $dblist)) { - Log::error('Database ' . $dbUserForm . ' was not found, skipping'); - } else { - iDatabase::select_db($dbUserForm); - foreach ($u_q_list as $query) { - if ($only_test) { - error_log("iDatabase::query($dbUserForm,$query)"); - error_log("In $dbUserForm, executed: $query"); - } else { - $res = iDatabase::query($query); - } - } - } - } - // The SCORM database doesn't need a change in the pre-migrate part - ignore - } - - $prefix = ''; - if ($singleDbForm) { - $prefix = get_config_param('table_prefix'); - } - - // Get the courses databases queries list (c_q_list) - $c_q_list = get_sql_file_contents('migrate-db-' . $old_file_version . '-' . $new_file_version . '-pre.sql', 'course'); - - if (count($c_q_list) > 0) { - // Get the courses list - if (strlen($dbNameForm) > 40) { - error_log('Database name ' . $dbNameForm . ' is too long, skipping'); - } elseif (!in_array($dbNameForm, $dblist)) { - error_log('Database ' . $dbNameForm . ' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - $res = iDatabase::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code"); - - if ($res === false) { - die('Error while querying the courses list in update_db-1.8.5-1.8.6.inc.php'); - } - - if (iDatabase::num_rows($res) > 0) { - $i = 0; - $list = array(); - while ($row = iDatabase::fetch_array($res)) { - $list[] = $row; - $i++; - } - foreach ($list as $row_course) { - // Now use the $c_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (!$singleDbForm) { //otherwise just use the main one - iDatabase::select_db($row_course['db_name']); - } - Log::notice('Course db ' . $row_course['db_name']); - - foreach ($c_q_list as $query) { - if ($singleDbForm) { //otherwise just use the main one - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query); - } - - if ($only_test) { - Log::notice("iDatabase::query(" . $row_course['db_name'] . ",$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In " . $row_course['db_name'] . ", executed: $query"); - } - } - } - - $t_d = $row_course['db_name'] . ".document"; - $t_ip = $row_course['db_name'] . ".item_property"; - - if ($singleDbForm) { - $t_d = "$prefix{$row_course['db_name']}_document"; - $t_ip = "$prefix{$row_course['db_name']}_item_property"; - } - // Shared documents folder - $query = "INSERT INTO $t_d (path,title,filetype,size) VALUES ('/shared_folder','" . get_lang('SharedDocumentsDirectory') . "','folder','0')"; - $myres = iDatabase::query($query); - if ($myres !== false) { - $doc_id = iDatabase::insert_id(); - $query = "INSERT INTO $t_ip (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('document',1,NOW(),NOW(),$doc_id,'FolderAdded',1,0,NULL,1)"; - $myres = iDatabase::query($query); - } - } - } - } - } -} else { - - echo 'You are not allowed here !' . __FILE__; -} diff --git a/main/install/update-db-1.8.6-1.8.6.1.inc.php b/main/install/update-db-1.8.6-1.8.6.1.inc.php deleted file mode 100755 index 426e04e5fc..0000000000 --- a/main/install/update-db-1.8.6-1.8.6.1.inc.php +++ /dev/null @@ -1,264 +0,0 @@ -'.get_lang('Error').' ! Dokeos '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').'.

    - '.get_lang('PleasGoBackToStep1').'. -

    - '; - exit (); - } - - $_configuration['db_glue'] = get_config_param('dbGlu'); - - if ($singleDbForm) { - $_configuration['table_prefix'] = get_config_param('courseTablePrefix'); - $_configuration['main_database'] = get_config_param('mainDbName'); - $_configuration['db_prefix'] = get_config_param('dbNamePrefix'); - } - - $dbScormForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbScormForm); - - if (!empty($dbPrefixForm) && strpos($dbScormForm, $dbPrefixForm) !== 0) { - $dbScormForm = $dbPrefixForm.$dbScormForm; - } - - if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) { - $dbScormForm = $dbPrefixForm.'scorm'; - } - - /* Normal upgrade procedure: start by updating main, statistic, user databases */ - - // If this script has been included by index.php, not update_courses.php, so - // that we want to change the main databases as well... - $only_test = false; - $log = 0; - if (defined('SYSTEM_INSTALLATION')) { - - if ($singleDbForm) { - $dbStatsForm = $dbNameForm; - $dbScormForm = $dbNameForm; - $dbUserForm = $dbNameForm; - } - /** - * Update the databases "pre" migration - */ - include_once '../lang/english/trad4all.inc.php'; - - if ($languageForm != 'english') { - //languageForm has been escaped in index.php - include_once '../lang/'.$languageForm.'/trad4all.inc.php'; - } - - //get the main queries list (m_q_list) - $m_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'main'); - if (count($m_q_list) > 0) { - // Now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - Log::error('Database name '.$dbNameForm.' is too long, skipping'); - } elseif (!in_array($dbNameForm,$dblist)) { - Log::error('Database '.$dbNameForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - foreach($m_q_list as $query) { - if ($only_test){ - Log::notice("iDatabase::query($dbNameForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In $dbNameForm, executed: $query"); - } - } - } - } - } - - - // Get the stats queries list (s_q_list) - $s_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'stats'); - - if (count($s_q_list) > 0) { - // Now use the $s_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbStatsForm) > 40) { - Log::error('Database name '.$dbStatsForm.' is too long, skipping'); - } elseif (!in_array($dbStatsForm,$dblist)) { - Log::error('Database '.$dbStatsForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbStatsForm); - foreach ($s_q_list as $query) { - if ($only_test) { - Log::notice("iDatabase::query($dbStatsForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In $dbStatsForm, executed: $query"); - } - } - } - } - } - // Get the user queries list (u_q_list) - $u_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'user'); - if (count($u_q_list) > 0) { - // Now use the $u_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbUserForm) > 40) { - Log::error('Database name '.$dbUserForm.' is too long, skipping'); - } elseif (!in_array($dbUserForm, $dblist)) { - Log::error('Database '.$dbUserForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbUserForm); - foreach ($u_q_list as $query) { - if ($only_test) { - Log::notice("iDatabase::query($dbUserForm,$query)"); - Log::notice("In $dbUserForm, executed: $query"); - } else { - $res = iDatabase::query($query); - } - } - } - } - // The SCORM database doesn't need a change in the pre-migrate part - ignore - } - - $prefix = ''; - if ($singleDbForm) { - $prefix = get_config_param ('table_prefix'); - } - - // Get the courses databases queries list (c_q_list) - $c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'course'); - - if (count($c_q_list) > 0) { - // Get the courses list - if (strlen($dbNameForm) > 40) { - Log::error('Database name '.$dbNameForm.' is too long, skipping'); - } elseif (!in_array($dbNameForm, $dblist)) { - Log::error('Database '.$dbNameForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - $res = iDatabase::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code"); - - if ($res === false) { die('Error while querying the courses list in update_db-1.8.6-1.8.6.1.inc.php'); } - - if (iDatabase::num_rows($res) > 0) { - $i = 0; - $list = array(); - while ($row = iDatabase::fetch_array($res)) { - $list[] = $row; - $i++; - } - foreach ($list as $row_course) { - // Now use the $c_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (!$singleDbForm) { //otherwise just use the main one - iDatabase::select_db($row_course['db_name']); - } - Log::notice('Course db ' . $row_course['db_name']); - - foreach ($c_q_list as $query) { - if ($singleDbForm) { - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query); - } - - if ($only_test) { - Log::notice("iDatabase::query(".$row_course['db_name'].",$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In ".$row_course['db_name'].", executed: $query"); - } - } - } - - $t_wiki = $row_course['db_name'].".wiki"; - $t_wiki_conf = $row_course['db_name'].".wiki_conf"; - - if ($singleDbForm) { - $t_wiki = "$prefix{$row_course['db_name']}_wiki"; - $t_wiki_conf = "$prefix{$row_course['db_name']}_wiki_conf"; - } - - // Update correct page_id to wiki table, actually only store 0 - $query = "SELECT id, reflink FROM $t_wiki"; - $res_page = iDatabase::query($query); - $wiki_id = $reflink = array(); - - if (iDatabase::num_rows($res_page) > 0) { - while ($row_page = iDatabase::fetch_row($res_page)) { - $wiki_id[] = $row_page[0]; - $reflink[] = $row_page[1]; - } - } - - $reflink_unique = array_unique($reflink); - $reflink_flip = array_flip($reflink_unique); - - if (is_array($wiki_id)) { - foreach ($wiki_id as $key => $wiki_page) { - $pag_id = $reflink_flip[$reflink[$key]]; - $sql= "UPDATE $t_wiki SET page_id='".($pag_id + 1)."' WHERE id = '$wiki_page'"; - $res_update = iDatabase::query($sql); - } - } - - // Insert page_id into wiki_conf table, actually this table is empty - $query = "SELECT DISTINCT page_id FROM $t_wiki ORDER BY page_id"; - $myres_wiki = iDatabase::query($query); - - if (iDatabase::num_rows($myres_wiki) > 0) { - while ($row_wiki = iDatabase::fetch_row($myres_wiki)) { - $page_id = $row_wiki[0]; - $query = "INSERT INTO ".$t_wiki_conf." (page_id, task, feedback1, feedback2, feedback3, fprogress1, fprogress2, fprogress3) VALUES ('".$page_id."','','','','','','','')"; - $myres_wiki_conf = iDatabase::query($query); - } - } - - } - } - } - } - -} else { - - echo 'You are not allowed here !' . __FILE__; - -} diff --git a/main/install/update-db-1.8.6.1-1.8.6.2.inc.php b/main/install/update-db-1.8.6.1-1.8.6.2.inc.php deleted file mode 100755 index 6df0fb542c..0000000000 --- a/main/install/update-db-1.8.6.1-1.8.6.2.inc.php +++ /dev/null @@ -1,349 +0,0 @@ -'.get_lang('Error').' ! Dokeos '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').'.

    - '.get_lang('PleasGoBackToStep1').'. -

    - '; - exit (); - } - - $_configuration['db_glue'] = get_config_param('dbGlu'); - - if ($singleDbForm) { - $_configuration['table_prefix'] = get_config_param('courseTablePrefix'); - $_configuration['main_database'] = get_config_param('mainDbName'); - $_configuration['db_prefix'] = get_config_param('dbNamePrefix'); - } - - $dbScormForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbScormForm); - - if (!empty($dbPrefixForm) && strpos($dbScormForm, $dbPrefixForm) !== 0) { - $dbScormForm = $dbPrefixForm.$dbScormForm; - } - - if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) { - $dbScormForm = $dbPrefixForm.'scorm'; - } - - /* Normal upgrade procedure: start by updating main, statistic, user databases */ - - // If this script has been included by index.php, not update_courses.php, so - // that we want to change the main databases as well... - $only_test = false; - $log = 0; - if (defined('SYSTEM_INSTALLATION')) { - - if ($singleDbForm) { - $dbStatsForm = $dbNameForm; - $dbScormForm = $dbNameForm; - $dbUserForm = $dbNameForm; - } - /** - * Update the databases "pre" migration - */ - include_once '../lang/english/trad4all.inc.php'; - - if ($languageForm != 'english') { - // languageForm has been escaped in index.php - include_once '../lang/'.$languageForm.'/trad4all.inc.php'; - } - - // Get the main queries list (m_q_list) - $m_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'main'); - if (count($m_q_list) > 0) { - // Now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - Log::error('Database name '.$dbNameForm.' is too long, skipping'); - } elseif (!in_array($dbNameForm,$dblist)) { - Log::error('Database '.$dbNameForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - foreach ($m_q_list as $query) { - if ($only_test) { - Log::notice("iDatabase::query($dbNameForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In $dbNameForm, executed: $query"); - } - } - } - - - // There might now be multiple course coaches. This implies - // moving the previous course coach elements from the - // session_rel_course table to the session_rel_course_rel_user - // table with status 2 - // Select all the current course coaches in sessions - - $sql = "SELECT id_session, course_code, id_coach - FROM session_rel_course - ORDER BY id_session, course_code"; - - $res = iDatabase::query($sql); - - if ($res === false) { - Log::error('Could not query session course coaches table: '.iDatabase::error()); - } else { - // For each coach found, add him as a course coach in the - // session_rel_course_rel_user table - while ($row = iDatabase::fetch_array($res)) { - - // Check whether coach is a student - $sql = "SELECT 1 FROM session_rel_course_rel_user - WHERE id_session='{$row[id_session]}' AND course_code='{$row[course_code]}' AND id_user='{$row[id_coach]}'"; - $rs = iDatabase::query($sql); - - if (iDatabase::num_rows($rs) > 0) { - $sql_upd = "UPDATE session_rel_course_rel_user SET status=2 - WHERE id_session='{$row[id_session]}' AND course_code='{$row[course_code]}' AND id_user='{$row[id_coach]}'"; - } else { - $sql_ins = "INSERT INTO session_rel_course_rel_user(id_session, course_code, id_user, status) - VALUES ('{$row[id_session]}','{$row[course_code]}','{$row[id_coach]}',2)"; - } - - $rs_coachs = iDatabase::query($sql_ins); - - if ($rs_coachs === false) { - Log::error('Could not move course coach to new table: '.iDatabase::error()); - } - - } - } - - // Remove duplicated rows for 'show_tutor_data' AND 'show_teacher_data' into settings_current table - - $sql = "SELECT id FROM settings_current WHERE variable='show_tutor_data' ORDER BY id"; - $rs_chk_id1 = iDatabase::query($sql); - - if ($rs_chk_id1 === false) { - Log::error('Could not query settings_current ids table: '.iDatabase::error()); - } else { - $i = 1; - while ($row_id1 = iDatabase::fetch_array($rs_chk_id1)) { - $id = $row_id1['id']; - if ($i > 1) { - $sql_del = "DELETE FROM settings_current WHERE id = '$id'"; - iDatabase::query($sql_del); - } - $i++; - } - } - - $sql = "SELECT id FROM settings_current WHERE variable='show_teacher_data' ORDER BY id"; - $rs_chk_id2 = iDatabase::query($sql); - - if ($rs_chk_id2 === false) { - Log::error('Could not query settings_current ids table: '.iDatabase::error()); - } else { - $i = 1; - while ($row_id2 = iDatabase::fetch_array($rs_chk_id2)) { - $id = $row_id2['id']; - if ($i > 1) { - $sql_del = "DELETE FROM settings_current WHERE id = '$id'"; - iDatabase::query($sql_del); - } - $i++; - } - } - - } - } - // Now clean the deprecated id_coach field from the session_rel_course table - $m_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-post.sql', 'main'); - if (count($m_q_list) > 0) { - // Now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - Log::error('Database name '.$dbNameForm.' is too long, skipping'); - } elseif (!in_array($dbNameForm,$dblist)) { - Log::error('Database '.$dbNameForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - foreach ($m_q_list as $query) { - if ($only_test) { - Log::notice("iDatabase::query($dbNameForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In $dbNameForm, executed: $query"); - } - } - } - } - } - - // Get the stats queries list (s_q_list) - $s_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'stats'); - - if (count($s_q_list) > 0) { - // Now use the $s_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbStatsForm) > 40) { - Log::error('Database name '.$dbStatsForm.' is too long, skipping'); - } elseif (!in_array($dbStatsForm, $dblist)) { - Log::error('Database '.$dbStatsForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbStatsForm); - foreach ($s_q_list as $query) { - if ($only_test) { - Log::notice("iDatabase::query($dbStatsForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In $dbStatsForm, executed: $query"); - } - } - } - } - } - // Get the user queries list (u_q_list) - $u_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'user'); - if (count($u_q_list) > 0) { - // Now use the $u_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbUserForm) > 40) { - Log::error('Database name '.$dbUserForm.' is too long, skipping'); - } elseif (!in_array($dbUserForm,$dblist)) { - Log::error('Database '.$dbUserForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbUserForm); - foreach ($u_q_list as $query) { - if ($only_test){ - Log::notice("iDatabase::query($dbUserForm,$query)"); - Log::notice("In $dbUserForm, executed: $query"); - } else { - $res = iDatabase::query($query); - } - } - } - } - // The SCORM database doesn't need a change in the pre-migrate part - ignore - } - - $prefix = ''; - if ($singleDbForm) { - $prefix = get_config_param ('table_prefix'); - } - - // Get the courses databases queries list (c_q_list) - $c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'course'); - - if (count($c_q_list) > 0) { - // Get the courses list - if (strlen($dbNameForm) > 40) { - Log::error('Database name '.$dbNameForm.' is too long, skipping'); - } elseif (!in_array($dbNameForm, $dblist)) { - Log::error('Database '.$dbNameForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - $res = iDatabase::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code"); - - if ($res === false) { die('Error while querying the courses list in update_db-1.8.6.1-1.8.6.2.inc.php'); } - - if (iDatabase::num_rows($res) > 0) { - $i = 0; - $list = array(); - while ($row = iDatabase::fetch_array($res)) { - $list[] = $row; - $i++; - } - foreach ($list as $row_course) { - // Now use the $c_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (!$singleDbForm) { //otherwise just use the main one - iDatabase::select_db($row_course['db_name']); - } - Log::notice('Course db ' . $row_course['db_name']); - - foreach ($c_q_list as $query) { - if ($singleDbForm) { - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query); - } - - if ($only_test) { - Log::error("iDatabase::query(".$row_course['db_name'].",$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::error("In ".$row_course['db_name'].", executed: $query"); - } - } - } - - // Fill description type into course_description table - - $t_course_description = $row_course['db_name'].".course_description"; - - if ($singleDbForm) { - $t_course_description = "$prefix{$row_course['db_name']}_course_description"; - } - - // Get all ids and update description_type field with them from course_description table - $sql_sel = "SELECT id FROM $t_course_description"; - $rs_sel = iDatabase::query($sql_sel); - - if ($rs_sel === false) { - Log::error('Could not query course_description ids table: '.iDatabase::error()); - } else { - if (iDatabase::num_rows($rs_sel) > 0) { - while ($row_ids = iDatabase::fetch_array($rs_sel)) { - $description_id = $row_ids['id']; - $sql_upd = "UPDATE $t_course_description SET description_type='$description_id' WHERE id='$description_id'"; - iDatabase::query($sql_upd); - } - } - } - - } - } - } - } - -} else { - - echo 'You are not allowed here !' . __FILE__; - -} diff --git a/main/install/update-db-1.8.6.2-1.8.7.inc.php b/main/install/update-db-1.8.6.2-1.8.7.inc.php deleted file mode 100755 index b407645a09..0000000000 --- a/main/install/update-db-1.8.6.2-1.8.7.inc.php +++ /dev/null @@ -1,568 +0,0 @@ -' . get_lang('Error') . ' ! Chamilo ' . implode('|', $updateFromVersion) . ' ' . get_lang('HasNotBeenFound') . '.

    - ' . get_lang('PleasGoBackToStep1') . '. -

    - '; - exit(); - } - - $_configuration['db_glue'] = get_config_param('dbGlu'); - - if ($singleDbForm) { - $_configuration['table_prefix'] = get_config_param('courseTablePrefix'); - $_configuration['main_database'] = get_config_param('mainDbName'); - $_configuration['db_prefix'] = get_config_param('dbNamePrefix'); - } - - $dbScormForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbScormForm); - - if (!empty($dbPrefixForm) && strpos($dbScormForm, $dbPrefixForm) !== 0) { - $dbScormForm = $dbPrefixForm . $dbScormForm; - } - - if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) { - $dbScormForm = $dbPrefixForm . 'scorm'; - } - - /* Normal upgrade procedure: start by updating main, statistic, user databases */ - - // If this script has been included by index.php, not update_courses.php, so - // that we want to change the main databases as well... - $only_test = false; - $log = 0; - if (defined('SYSTEM_INSTALLATION')) { - - if ($singleDbForm) { - $dbStatsForm = $dbNameForm; - $dbScormForm = $dbNameForm; - $dbUserForm = $dbNameForm; - } - /** - * Update the databases "pre" migration - */ - include_once '../lang/english/trad4all.inc.php'; - - if ($languageForm != 'english') { - // languageForm has been escaped in index.php - include_once '../lang/' . $languageForm . '/trad4all.inc.php'; - } - - // Get the main queries list (m_q_list) - $m_q_list = get_sql_file_contents('migrate-db-' . $old_file_version . '-' . $new_file_version . '-pre.sql', 'main'); - if (count($m_q_list) > 0) { - // Now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - Log::error('Database name ' . $dbNameForm . ' is too long, skipping'); - } elseif (!in_array($dbNameForm, $dblist)) { - Log::error('Database ' . $dbNameForm . ' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - foreach ($m_q_list as $query) { - if ($only_test) { - Log::notice("Database::query($dbNameForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In $dbNameForm, executed: $query"); - } - if ($res === false) { - Log::error('Error in ' . $query . ': ' . iDatabase::error()); - } - } - } - $tables = iDatabase::get_tables($dbNameForm); - foreach ($tables as $table) { - $query = "ALTER TABLE `" . $table . "` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"; - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in ' . $query . ': ' . iDatabase::error()); - } - } - $query = "ALTER DATABASE `" . $dbNameForm . "` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;"; - $res = Database::query($query); - if ($res === false) { - Log::error('Error in ' . $query . ': ' . iDatabase::error()); - } - } - } - - if (DATE_TIME_INSTALLED) { - // Converting dates and times to UTC using the default timezone of PHP - // Converting gradebook dates and times - $timezone = date_default_timezone_get(); - // Calculating the offset - $dateTimeZoneCurrent = new DateTimeZone($timezone); - $dateTimeUTC = new DateTime("now", new DateTimeZone('UTC')); - $timeOffsetSeconds = $dateTimeZoneCurrent->getOffset($dateTimeUTC); - $timeOffsetHours = $timeOffsetSeconds / 3600; - $timeOffsetString = ""; - - if ($timeOffsetHours < 0) { - $timeOffsetString .= "-"; - $timeOffsetHours = abs($timeOffsetHours); - } else { - $timeOffsetString .= "+"; - } - - if ($timeOffsetHours < 10) { - $timeOffsetString .= "0"; - } - - $timeOffsetString .= "$timeOffsetHours"; - $timeOffsetString .= ":00"; - - // Executing the queries to convert everything - $queries[] = "UPDATE gradebook_certificate SET created_at = CONVERT_TZ(created_at, '" . $timeOffsetString . "', '+00:00');"; - $queries[] = "UPDATE gradebook_evaluation SET created_at = CONVERT_TZ(created_at, '" . $timeOffsetString . "', '+00:00');"; - $queries[] = "UPDATE gradebook_link SET created_at = CONVERT_TZ(created_at, '" . $timeOffsetString . "', '+00:00');"; - $queries[] = "UPDATE gradebook_linkeval_log SET created_at = CONVERT_TZ(created_at, '" . $timeOffsetString . "', '+00:00');"; - $queries[] = "UPDATE gradebook_result SET created_at = CONVERT_TZ(created_at, '" . $timeOffsetString . "', '+00:00');"; - $queries[] = "UPDATE gradebook_result_log SET created_at = CONVERT_TZ(created_at, '" . $timeOffsetString . "', '+00:00');"; - - foreach ($queries as $query) { - iDatabase::query($query); - } - } - // Moving user followed by a human resource manager from hr_dept_id field to user_rel_user table - $query = "SELECT user_id, hr_dept_id FROM $dbNameForm.user"; - $result = iDatabase::query($query); - if (iDatabase::num_rows($result) > 0) { - require_once api_get_path(LIBRARY_PATH) . 'usermanager.lib.php'; - while ($row = iDatabase::fetch_array($result, 'ASSOC')) { - $user_id = $row['user_id']; - $hr_dept_id = $row['hr_dept_id']; - // moving data to user_rel_user table - if (!empty($hr_dept_id)) { - $sql = " SELECT id FROM $dbNameForm.user_rel_user WHERE user_id = $user_id AND friend_user_id = $hr_dept_id AND relation_type = " . USER_RELATION_TYPE_RRHH . " "; - $rs = iDatabase::query($sql); - if (iDatabase::num_rows($rs) == 0) { - $ins = "INSERT INTO $dbNameForm.user_rel_user SET user_id = $user_id, friend_user_id = $hr_dept_id, relation_type = " . USER_RELATION_TYPE_RRHH . " "; - iDatabase::query($ins); - } - } - } - // cleaning hr_dept_id field inside user table - $upd = "UPDATE $dbNameForm.user SET hr_dept_id = 0"; - iDatabase::query($upd); - } - - // Updating score display for each gradebook category - // first we check if there already is migrated data to categoy_id field - $query = "SELECT id FROM $dbNameForm.gradebook_score_display WHERE category_id = 0"; - $rs_check = iDatabase::query($query); - - if (iDatabase::num_rows($rs_check) > 0) { - // get all gradebook categories id - $a_categories = array(); - $query = "SELECT id FROM $dbNameForm.gradebook_category"; - $rs_gradebook = iDatabase::query($query); - if (iDatabase::num_rows($rs_gradebook) > 0) { - while ($row_gradebook = iDatabase::fetch_row($rs_gradebook)) { - $a_categories[] = $row_gradebook[0]; - } - } - - // get all gradebook score display - $query = "SELECT * FROM $dbNameForm.gradebook_score_display"; - $rs_score_display = iDatabase::query($query); - if (iDatabase::num_rows($rs_score_display) > 0) { - $score_color_percent = api_get_setting('gradebook_score_display_colorsplit'); - while ($row_score_display = iDatabase::fetch_array($rs_score_display)) { - $score = $row_score_display['score']; - $display = $row_score_display['display']; - foreach ($a_categories as $category_id) { - $ins = "INSERT INTO $dbNameForm.gradebook_score_display(score, display, category_id, score_color_percent) VALUES('$score', '$display', $category_id, '$score_color_percent')"; - iDatabase::query($ins); - } - } - // remove score display with category id = 0 - $del = "DELETE FROM $dbNameForm.gradebook_score_display WHERE category_id = 0"; - iDatabase::query($del); - } - } - - // Now clean the deprecated id_coach field from the session_rel_course table - $m_q_list = get_sql_file_contents('migrate-db-' . $old_file_version . '-' . $new_file_version . '-post.sql', 'main'); - if (count($m_q_list) > 0) { - // Now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - Log::error('Database name ' . $dbNameForm . ' is too long, skipping'); - } elseif (!in_array($dbNameForm, $dblist)) { - Log::error('Database ' . $dbNameForm . ' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - foreach ($m_q_list as $query) { - if ($only_test) { - Log::notice("Database::query($dbNameForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In $dbNameForm, executed: $query"); - } - } - } - } - } - - // Get the stats queries list (s_q_list) - $s_q_list = get_sql_file_contents('migrate-db-' . $old_file_version . '-' . $new_file_version . '-pre.sql', 'stats'); - if (count($s_q_list) > 0) { - // Now use the $s_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbStatsForm) > 40) { - Log::error('Database name ' . $dbStatsForm . ' is too long, skipping'); - } elseif (!in_array($dbStatsForm, $dblist)) { - Log::error('Database ' . $dbStatsForm . ' was not found, skipping'); - } else { - iDatabase::select_db($dbStatsForm); - - foreach ($s_q_list as $query) { - if ($only_test) { - Log::notice("Database::query($dbStatsForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In $dbStatsForm, executed: $query"); - } - if ($res === false) { - Log::error('Error in ' . $query . ': ' . iDatabase::error()); - } - } - } - $tables = iDatabase::get_tables($dbStatsForm); - foreach ($tables as $table) { - $query = "ALTER TABLE `" . $table . "` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"; - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in ' . $query . ': ' . iDatabase::error()); - } - } - $query = "ALTER DATABASE `" . $dbStatsForm . "` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;"; - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in ' . $query . ': ' . iDatabase::error()); - } - - - // chamilo_stat.track_e_attempt table update changing id by id_auto - - $sql = "SELECT exe_id, question_id, course_code, answer FROM $dbStatsForm.track_e_attempt"; - $result = iDatabase::query($sql); - if (iDatabase::num_rows($result) > 0) { - while ($row = iDatabase::fetch_array($result)) { - $course_code = $row['course_code']; - $course_info = api_get_course_info($course_code); - if (empty($course_info)) { - continue; - } - $my_course_db = $course_info['dbName']; - $question_id = $row['question_id']; - $answer = $row['answer']; - $exe_id = $row['exe_id']; - - if(empty($answer)){ - continue; - } - - //getting the type question id - $sql_question = "SELECT type FROM $my_course_db.quiz_question where id = $question_id"; - $res_question = iDatabase::query($sql_question); - $row = iDatabase::fetch_array($res_question); - $type = $row['type']; - - require_once api_get_path(SYS_CODE_PATH) . 'exercice/question.class.php'; - //this type of questions produce problems in the track_e_attempt table - if (in_array($type, array(UNIQUE_ANSWER, MULTIPLE_ANSWER, MATCHING, MULTIPLE_ANSWER_COMBINATION))) { - $sql_question = "SELECT id_auto FROM $my_course_db.quiz_answer where question_id = $question_id and id = $answer"; - $res_question = iDatabase::query($sql_question); - $row = iDatabase::fetch_array($res_question); - if($row){ - $id_auto = $row['id_auto']; - if (!empty($id_auto)) { - $sql = "UPDATE $dbStatsForm.track_e_attempt SET answer = '$id_auto' WHERE exe_id = $exe_id AND question_id = $question_id AND course_code = '$course_code' and answer = $answer "; - iDatabase::query($sql); - } - } - } - } - } - } - } - - - - // Get the user queries list (u_q_list) - $u_q_list = get_sql_file_contents('migrate-db-' . $old_file_version . '-' . $new_file_version . '-pre.sql', 'user'); - if (count($u_q_list) > 0) { - // Now use the $u_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbUserForm) > 40) { - Log::error('Database name ' . $dbUserForm . ' is too long, skipping'); - } elseif (!in_array($dbUserForm, $dblist)) { - Log::error('Database ' . $dbUserForm . ' was not found, skipping'); - } else { - iDatabase::select_db($dbUserForm); - foreach ($u_q_list as $query) { - if ($only_test) { - Log::notice("Database::query($dbUserForm,$query)"); - Log::notice("In $dbUserForm, executed: $query"); - } else { - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in ' . $query . ': ' . iDatabase::error()); - } - } - } - $tables = iDatabase::get_tables($dbUserForm); - foreach ($tables as $table) { - $query = "ALTER TABLE `" . $table . "` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"; - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in ' . $query . ': ' . iDatabase::error()); - } - } - $query = "ALTER DATABASE `" . $dbUserForm . "` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;"; - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in ' . $query . ': ' . iDatabase::error()); - } - } - } - // The SCORM database doesn't need a change in the pre-migrate part - ignore - } - - $prefix = ''; - if ($singleDbForm) { - $prefix = get_config_param('table_prefix'); - } - - // Get the courses databases queries list (c_q_list) - $c_q_list = get_sql_file_contents('migrate-db-' . $old_file_version . '-' . $new_file_version . '-pre.sql', 'course'); - if (count($c_q_list) > 0) { - // Get the courses list - if (strlen($dbNameForm) > 40) { - Log::error('Database name ' . $dbNameForm . ' is too long, skipping'); - } elseif (!in_array($dbNameForm, $dblist)) { - Log::error('Database ' . $dbNameForm . ' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - $res = iDatabase::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code"); - - if ($res === false) { - die('Error while querying the courses list in update_db-1.8.6.2-1.8.7.inc.php'); - } - - if (iDatabase::num_rows($res) > 0) { - $i = 0; - $list = array(); - while ($row = iDatabase::fetch_array($res)) { - $list[] = $row; - $i++; - } - foreach ($list as $row_course) { - // Now use the $c_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (!$singleDbForm) { // otherwise just use the main one - iDatabase::select_db($row_course['db_name']); - } - - foreach ($c_q_list as $query) { - if ($singleDbForm) { - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query); - } - - if ($only_test) { - Log::notice("Database::query(" . $row_course['db_name'] . ",$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In " . $row_course['db_name'] . ", executed: $query"); - } - if ($res === false) { - Log::error('Error in ' . $query . ': ' . iDatabase::error()); - } - } - } - - if (!$singleDbForm) { - $tables = iDatabase::get_tables($row_course['db_name']); - foreach ($tables as $table) { - $query = "ALTER TABLE `" . $table . "` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"; - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in ' . $query . ': ' . iDatabase::error()); - } - } - $query = "ALTER DATABASE `" . $row_course['db_name'] . "` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;"; - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in ' . $query . ': ' . iDatabase::error()); - } - } - $t_student_publication = $row_course['db_name'] . ".student_publication"; - $t_item_property = $row_course['db_name'] . ".item_property"; - - if ($singleDbForm) { - $t_student_publication = "$prefix{$row_course['db_name']}_student_publication"; - $t_item_property = "$prefix{$row_course['db_name']}_item_property"; - } - - $sql_insert_user = "SELECT ref, insert_user_id FROM $t_item_property WHERE tool='work'"; - - $rs_insert_user = iDatabase::query($sql_insert_user); - - if ($rs_insert_user === false) { - Log::error('Could not query insert_user_id table: ' . iDatabase::error()); - } else { - if (iDatabase::num_rows($rs_insert_user) > 0) { - while ($row_ids = iDatabase::fetch_array($rs_insert_user)) { - $user_id = $row_ids['insert_user_id']; - $ref = $row_ids['ref']; - $sql_upd = "UPDATE $t_student_publication SET user_id='$user_id' WHERE id='$ref'"; - iDatabase::query($sql_upd); - } - } - } - - //updating parent_id of the student_publication table - $sql = 'SELECT id, url, parent_id FROM ' . $t_student_publication; - $result = iDatabase::query($sql); - if (iDatabase::num_rows($result) > 0) { - $items = iDatabase::store_result($result); - $directory_list = $file_list = array(); - - foreach ($items as $item) { - $student_slash = substr($item['url'], 0, 1); - //means this is a directory - if ($student_slash == '/') { - $directory_list[$item['id']] = $item['url']; - } else { - // this is a file with no parents - if ($item['parent_id'] == 0) - $file_list [] = $item; - } - } - - if (is_array($file_list) && count($file_list) > 0) { - foreach ($file_list as $file) { - $parent_id = 0; - if (is_array($directory_list) && count($directory_list) > 0) { - foreach ($directory_list as $id => $dir) { - $pos = strpos($file['url'], $dir . '/'); - if ($pos !== false) { - $parent_id = $id; - break; - } - } - } - - if ($parent_id != 0) { - $sql = 'UPDATE ' . $t_student_publication . ' SET parent_id = ' . $parent_id . ' WHERE id = ' . $file['id'] . ''; - iDatabase::query($sql); - } - } - } - } - } - } - } - } - // Get the courses databases queries list (c_q_list) - $c_q_list = get_sql_file_contents('migrate-db-' . $old_file_version . '-' . $new_file_version . '-post.sql', 'course'); - if (count($c_q_list) > 0) { - // Get the courses list - if (strlen($dbNameForm) > 40) { - Log::error('Database name ' . $dbNameForm . ' is too long, skipping'); - } elseif (!in_array($dbNameForm, $dblist)) { - Log::error('Database ' . $dbNameForm . ' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - $res = iDatabase::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); - if ($res === false) { - die('Error while querying the courses list in update_db-1.8.6.2-1.8.7.inc.php'); - } - if (iDatabase::num_rows($res) > 0) { - $i = 0; - while ($row = iDatabase::fetch_array($res)) { - $list[] = $row; - $i++; - } - foreach ($list as $row) { - // Now use the $c_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - $prefix_course = $prefix; - if ($singleDbForm) { - $prefix_course = $prefix . $row['db_name'] . "_"; - } else { - iDatabase::select_db($row['db_name']); - } - - foreach ($c_q_list as $query) { - if ($singleDbForm) { //otherwise just use the main one - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix$2$3", $query); - } - if ($only_test) { - Log::notice("Database::query(" . $row['db_name'] . ",$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In " . $row['db_name'] . ", executed: $query"); - } - } - } - } - } - } - } -} else { - - echo 'You are not allowed here !' . __FILE__; -} diff --git a/main/install/update-db-1.8.7-1.8.8.inc.php b/main/install/update-db-1.8.7-1.8.8.inc.php deleted file mode 100755 index b085a44aa0..0000000000 --- a/main/install/update-db-1.8.7-1.8.8.inc.php +++ /dev/null @@ -1,409 +0,0 @@ -'.get_lang('Error').' ! Chamilo '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').'.

    - '.get_lang('PleasGoBackToStep1').'. -

    - '; - exit (); - } - - $_configuration['db_glue'] = get_config_param('dbGlu'); - - if ($singleDbForm) { - $_configuration['table_prefix'] = get_config_param('courseTablePrefix'); - $_configuration['main_database'] = get_config_param('mainDbName'); - $_configuration['db_prefix'] = get_config_param('dbNamePrefix'); - } - - $dbScormForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbScormForm); - - if (!empty($dbPrefixForm) && strpos($dbScormForm, $dbPrefixForm) !== 0) { - $dbScormForm = $dbPrefixForm.$dbScormForm; - } - - if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) { - $dbScormForm = $dbPrefixForm.'scorm'; - } - - /* Normal upgrade procedure: start by updating main, statistic, user databases */ - - // If this script has been included by index.php, not update_courses.php, so - // that we want to change the main databases as well... - $only_test = false; - $log = 0; - if (defined('SYSTEM_INSTALLATION')) { - - if ($singleDbForm) { - $dbStatsForm = $dbNameForm; - $dbScormForm = $dbNameForm; - $dbUserForm = $dbNameForm; - } - /** - * Update the databases "pre" migration - */ - include_once '../lang/english/trad4all.inc.php'; - - if ($languageForm != 'english') { - // languageForm has been escaped in index.php - include_once '../lang/'.$languageForm.'/trad4all.inc.php'; - } - - // Get the main queries list (m_q_list) - $m_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'main'); - if (count($m_q_list) > 0) { - // Now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - Log::error('Database name '.$dbNameForm.' is too long, skipping'); - } elseif (!in_array($dbNameForm, $dblist)) { - Log::error('Database '.$dbNameForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - foreach ($m_q_list as $query){ - if ($only_test) { - Log::notice("iDatabase::query($dbNameForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In $dbNameForm, executed: $query"); - } - if ($res === false) { - Log::error('Error in '.$query.': '.iDatabase::error()); - } - } - } - } - } - - /* // This fragment of code is not necessary so far. - // Get the main queries list (m_q_list) - $m_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-post.sql', 'main'); - if (count($m_q_list) > 0) { - // Now use the $m_q_list - // We connect to the right DB first to make sure we can use the queries - // without a database name. - if (strlen($dbNameForm) > 40) { - error_log('Database name '.$dbNameForm.' is too long, skipping'); - } elseif (!in_array($dbNameForm,$dblist)) { - error_log('Database '.$dbNameForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - foreach ($m_q_list as $query) { - if ($only_test) { - error_log("iDatabase::query($dbNameForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - error_log("In $dbNameForm, executed: $query"); - } - } - } - } - } - */ - - // Get the stats queries list (s_q_list) - $s_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'stats'); - if (count($s_q_list) > 0) { - // Now use the $s_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbStatsForm) > 40) { - Log::error('Database name '.$dbStatsForm.' is too long, skipping'); - } elseif (!in_array($dbStatsForm, $dblist)){ - Log::error('Database '.$dbStatsForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbStatsForm); - - foreach ($s_q_list as $query) { - if ($only_test) { - Log::notice("iDatabase::query($dbStatsForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In $dbStatsForm, executed: $query"); - } - if ($res === false) { - Log::error('Error in '.$query.': '.iDatabase::error()); - } - } - } - - } - } - - - // Get the user queries list (u_q_list) - $u_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'user'); - if (count($u_q_list) > 0) { - // Now use the $u_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbUserForm) > 40) { - Log::error('Database name '.$dbUserForm.' is too long, skipping'); - } elseif (!in_array($dbUserForm,$dblist)) { - Log::error('Database '.$dbUserForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbUserForm); - foreach ($u_q_list as $query) { - if ($only_test) { - Log::notice("iDatabase::query($dbUserForm,$query)"); - Log::notice("In $dbUserForm, executed: $query"); - } else { - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in '.$query.': '.iDatabase::error()); - } - } - } - } - } - // The SCORM database doesn't need a change in the pre-migrate part - ignore - } - - $prefix = ''; - if ($singleDbForm) { - $prefix = get_config_param ('table_prefix'); - } - - // Get the courses databases queries list (c_q_list) - $c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'course'); - if (count($c_q_list) > 0) { - // Get the courses list - if (strlen($dbNameForm) > 40) { - Log::error('Database name '.$dbNameForm.' is too long, skipping'); - } elseif(!in_array($dbNameForm, $dblist)) { - Log::error('Database '.$dbNameForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - $res = iDatabase::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code"); - - if ($res === false) { die('Error while querying the courses list in update_db-1.8.7.1-1.8.8.inc.php'); } - - if (iDatabase::num_rows($res) > 0) { - $i = 0; - $list = array(); - while ($row = iDatabase::fetch_array($res)) { - $list[] = $row; - $i++; - } - foreach ($list as $row_course) { - // Now use the $c_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (!$singleDbForm) { // otherwise just use the main one - iDatabase::select_db($row_course['db_name']); - } - Log::notice('Course db ' . $row_course['db_name']); - - foreach ($c_q_list as $query) { - if ($singleDbForm) { - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query); - } - - if ($only_test) { - Log::notice("iDatabase::query(".$row_course['db_name'].",$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In ".$row_course['db_name'].", executed: $query"); - } - if ($res === false) { - Log::error('Error in '.$query.': '.iDatabase::error()); - } - } - } - - $table_lp_item_view = $row_course['db_name'].".lp_item_view"; - $table_lp_view = $row_course['db_name'].".lp_view"; - $table_lp_item = $row_course['db_name'].".lp_item"; - - if ($singleDbForm) { - $table_lp_item_view = "$prefix{$row_course['db_name']}_lp_item_view"; - $table_lp_view = "$prefix{$row_course['db_name']}_lp_view"; - $table_lp_item = "$prefix{$row_course['db_name']}_lp_item"; - } - - // Filling the track_e_exercices.orig_lp_item_view_id field in order to have better traceability in exercises included in a LP see #3188 - - $query = "SELECT DISTINCT path as exercise_id, lp_item_id, lp_view_id, user_id, v.lp_id - FROM $table_lp_item_view iv INNER JOIN $table_lp_view v ON v.id = iv.lp_view_id INNER JOIN $table_lp_item i ON i.id = lp_item_id - WHERE item_type = 'quiz'"; - $result = iDatabase::query($query); - - if (iDatabase::num_rows($result) > 0) { - while ($row = iDatabase::fetch_array($result,'ASSOC')) { - $sql = "SELECT exe_id FROM $dbStatsForm.track_e_exercices - WHERE exe_user_id = {$row['user_id']} AND - exe_cours_id = '{$row_course['code']}' AND - exe_exo_id = {$row['exercise_id']} AND - orig_lp_id = {$row['lp_id']} AND - orig_lp_item_id = {$row['lp_item_id']} "; - $sub_result = iDatabase::query($sql); - $exe_list = array(); - while ($sub_row = iDatabase::fetch_array($sub_result,'ASSOC')) { - $exe_list[] = $sub_row['exe_id']; - } - - $sql = "SELECT iv.id, iv.view_count - FROM $table_lp_item_view iv INNER JOIN $table_lp_view v ON v.id = iv.lp_view_id INNER JOIN $table_lp_item i ON i.id = lp_item_id - WHERE item_type = 'quiz' AND user_id = {$row['user_id']} AND path = {$row['exercise_id']} "; - $sub_result = iDatabase::query($sql); - $lp_item_view_id_list = array(); - while ($sub_row = iDatabase::fetch_array($sub_result,'ASSOC')) { - $lp_item_view_id_list[] = $sub_row['id']; - } - $i = 0; - foreach($exe_list as $exe_id) { - $lp_item_view_id = $lp_item_view_id_list[$i]; - $update = "UPDATE $dbStatsForm.track_e_exercices SET orig_lp_item_view_id = '$lp_item_view_id' WHERE exe_id = $exe_id "; - iDatabase::query($update); - $i++; - } - } - } - } - } - - //Adding notifications options - - $sql = "INSERT INTO $dbNameForm.user_field (field_type, field_variable, field_display_text, field_visible, field_changeable, field_default_value) values (4, 'mail_notify_invitation', 'MailNotifyInvitation',1,1,'1') "; - $result = iDatabase::query($sql); - $id = iDatabase::insert_id(); - - $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '1', 'AtOnce',1) "; - $result = iDatabase::query($sql); - $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '8', 'Daily',2) "; - $result = iDatabase::query($sql); - $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '0', 'No',3) "; - $result = iDatabase::query($sql); - - - $sql = "INSERT INTO $dbNameForm.user_field (field_type, field_variable, field_display_text, field_visible, field_changeable, field_default_value) values (4, 'mail_notify_message', 'MailNotifyMessage',1,1,'1')"; - $result = iDatabase::query($sql); - $id = iDatabase::insert_id(); - - $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '1', 'AtOnce',1) "; - $result = iDatabase::query($sql); - $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '8', 'Daily',2) "; - $result = iDatabase::query($sql); - $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '0', 'No',3) "; - $result = iDatabase::query($sql); - - - $sql = "INSERT INTO $dbNameForm.user_field (field_type, field_variable, field_display_text, field_visible, field_changeable, field_default_value) values (4, 'mail_notify_group_message','MailNotifyGroupMessage',1,1,'1') "; - $result = iDatabase::query($sql); - $id = iDatabase::insert_id(); - - $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '1', 'AtOnce',1) "; - $result = iDatabase::query($sql); - $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '8', 'Daily',2) "; - $result = iDatabase::query($sql); - $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '0', 'No',3) "; - $result = iDatabase::query($sql); - - //Fixing table access_url_rel_course if the platform have courses that were created in Dok€os 1.8.5 - - if (!isset($_configuration['multiple_access_urls']) || $_configuration['multiple_access_urls'] == false) { - $sql = "SELECT code FROM $dbNameForm.course"; - $result = iDatabase::query($sql); - while ($row = iDatabase::fetch_array($result)) { - //Adding course to default URL just in case - $sql = "INSERT INTO $dbNameForm.access_url_rel_course SET course_code = '".iDatabase::escape_string($row['code'])."', access_url_id = '1' "; - iDatabase::query($sql); - } - } - } - } - - - - - - - /* // This fragment of code is not necessary so far. - // Get the courses databases queries list (c_q_list) - $c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-post.sql', 'course'); - if (count($c_q_list) > 0) { - // Get the courses list - if (strlen($dbNameForm) > 40) { - Log::error('Database name '.$dbNameForm.' is too long, skipping'); - } elseif (!in_array($dbNameForm, $dblist)) { - Log::error('Database '.$dbNameForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - $res = iDatabase::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); - if ($res === false) { die('Error while querying the courses list in update_db-1.8.7-1.8.8.inc.php'); } - if (iDatabase::num_rows($res) > 0) { - $i = 0; - while ($row = iDatabase::fetch_array($res)) { - $list[] = $row; - $i++; - } - foreach ($list as $row) { - // Now use the $c_q_list - // We connect to the right DB first to make sure we can use the queries - // without a database name - $prefix_course = $prefix; - if ($singleDbForm) { - $prefix_course = $prefix.$row['db_name']."_"; - } else { - iDatabase::select_db($row['db_name']); - } - - foreach($c_q_list as $query) { - if ($singleDbForm) { //otherwise just use the main one - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix$2$3", $query); - } - if ($only_test) { - Log::notice("iDatabase::query(".$row['db_name'].",$query)"); - } else { - $res = iDatabase::query($query); - if ($log) { - Log::notice("In ".$row['db_name'].", executed: $query"); - } - } - } - } - } - } - } - */ -} else { - echo 'You are not allowed here !' . __FILE__; -} diff --git a/main/install/update-db-1.8.8-1.9.0.inc.php b/main/install/update-db-1.8.8-1.9.0.inc.php deleted file mode 100755 index bd0e37b5b3..0000000000 --- a/main/install/update-db-1.8.8-1.9.0.inc.php +++ /dev/null @@ -1,678 +0,0 @@ -'.get_lang('Error').' ! Chamilo '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').'.

    - '.get_lang('PleasGoBackToStep1').'. -

    - '; - exit (); - } - - $_configuration['db_glue'] = get_config_param('dbGlu'); - - if ($singleDbForm) { - $_configuration['table_prefix'] = get_config_param('courseTablePrefix'); - $_configuration['main_database'] = get_config_param('mainDbName'); - $_configuration['db_prefix'] = get_config_param('dbNamePrefix'); - } - - $dbScormForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbScormForm); - - if (!empty($dbPrefixForm) && strpos($dbScormForm, $dbPrefixForm) !== 0) { - $dbScormForm = $dbPrefixForm.$dbScormForm; - } - - if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) { - $dbScormForm = $dbPrefixForm.'scorm'; - } - - /* Normal upgrade procedure: start by updating main, statistic, user databases */ - - // If this script has been included by index.php, not update_courses.php, so - // that we want to change the main databases as well... - $only_test = false; - if (defined('SYSTEM_INSTALLATION')) { - - if ($singleDbForm) { - $dbStatsForm = $dbNameForm; - $dbScormForm = $dbNameForm; - $dbUserForm = $dbNameForm; - } - /** - * Update the databases "pre" migration - */ - include_once '../lang/english/trad4all.inc.php'; - - if ($languageForm != 'english') { - // languageForm has been escaped in index.php - include_once '../lang/'.$languageForm.'/trad4all.inc.php'; - } - - // Get the main queries list (m_q_list) - $m_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'main'); - - if (count($m_q_list) > 0) { - // Now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - Log::error('Database name '.$dbNameForm.' is too long, skipping'); - } elseif (!in_array($dbNameForm, $dblist)) { - Log::error('Database '.$dbNameForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - foreach ($m_q_list as $query){ - if ($only_test) { - Log::notice("iDatabase::query($dbNameForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in '.$query.': '.iDatabase::error()); - } - } - } - } - } - - if (INSTALL_TYPE_UPDATE == 'update') { - - //Migrate classes to the new classes (usergroups) - - $sql = "SELECT selected_value FROM $dbNameForm.settings_current WHERE variable='use_session_mode' "; - $result = iDatabase::query($sql); - $result = Database::fetch_array($result); - $session_mode = $result['selected_value']; - - if ($session_mode == 'true') { - - $sql = "UPDATE $dbNameForm.settings_current SET selected_value = 'true' WHERE variable='use_session_mode' "; - $result = iDatabase::query($sql); - - $sql = "SELECT * FROM $dbNameForm.class"; - $result = iDatabase::query($sql); - $count = 0; - $new_table = "$dbNameForm.usergroup"; - $classes_added = 0; - $mapping_classes = array(); - if (Database::num_rows($result)) { - while($row = iDatabase::fetch_array($result, 'ASSOC')) { - $old_id = $row['id']; - unset($row['id']); - unset($row['code']); - $new_user_group_id = Database::insert($new_table, $row); - $mapping_classes[$old_id] = $new_user_group_id; - if (is_numeric($id)) { - $classes_added ++; - } - } - } - - $sql = "SELECT * FROM $dbNameForm.class_user"; - $result = iDatabase::query($sql); - $new_table = "$dbNameForm.usergroup_rel_user"; - if (Database::num_rows($result)) { - while ($row = iDatabase::fetch_array($result, 'ASSOC')) { - $values = array('usergroup_id' => $mapping_classes[$row['class_id']], - 'user_id' => $row['user_id']); - iDatabase::insert($new_table, $values); - } - } - - $sql = "SELECT * FROM $dbNameForm.course_rel_class"; - $result = iDatabase::query($sql); - $new_table = "$dbNameForm.usergroup_rel_course"; - - if (Database::num_rows($result)) { - while ($row = iDatabase::fetch_array($result, 'ASSOC')) { - $course_code = $row['course_code']; - $course_code = addslashes($course_code); - $sql_course = "SELECT id from $dbNameForm.course WHERE code = '$course_code'"; - $result_course = iDatabase::query($sql_course); - $result_course = Database::fetch_array($result_course); - $course_id = $result_course['id']; - $values = array('usergroup_id' => $mapping_classes[$row['class_id']], - 'course_id' => $course_id); - iDatabase::insert($new_table, $values); - } - } - - Log::notice("#classes added $classes_added"); - } - } - - - // Get the stats queries list (s_q_list) - $s_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'stats'); - if (count($s_q_list) > 0) { - // Now use the $s_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbStatsForm) > 40) { - Log::error('Database name '.$dbStatsForm.' is too long, skipping'); - } elseif (!in_array($dbStatsForm, $dblist)){ - Log::error('Database '.$dbStatsForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbStatsForm); - - foreach ($s_q_list as $query) { - if ($only_test) { - Log::notice("iDatabase::query($dbStatsForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in '.$query.': '.iDatabase::error()); - } - } - } - } - } - - //Moving Stats DB to the main DB - - $stats_table = array( - "track_c_browsers", - "track_c_countries", - "track_c_os", - "track_c_providers", - "track_c_referers", - "track_e_access", - "track_e_attempt", - "track_e_attempt_recording", - "track_e_course_access", - "track_e_default", - "track_e_downloads", - "track_e_exercices", - "track_e_hotpotatoes", - "track_e_hotspot", - "track_e_item_property", - "track_e_lastaccess", - "track_e_links", - "track_e_login", - "track_e_online", - "track_e_open", - "track_e_uploads", - "track_stored_values", - "track_stored_values_stack", - ); - - if ($dbNameForm != $dbStatsForm) { - iDatabase::select_db($dbStatsForm); - foreach ($stats_table as $stat_table) { - $sql = "ALTER TABLE $dbStatsForm.$stat_table RENAME $dbNameForm.$stat_table"; - iDatabase::query($sql); - } - iDatabase::select_db($dbNameForm); - } - - // Get the user queries list (u_q_list) - $u_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'user'); - - if (count($u_q_list) > 0) { - // Now use the $u_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbUserForm) > 40) { - Log::error('Database name '.$dbUserForm.' is too long, skipping'); - } elseif (!in_array($dbUserForm,$dblist)) { - Log::error('Database '.$dbUserForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbUserForm); - foreach ($u_q_list as $query) { - if ($only_test) { - Log::notice("iDatabase::query($dbUserForm,$query)"); - Log::notice("In $dbUserForm, executed: $query"); - } else { - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in '.$query.': '.iDatabase::error()); - } - } - } - } - } - - //Moving user database to the main database - $users_tables = array( - "personal_agenda", - "personal_agenda_repeat", - "personal_agenda_repeat_not", - "user_course_category" - ); - - if ($dbNameForm != $dbUserForm) { - iDatabase::select_db($dbUserForm); - foreach ($users_tables as $table) { - $sql = "ALTER TABLE $dbUserForm.$table RENAME $dbNameForm.$table"; - iDatabase::query($sql); - } - iDatabase::select_db($dbNameForm); - } - } - - //Adding admin user in the access_url_rel_user table - $sql = "SELECT user_id FROM admin WHERE user_id = 1"; - $result = iDatabase::query($sql); - $has_user_id = Database::num_rows($result) > 0; - - $sql = "SELECT * FROM access_url_rel_user WHERE user_id = 1 AND access_url_id = 1"; - $result = iDatabase::query($sql); - $has_entry = Database::num_rows($result) > 0; - - if ($has_user_id && !$has_entry) { - $sql = "INSERT INTO access_url_rel_user VALUES(1, 1)"; - iDatabase::query($sql); - } - - global $_configuration; - - $prefix = ''; - if ($singleDbForm) { - $prefix = get_config_param('table_prefix'); - } - - Log::notice("Database prefix: '$prefix'"); - - // Get the courses databases queries list (c_q_list) - $c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'course'); - Log::notice('Starting migration: '.$old_file_version.' - '.$new_file_version); - - if (count($c_q_list) > 0) { - // Get the courses list - if (strlen($dbNameForm) > 40) { - Log::error('Database name '.$dbNameForm.' is too long, skipping'); - } elseif(!in_array($dbNameForm, $dblist)) { - Log::error('Database '.$dbNameForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - $res = iDatabase::query("SELECT id, code, db_name, directory, course_language, id as real_id FROM course WHERE target_course_code IS NULL ORDER BY code"); - - if ($res === false) { die('Error while querying the courses list in update_db-1.8.8-1.9.0.inc.php'); } - - $errors = array(); - - if (iDatabase::num_rows($res) > 0) { - $i = 0; - $list = array(); - while ($row = iDatabase::fetch_array($res)) { - $list[] = $row; - $i++; - } - - foreach ($list as $row_course) { - if (!$singleDbForm) { // otherwise just use the main one - iDatabase::select_db($row_course['db_name']); - } - Log::notice('Course db ' . $row_course['db_name']); - - // Now use the $c_q_list - foreach ($c_q_list as $query) { - if ($singleDbForm) { - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query); - } - if ($only_test) { - Log::notice("iDatabase::query(".$row_course['db_name'].",$query)"); - } else { - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in '.$query.': '.iDatabase::error()); - } - } - } - - $work_table = $row_course['db_name'].".student_publication"; - $item_table = $row_course['db_name'].".item_property"; - - if ($singleDbForm) { - $work_table = "$prefix{$row_course['db_name']}_student_publication"; - $item_table = $row_course['db_name'].".item_property"; - } - - if (!$singleDbForm) { - // otherwise just use the main one - iDatabase::select_db($row_course['db_name']); - } else { - iDatabase::select_db($dbNameForm); - } - - - /* Start work fix */ - - /* Fixes the work subfolder and work with no parent issues */ - - //1. Searching for works with no parents - $sql = "SELECT * FROM $work_table WHERE parent_id = 0 AND filetype ='file'"; - $result = Database::query($sql); - - $work_list = array(); - - if (Database::num_rows($result)) { - while ($row = Database::fetch_array($result, 'ASSOC')) { - $work_list[] = $row; - } - } - - $today = api_get_utc_datetime(); - $user_id = 1; - require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php'; - - $sys_course_path = api_get_path(SYS_COURSE_PATH); - $course_dir = $sys_course_path . $row_course['directory']; - $base_work_dir = $course_dir . '/work'; - - //2. Looping if there are works with no parents - if (!empty($work_list)) { - $work_dir_created = array(); - - foreach ($work_list as $work) { - $session_id = intval($work['session_id']); - $group_id = intval($work['post_group_id']); - $work_key = $session_id.$group_id; - - //Only create the folder once - if (!isset($work_dir_created[$work_key])) { - - $dir_name = "default_tasks_".$group_id."_".$session_id; - - //2.1 Creating a new work folder - $sql = "INSERT INTO $work_table SET - url = 'work/".$dir_name."', - title = 'Tasks', - description = '', - author = '', - active = '1', - accepted = '1', - filetype = 'folder', - post_group_id = '$group_id', - sent_date = '".$today."', - parent_id = '0', - qualificator_id = '', - user_id = '".$user_id."'"; - iDatabase::query($sql); - - $id = Database::insert_id(); - //2.2 Adding the folder in item property - if ($id) { - //api_item_property_update($row_course, 'work', $id, 'DirectoryCreated', $user_id, $group_id, null, 0, 0 , $session_id); - $sql = "INSERT INTO $item_table (tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id, to_group_id, visibility, id_session) - VALUES ('work','$id','$today', '$user_id', '$today', 'DirectoryCreated','$user_id', '$group_id', '1', '$session_id')"; - - iDatabase::query($sql); - $work_dir_created[$work_key] = $id; - create_unexisting_work_directory($base_work_dir, $dir_name); - $final_dir = $base_work_dir.'/'.$dir_name; - } - } else { - $final_dir = $base_work_dir.'/'.$dir_name; - } - - //2.3 Updating the url - if (!empty($work_dir_created[$work_key])) { - $parent_id = $work_dir_created[$work_key]; - $new_url = "work/".$dir_name.'/'.basename($work['url']); - $new_url = Database::escape_string($new_url);$sql = "UPDATE $work_table SET url = '$new_url', parent_id = $parent_id, contains_file = '1' WHERE id = {$work['id']}"; - iDatabase::query($sql); - if (is_dir($final_dir)) { - rename($course_dir.'/'.$work['url'], $course_dir.'/'.$new_url); - } - } - } - } - - //3.0 Moving subfolders to the root - $sql = "SELECT * FROM $work_table WHERE parent_id <> 0 AND filetype ='folder'"; - $result = Database::query($sql); - $work_list = array(); - - if (Database::num_rows($result)) { - while ($row = Database::fetch_array($result, 'ASSOC')) { - $work_list[] = $row; - } - if (!empty($work_list)) { - foreach ($work_list as $work_folder) { - $folder_id = $work_folder['id']; - check_work($folder_id, $work_folder['url'], $work_table, $base_work_dir); - } - } - } - - /* End of work fix */ - - //Course tables to be migrated - $table_list = array( - 'announcement', - 'announcement_attachment', - 'attendance', - 'attendance_calendar', - 'attendance_result', - 'attendance_sheet', - 'attendance_sheet_log', - 'blog', - 'blog_attachment', - 'blog_comment', - 'blog_post', - 'blog_rating', - 'blog_rel_user', - 'blog_task', - 'blog_task_rel_user', - 'calendar_event', - 'calendar_event_attachment', - 'calendar_event_repeat', - 'calendar_event_repeat_not', - 'chat_connected', - 'course_description', - 'course_setting', - 'document', - 'dropbox_category', - 'dropbox_feedback', - 'dropbox_file', - 'dropbox_person', - 'dropbox_post', - 'forum_attachment', - 'forum_category', - 'forum_forum', - 'forum_mailcue', - 'forum_notification', - 'forum_post', - 'forum_thread', - 'forum_thread_qualify', - 'forum_thread_qualify_log', - 'glossary', - 'group_category', - 'group_info', - 'group_rel_tutor', - 'group_rel_user', - 'item_property', - 'link', - 'link_category', - 'lp', - 'lp_item', - 'lp_item_view', - 'lp_iv_interaction', - 'lp_iv_objective', - 'lp_view', - 'notebook', - 'metadata', - 'online_connected', - 'online_link', - 'permission_group', - 'permission_task', - 'permission_user', - 'quiz', - 'quiz_answer', - 'quiz_question', - 'quiz_question_option', - 'quiz_rel_question', - 'resource', - 'role', - 'role_group', - 'role_permissions', - 'role_user', - 'student_publication', - 'student_publication_assignment', - 'survey', - 'survey_answer', - 'survey_group', - 'survey_invitation', - 'survey_question', - 'survey_question_option', - 'thematic', - 'thematic_advance', - 'thematic_plan', - 'tool', - 'tool_intro', - 'userinfo_content', - 'userinfo_def', - 'wiki', - 'wiki_conf', - 'wiki_discuss', - 'wiki_mailcue' - ); - - Log::notice('<<<------- Loading DB course '.$row_course['db_name'].' -------->>'); - //Install::message('<<<------- Loading DB course '.$row_course['db_name'].' -------->>'); - - $count = $old_count = 0; - foreach ($table_list as $table) { - $just_table_name = $table; - $old_table = $row_course['db_name'].".".$table; - - if ($singleDbForm) { - $old_table = "$prefix{$row_course['db_name']}_".$table; - $just_table_name = "$prefix{$row_course['db_name']}_".$table; - } - - $course_id = $row_course['id']; - $new_table = DB_COURSE_PREFIX.$table; - - //Use the old database (if this is the case) - - if (!$singleDbForm) { - // otherwise just use the main one - iDatabase::select_db($row_course['db_name']); - } else { - iDatabase::select_db($dbNameForm); - } - - //Count of rows - $sql = "SHOW TABLES LIKE '$just_table_name'"; - $result = iDatabase::query($sql); - - if (Database::num_rows($result)) { - - $sql = "SELECT count(*) FROM $old_table"; - $result = iDatabase::query($sql); - - $old_count = 0; - if ($result) { - $row = iDatabase::fetch_row($result); - $old_count = $row[0]; - } else { - Log::error("Count(*) in table $old_table failed"); - } - - Log::notice("# rows in $old_table: $old_count"); - - $sql = "SELECT * FROM $old_table"; - $result = iDatabase::query($sql); - - $count = 0; - - /* Loads the main database */ - iDatabase::select_db($dbNameForm); - - while($row = iDatabase::fetch_array($result, 'ASSOC')) { - $row['c_id'] = $course_id; - $id = iDatabase::insert($new_table, $row); - if (is_numeric($id)) { - $count++; - } else { - $errors[$old_table][] = $row; - } - } - Log::notice("#rows inserted in $new_table: $count"); - - if ($old_count != $count) { - Log::error("ERROR count of new and old table doesn't match: $old_count - $new_table"); - Log::error("Check the results: "); - Log::error(print_r($errors, 1)); - error_log(print_r($errors, 1)); - } - } else { - Log::error("Seems that the table $old_table doesn't exists "); - } - } - Log::notice('<<<------- end -------->>'); - } - } - } - } -} else { - echo 'You are not allowed here !' . __FILE__; -} - -function check_work($folder_id, $work_url, $work_table, $base_work_dir) { - $uniq_id = uniqid(); - //Looking for subfolders - $sql = "SELECT * FROM $work_table WHERE parent_id = $folder_id AND filetype ='folder'"; - $result = Database::query($sql); - - if (Database::num_rows($result)) { - while ($row = Database::fetch_array($result, 'ASSOC')) { - check_work($row['id'], $row['url'], $work_table, $base_work_dir); - } - } - - //Moving the subfolder in the root - $new_url = '/'.basename($work_url).'_mv_'.$uniq_id; - $new_url = Database::escape_string($new_url); - $sql = "UPDATE $work_table SET url = '$new_url', parent_id = 0 WHERE id = $folder_id"; - iDatabase::query($sql); - - if (is_dir($base_work_dir.$work_url)) { - rename($base_work_dir.$work_url, $base_work_dir.$new_url); - - //Rename all files inside the folder - $sql = "SELECT * FROM $work_table WHERE parent_id = $folder_id AND filetype ='file'"; - $result = Database::query($sql); - - if (Database::num_rows($result)) { - while ($row = Database::fetch_array($result, 'ASSOC')) { - $new_url = "work".$new_url.'/'.basename($row['url']); - $new_url = Database::escape_string($new_url); - $sql = "UPDATE $work_table SET url = '$new_url', parent_id = $folder_id, contains_file = '1' WHERE id = {$row['id']}"; - iDatabase::query($sql); - } - } - } -} diff --git a/main/install/update-db-1.9.0-1.10.0.inc.php b/main/install/update-db-1.9.0-1.10.0.inc.php deleted file mode 100644 index 54fa41576e..0000000000 --- a/main/install/update-db-1.9.0-1.10.0.inc.php +++ /dev/null @@ -1,199 +0,0 @@ -'.get_lang('Error').' ! ' - .'Chamilo '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').' - .

    ' - .get_lang('PleasGoBackToStep1') - .'

    ' - .'' - .'

    ' - .''; - exit (); - } - - $_configuration['db_glue'] = get_config_param('dbGlu'); - - if ($singleDbForm) { - $_configuration['table_prefix'] = get_config_param('courseTablePrefix'); - $_configuration['main_database'] = get_config_param('mainDbName'); - $_configuration['db_prefix'] = get_config_param('dbNamePrefix'); - } - - /* Normal upgrade procedure: start by updating the main database */ - - // If this script has been included by index.php, not update_courses.php, so - // that we want to change the main databases as well... - $onlyTest = false; - if (defined('SYSTEM_INSTALLATION')) { - - /** - * Update the databases "pre" migration - */ - include_once '../lang/english/trad4all.inc.php'; - - if ($languageForm != 'english') { - // languageForm has been escaped in index.php - include_once '../lang/' . $languageForm . '/trad4all.inc.php'; - } - - // Get the main queries list (m_q_list) - $sqlFile = 'migrate-db-' . $oldFileVersion . '-' . $newFileVersion . '-pre.sql'; - $mainQueriesList = get_sql_file_contents($sqlFile, 'main'); - - if (count($mainQueriesList) > 0) { - // Now use the $mainQueriesList - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - Log::error('Database name ' . $dbNameForm . ' is too long, skipping'); - } elseif (!in_array($dbNameForm, $dblist)) { - Log::error('Database ' . $dbNameForm . ' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - foreach ($mainQueriesList as $query) { - if ($onlyTest) { - Log::notice("iDatabase::query($dbNameForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in ' . $query . ': ' . iDatabase::error()); - } - } - } - } - } - - if (INSTALL_TYPE_UPDATE == 'update') { - // Updating track tables with c_id -> moved to migrate-db - - } - } - - $prefix = ''; - if ($singleDbForm) { - $prefix = get_config_param('table_prefix'); - } - - Log::notice("Database prefix: '$prefix'"); - - // Get the courses databases queries list (c_q_list) - - $sqlFile = 'migrate-db-'.$oldFileVersion.'-'.$newFileVersion.'-pre.sql'; - $courseQueriesList = get_sql_file_contents($sqlFile, 'course'); - Log::notice('Starting migration: '.$oldFileVersion.' - '.$newFileVersion); - - if (count($courseQueriesList) > 0) { - // Get the courses list - if (strlen($dbNameForm) > 40) { - Log::error('Database name '.$dbNameForm.' is too long, skipping'); - } elseif (!in_array($dbNameForm, $dblist)) { - Log::error('Database '.$dbNameForm.' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - $res = iDatabase::query( - "SELECT id, code, db_name, directory, course_language, id as real_id " - ." FROM course WHERE target_course_code IS NULL ORDER BY code" - ); - - if ($res === false) { - die('Error while querying the courses list in update_db-1.9.0-1.10.0.inc.php'); - } - $errors = array(); - - if (iDatabase::num_rows($res) > 0) { - $i = 0; - $list = array(); - while ($row = iDatabase::fetch_array($res)) { - $list[] = $row; - $i++; - } - - foreach ($list as $rowCourse) { - if (!$singleDbForm) { // otherwise just use the main one - iDatabase::select_db($rowCourse['db_name']); - } - Log::notice('Course db ' . $rowCourse['db_name']); - - // Now use the $c_q_list - foreach ($courseQueriesList as $query) { - if ($singleDbForm) { - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$rowCourse['db_name']}_$2$3", $query); - } - if ($onlyTest) { - Log::notice("iDatabase::query(".$rowCourse['db_name'].",$query)"); - } else { - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in '.$query.': '.iDatabase::error()); - } - } - } - - Log::notice('<<<------- end -------->>'); - } - } - } - } - - // Get the main queries *POST* list (m_q_list) - $sqlFile = 'migrate-db-' . $oldFileVersion . '-' . $newFileVersion . '-post.sql'; - $mainQueriesList = get_sql_file_contents($sqlFile, 'main'); - - if (count($mainQueriesList) > 0) { - // Now use the $mainQueriesList - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - if (strlen($dbNameForm) > 40) { - Log::error('Database name ' . $dbNameForm . ' is too long, skipping'); - } elseif (!in_array($dbNameForm, $dblist)) { - Log::error('Database ' . $dbNameForm . ' was not found, skipping'); - } else { - iDatabase::select_db($dbNameForm); - foreach ($mainQueriesList as $query) { - if ($onlyTest) { - Log::notice("iDatabase::query($dbNameForm,$query)"); - } else { - $res = iDatabase::query($query); - if ($res === false) { - Log::error('Error in ' . $query . ': ' . iDatabase::error()); - } - } - } - } - } - -} else { - echo 'You are not allowed here !' . __FILE__; -} diff --git a/main/install/update-db-scorm-1.6.x-1.8.0.inc.php b/main/install/update-db-scorm-1.6.x-1.8.0.inc.php deleted file mode 100755 index 758c374d65..0000000000 --- a/main/install/update-db-scorm-1.6.x-1.8.0.inc.php +++ /dev/null @@ -1,1289 +0,0 @@ - - */ - -/** - * Include mandatory libraries - */ -Log::notice('Entering file'); - -if (!defined('SYSTEM_INSTALLATION')) { - echo 'You are not allowed here !' . __FILE__; - return; -} - -require_once api_get_path(LIBRARY_PATH).'document.lib.php'; -require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; //check_name_exists() -require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php'; -require_once api_get_path(SYS_CODE_PATH).'newscorm/scorm.class.php'; - -$loglevel = 0; - -// Get table prefix from $prefix variable declared in update-db-....inc.php -$table_prefix = $prefix; -$sys_course_path = $pathForm.'courses/'; -$upd_course_path = $proposedUpdatePath.'courses/'; - -function my_get_time($time) { - $matches = array(); - if (preg_match('/(\d{1,4}):(\d{2})(:(\d{2})(\.\d*)?)?/', $time, $matches)) { - if (count($matches) == 3) { - return ($matches[1] * 60) + ($matches[2]); - } else { - return ($matches[1] * 3600) + ($matches[2] * 60) + ($matches[4]); - } - } - else return 0; -} - -// Open log file -$fh = fopen(api_get_path(SYS_ARCHIVE_PATH).'newscorm_'.time().'.log', 'w'); -$fh_revert = fopen(api_get_path(SYS_ARCHIVE_PATH).'newscorm_'.time().'_revert.log', 'w'); -$fh_res = fopen(api_get_path(SYS_ARCHIVE_PATH).'newscorm_'.time().'_res.log', 'w'); -fwrite($fh, "-- Recording course homepages links changes to enable reverting\n"); -fwrite($fh_revert, "-- Recording reverted course homepages links changes to enable reverting\n"); -fwrite($fh_res, "-- Recording resulting course homepages links changes\n"); - -//echo ""; - -/** - * New tables definition: - */ -$new_lp = 'lp'; -$new_lp_view = 'lp_view'; -$new_lp_item = 'lp_item'; -$new_lp_item_view = 'lp_item_view'; -$new_lp_type = 'lp_type'; - -$max_dsp_lp = 0; -$courses_list = array(); -$courses_id_list = array(); -$courses_id_full_table_prefix_list = array(); -$courses_dir_list = array(); - -Database::select_db($dbNameForm); - -$sql = "SELECT * FROM course"; -$res = Database::query($sql); - -while ($row = Database::fetch_array($res)) { - $course_pref = $table_prefix; - if ($singleDbForm) { - $dbname = $_configuration['main_database'].'.'.$course_pref.$row['db_name'].'_'; - } else { - $dbname = $row['db_name'].'.'.$course_pref; - } - $courses_list[] = $row['db_name']; - $courses_id_list[$row['code']] = $row['db_name']; - $courses_id_full_table_prefix_list[$row['code']] = $dbname; - $courses_dir_list[$row['code']] = $row['directory']; -} - -if ($loglevel > 0) { Log::notice("Tables created/deleted for all courses"); } - -/** - * The migration needs to take all data from the original learnpath tables and add them to the new - * lp, lp_view, lp_item and lp_item_view tables - */ -// MIGRATING LEARNPATHS -// Test only one course -foreach ($courses_id_full_table_prefix_list as $course_code => $db) { - if (strlen($courses_id_list[$course_code]) > 40) { - Log::error('Database '.$courses_id_list[$course_code].' is too long, skipping'); - continue; - } - - $incoherences = 0; - if ($loglevel > 0) { Log::notice("Now starting migration of learnpath tables from $db database..."); } - $lp_doc = $db.TABLE_DOCUMENT; - $lp_main = $db.TABLE_LEARNPATH_MAIN; - $lp_ids = array(); - $lp_user = $db.TABLE_LEARNPATH_USER; - $lp_users = array(); - $lp_chap = $db.TABLE_LEARNPATH_CHAPTER; - $parent_chaps = array(); - $lp_chap_items = array(); - $ordered_chaps = array(); - $lp_item = $db.TABLE_LEARNPATH_ITEM; - $lp_items = array(); - $lp_ordered_items = array(); - $parent_lps = array(); //keeps a track of chapter's learnpath ids - $my_new_lp = $db.$new_lp; - $my_new_lp_item = $db.$new_lp_item; - $my_new_lp_view = $db.$new_lp_view; - $my_new_lp_item_view = $db.$new_lp_item_view; - - // Migrate learnpaths - $sql_test = "SELECT * FROM $my_new_lp"; - $res_test = Database::query($sql_test); - $sql_lp = "SELECT * FROM $lp_main"; - if ($loglevel > 1) { Log::notice("$sql_lp"); } - $res_lp = Database::query($sql_lp); - if (!$res_lp or !$res_test) { - if ($loglevel > 1) { - Log::error("+++Problem querying DB $lp_main+++ skipping (".Database::error().")"); - if (!$res_test) { - Log::error("This might be due to no existing table in the destination course"); - } - } - continue; - } - $dsp_ord = 1; - while ($row = Database::fetch_array($res_lp)) { - //echo "Treating lp id : ".$row['learnpath_id']."
    \n"; - $ins_lp_sql = "INSERT INTO $my_new_lp (lp_type,name,description,display_order,content_maker) " . - "VALUES (1," . - "'".Database::escape_string($row['learnpath_name'])."'," . - "'".Database::escape_string($row['learnpath_description'])."',$dsp_ord,'Dokeos')"; - $ins_lp_res = Database::query($ins_lp_sql); - $in_id = Database::insert_id(); - if (!$in_id) die('Could not insert lp: '.$ins_lp_sql); - $lp_ids[$row['learnpath_id']] = $in_id; - $dsp_ord++; - $max_dsp_lp = $dsp_ord; - } - //echo "
    lp_ids:".print_r($lp_ids,true)."
    \n"; - - - // MIGRATING LEARNPATH CHAPTERS - $sql_lp_chap = "ALTER TABLE $lp_chap ADD INDEX ( parent_chapter_id, display_order )"; - $res_lp_chap = Database::query($sql_lp_chap); - - $sql_lp_chap = "SELECT * FROM $lp_chap ORDER BY parent_chapter_id, display_order"; - //echo "$sql_lp_chap
    \n"; - $res_lp_chap = Database::query($sql_lp_chap); - while ($row = Database::fetch_array($res_lp_chap)) { - //echo "Treating chapter id : ".$row['id']."
    \n"; - - //TODO: Build path for this chapter (although there is no real path for any chapter) - //TODO: Find out how to calculate the "next_item_id" with the "ordre" field - $my_lp_item = $my_new_lp_item; - $myname = Database::escape_string($row['chapter_name']); - $mydesc = Database::escape_string($row['chapter_description']); - $ins_lp_sql = "INSERT INTO $my_new_lp_item (" . - "lp_id," . - "item_type," . - "title," . - "description," . - "path, " . - "display_order, " . - "next_item_id) " . - "VALUES (" . - "'".$lp_ids[$row['learnpath_id']]."'," . //insert new learnpath ID - "'dokeos_chapter'," . - "'".$myname."'," . - "'".$mydesc."'," . - "''," . - $row['display_order'].", " . - "123456" . - ")"; - //echo $ins_lp_sql."
    \n"; - $ins_res = Database::query($ins_lp_sql); - $in_id = Database::insert_id(); - //echo "  Inserted item $in_id
    \n"; - if (!$in_id) die('Could not insert lp: '.$ins_sql); - $parent_chaps[$row['id']] = $row['parent_chapter_id']; - $lp_chap_items[$row['id']] = $in_id; - $parent_lps[$row['id']] = $row['learnpath_id']; - $ordered_chaps[$row['parent_chapter_id']][$row['display_order']] = $in_id; - $lp_chaps_list[$row['learnpath_id']][] = $in_id; - } - //echo "
    parent_lps:".print_r($parent_lps,true)."
    \n"; - - // Now one loop to update the parent_chapter_ids - foreach ($parent_chaps as $old_chap => $old_parent_chap) { - if ($old_parent_chap != 0) { - $new_chap = $lp_chap_items[$old_chap]; - $new_parent = $lp_chap_items[$old_parent_chap]; - if (isset($new_chap) && $new_chap != '' && isset($new_parent) && $new_parent != '') { - $sql_par_chap = "UPDATE $my_new_lp_item " . - "SET parent_item_id = $new_parent " . - "WHERE id = $new_chap"; - $res_par_chap = Database::query($sql_par_chap); - } - } - } - unset($parent_chaps); - - // Now one loop to set the next_item_id and the previous_item_id - foreach ($ordered_chaps as $parent_chap) { - $last = 0; - foreach ($ordered_chaps[$parent_chap] as $order => $new_id) { - $sql_upd_chaps = "UPDATE $my_new_lp_item " . - "SET previous_item_id = $last " . - "WHERE id = $new_id"; - $res_upd_chaps = Database::query($sql_upd_chaps); - - $next = 0; - if (!empty($ordered_chaps[$parent_chap][$order + 1])) { - $next = $ordered_chaps[$parent_chap][$order + 1]; - } - $sql_upd_chaps = "UPDATE $my_new_lp_item " . - "SET next_item_id = $next " . - "WHERE id = $new_id"; - $res_upd_chaps = Database::query($sql_upd_chaps); - $last = $new_id; - } - } - unset($ordered_chaps); - - // Migrate learnpath_items - // TODO: Define this array thanks to types defined in the learnpath_building scripts - // TODO: Set order correctly - $type_trans = array( - 'document' => TOOL_DOCUMENT, - 'exercise' => TOOL_QUIZ, - 'forum' => TOOL_FORUM, - 'Agenda' => TOOL_CALENDAR_EVENT, - 'Ad_Valvas' => TOOL_ANNOUNCEMENT, - 'Link' => TOOL_LINK, - 'Link _blank' => TOOL_LINK, - 'Exercise' => TOOL_QUIZ, - 'HotPotatoes'=> 'HotPotatoes', - 'Forum' => TOOL_FORUM, - 'Thread' => TOOL_THREAD, - 'Topic' => TOOL_THREAD, - 'Post' => TOOL_POST, - 'Document' => TOOL_DOCUMENT, - 'Assignments'=> 'Assignments', - 'Dropbox' => TOOL_DROPBOX, - 'Introduction_text'=> 'Introduction_text', - 'Course_description' => TOOL_COURSE_DESCRIPTION, - 'Groups' => TOOL_GROUP, - 'Users' => TOOL_USER, - - //'chapter' => 'dokeos_chapter', Chapters should all be in learnpath_chapter, no matter the nesting level - - ); - - // MIGRATING LEARNPATH ITEMS - $sql_lp_item = "ALTER TABLE $lp_item ADD INDEX ( chapter_id, display_order)"; - $res_lp_item = Database::query($sql_lp_item); - $sql_lp_item = "SELECT * FROM $lp_item ORDER BY chapter_id, display_order"; - //echo "$sql_lp_item
    \n"; - $res_lp_item = Database::query($sql_lp_item); - while ($row = Database::fetch_array($res_lp_item)) { - //echo "Treating chapter ".$row['chapter_id'].", item ".$row['id']."
    \n"; - $type = $type_trans[$row['item_type']]; - $ref = $row['item_id']; - //TODO: Build item path - //TODO: Calculate "next_item_id" with the "ordre" field - // Prepare prereqs - // Prerequisites in Dokeos 1.6 is only authorised on previous items, so - // We know that we are gonna talk about an item that has already been passed - // through here - if none found, print message - $prereq_id = ''; - if (!empty($row['prereq_id'])) { - switch ($row['prereq_type']) { - case 'c': - // chapter-type prereq - $prereq_id = $lp_chap_items[$row['prereq_id']]; - if (empty($prereq_id) && $loglevel > 1) { Log::error("Could not find prereq chapter ".$row['prereq_id']); } - break; - case 'i': - default: - // item type prereq - $prereq_id = $lp_items[$parent_lps[$row['chapter_id']]][$row['prereq_id']]; - if (empty($prereq_id) && $loglevel > 1) { Log::error("Could not find prereq item ".$row['prereq_id']); } - break; - } - } - $my_parent_id = 0; - if (isset($lp_chap_items[$row['chapter_id']])) { - $my_parent_id = $lp_chap_items[$row['chapter_id']]; - } - $title = ''; - if (empty($row['title']) && $type == 'Document' && !empty($row['item_id'])) { - $my_sql_doctitle = "SELECT title FROM $lp_doc WHERE id = ".$row['item_id']; - $my_res_doctitle = Database::query($my_sql_doctitle); - if ($row_doctitle = Database::fetch_array($my_res_doctitle)) { - $title = $row_doctitle['title']; - } else { - $title = '-'; - } - } else { - $title = $row['title']; - } - if (isset($lp_ids[$parent_lps[$row['chapter_id']]])) { - // If there is a parent learnpath - $ins_lp_sql = "INSERT INTO $my_new_lp_item (" . - "lp_id," . - "item_type," . - "ref, " . - "title," . - "description," . - "path, " . - "parent_item_id," . - "prerequisite," . - "display_order" . - ") VALUES (" . - "'".$lp_ids[$parent_lps[$row['chapter_id']]]."'," . // Insert new learnpath ID - "'$type'," . - "'$ref', " . - "'".Database::escape_string($row['title'])."'," . - "'".Database::escape_string($row['description'])."'," . - "'$ref'," . - "".$my_parent_id."," . - "'$prereq_id'," . - $row['display_order']." " . - ")"; - $ins_res = Database::query($ins_lp_sql); - $in_id = Database::insert_id(); - //echo "  Inserted item $in_id (".$row['title'].")
    \n"; - if (!$in_id) die('Could not insert lp_item: '.$ins_sql); - $lp_items[$parent_lps[$row['chapter_id']]][$row['id']] = $in_id; - $lp_ordered_items[$parent_lps[$row['chapter_id']]][$row['chapter_id']][] = $in_id; - } - } - //echo "
    lp_items:".print_r($lp_items,true)."
    \n"; - // Complete next_item_id field by going through the new table and looking at parent_id and display_order - $order_sql = "ALTER TABLE $my_new_lp_item ADD INDEX (lp_id, parent_item_id, display_order)"; - $order_res = Database::query($order_sql); - $order_sql = "SELECT * FROM $my_new_lp_item ORDER by lp_id ASC, parent_item_id ASC, display_order ASC"; - //echo "$order_sql
    \n"; - $order_res = Database::query($order_sql); - $order_item = array(); //this will contain a sequential list of item_id's, thus allowing to give a simple way to get next id... - $lp_id = 0; - //echo "
    ";
    -    while ($row = Database::fetch_array($order_res)) {
    -        //print_r($row);
    -        if ($row['lp_id'] != $lp_id) {
    -            // Apply changes to the database and clean tool arrays
    -            $last = 0;
    -            foreach ($order_item as $order_id => $item_id) {
    -                $next = 0;
    -                if (!empty($order_item[$order_id+1])) {
    -                    $next = $order_item[$order_id+1];
    -                }
    -                $upd = "UPDATE $my_new_lp_item " .
    -                        "SET next_item_id = ".$next."," .
    -                        "    previous_item_id = ".$last." " .
    -                        "WHERE id = ".$item_id;
    -                //echo "$upd
    \n"; - Database::query($upd); - $last = $item_id; - } - $order_item = array(); - $lp_id = $row['lp_id']; - $order_item[] = $row['id']; - } else { - $order_item[] = $row['id']; - } - } - // Process the last LP stack - $last = 0; - foreach ($order_item as $order_id => $item_id) { - $next = 0; - if (!empty($order_item[$order_id + 1])) { - $next = $order_item[$order_id + 1]; - } - $upd = "UPDATE $my_new_lp_item " . - "SET next_item_id = ".$next."," . - " previous_item_id = ".$last." " . - "WHERE id = ".$item_id; - //echo "$upd
    \n"; - Database::query($upd); - $last = $item_id; - } - - //echo "
    \n"; - - // MIGRATING THE learnpath_user TABLE (results) - $mysql = "ALTER TABLE $my_new_lp_item_view ADD INDEX (lp_view_id)"; - $myres = Database::query($mysql); - $sql_lp_user = "ALTER TABLE $lp_user ADD INDEX (user_id, learnpath_id, learnpath_item_id)"; - $res_lp_user = Database::query($sql_lp_user); - $sql_lp_user = "SELECT * FROM $lp_user ORDER BY user_id, learnpath_id, learnpath_item_id"; - //echo "$sql_lp_user
    \n"; - $res_lp_user = Database::query($sql_lp_user); - $user_id = 0; - $learnpath_id = 0; - $lp_view = 0; - while ($row = Database::fetch_array($res_lp_user)) { - if ($row['user_id']!=$user_id OR $row['learnpath_id']!=$learnpath_id) { //the user has changed or this is the first - // Insert a new lp_view - $last = 0; - if (!empty($lp_chaps_list[$row['learnpath_id']][0])) { - $last = $lp_chaps_list[$row['learnpath_id']][0]; - } - if (empty($lp_ids[$row['learnpath_id']])) { - // This can be ignored as it means there was an LP before, this user - // used it, but now it's been removed - //echo "Somehow we also miss a lp_ids[".$row['learnpath_id']."] here
    \n"; - $incoherences ++; - } else { - $mylpid = $lp_ids[$row['learnpath_id']]; - $sql_ins_view = "INSERT INTO $my_new_lp_view(" . - "lp_id," . - "user_id," . - "view_count," . - "last_item" . - ")VALUES(" . - "".$mylpid."," . // new learnpath id - "".$row['user_id']."," . // user IDs stay the same - "1," . - "".$last."" . // Use the first chapter from this learnpath - ")"; - //echo $sql_ins_view; - $res_ins_view = Database::query($sql_ins_view); - $in_id = Database::insert_id(); - $user_id = $row['user_id']; - $learnpath_id = $row['learnpath_id']; - $lp_view = $in_id; - } - } - // Insert the record into lp_item_view - // TODO: fix the whole in here (missing one item at least) - $my_new_lp_item_id = $lp_items[$learnpath_id][$row['learnpath_item_id']]; - if (empty($my_new_lp_item_id)) { - // This can be ignored safely as it just means a user used a learnpath_item - // before it was removed from items - maybe fix that in Dokeos? - //echo "Somehow we miss lp_items[".$learnpath_id."][".$row['learnpath_item_id']."] here...
    "; - $incoherences ++; - } else { - $start_time = 0; - $my_time = my_get_time($row['time']); - if ($my_time > 0) { - $start_time = time() - $my_time; - } - $sql_ins_iv = "INSERT INTO $my_new_lp_item_view(" . - "lp_item_id," . - "lp_view_id," . - "view_count," . - "start_time," . - "total_time," . - "score," . - "status" . - ")VALUES(" . - "".$lp_items[$learnpath_id][$row['learnpath_item_id']]."," . - "".$lp_view."," . - "1," . - "$start_time," . - "".$my_time."," . - "".$row['score']."," . - "'".$row['status']."'" . - ")"; - //echo $sql_ins_iv; - $res_ins_iv = Database::query($sql_ins_iv); - } - // UPDATE THE LP_VIEW progress - $mysql = "SELECT count(distinct(lp_item_id)) FROM $my_new_lp_item_view WHERE lp_view_id = ".$lp_view." AND status IN ('passed','completed','succeeded','browsed','failed')"; - $myres = Database::query($mysql); - $myrow = Database::fetch_array($myres); - $completed = $myrow[0]; - $mylpid = $lp_ids[$row['learnpath_id']]; - $sql = "SELECT count(*) FROM $my_new_lp_item WHERE lp_id = '".$mylpid."'"; - $myres = Database::query($sql); - $myrow = Database::fetch_array($myres); - $total = $myrow[0]; - $progress = ((float)$completed / (float)$total) * 100; - $progress = number_format($progress, 0); - $sql = "UPDATE $my_new_lp_view SET progress = '$progress' WHERE id = '$lp_view'"; - $myres = Database::query($sql); - } - - /** - * Move prerequisites - * TODO: Integrate prerequisites migration into learnpath_item migration - */ - - $msg = ''; - if ($incoherences > 0) { - $msg = "(found $incoherences incoherences between views and items - ignored)"; - } - /** - * Migrate links on the homepage as well now (look into the TABLE_TOOL_LIST table and - * update the links to newscorm/lp_controller.php?action=view&lp_id=x) - * Only normal learnpaths were visible from the homepage so we only need to update here - */ - // MIGRATING LEARNPATH LINKS ON COURSES HOMEPAGES - $tbl_tool = $db.TABLE_TOOL_LIST; - $sql_tool = "SELECT * FROM $tbl_tool WHERE image='scormbuilder.gif' AND link LIKE '%learnpath_handler%'"; - $res_tool = Database::query($sql_tool); - while ($row_tool = Database::fetch_array($res_tool)) { - $name = $row_tool['name']; - $link = $row_tool['link']; - // Get old lp_id from there - $matches = array(); - if (preg_match('/learnpath_id=(\d+)$/', $link,$matches)) { - $old_lp_id = $matches[1]; - $new_lp_id = $lp_ids[$old_lp_id]; - $sql_tool_upd = "UPDATE $tbl_tool " . - "SET link='newscorm/lp_controller.php?action=view&lp_id=$new_lp_id' " . - "WHERE id = ".$row_tool['id']; - Log::notice('New LP - Migration - Updating tool table: '.$sql_tool_upd); - // Make sure there is a way of retrieving which links were updated (to revert) - fwrite($fh,$sql_tool_upd." AND link ='$link'"); - fwrite($fh_revert, "UPDATE $tbl_tool SET link='$link' WHERE id=".$row_tool['id']." AND link ='newscorm/lp_controller.php?action=view&lp_id=$new_lp_id';\n"); - //echo $sql_tool_upd." (and link='$link')
    \n"; - $res_tool_upd = Database::query($sql_tool_upd); - } - } - - $tbl_tool = $db.TABLE_TOOL_LIST; - $sql_tool = "SELECT * FROM $tbl_tool"; - $res_tool = Database::query($sql_tool); - while ($row_tool = Database::fetch_array($res_tool)) { - $link = $row_tool['link']; - $matches = array(); - $pattern = '@scorm/showinframes\.php([^\s"\'&]*)(&|&)file=([^\s"\'&]*)@'; - if (preg_match($pattern, $link, $matches)) { - //echo "Found match for scorm link in $tbl_tool: $link
    "; - if (!empty($matches[3]) && (strtolower(substr($matches[3], -15)) == 'imsmanifest.xml') && !is_file(realpath(urldecode($matches[3])))) { - //echo "Removing link $link from tools
    "; - $sql_tool_upd = "DELETE FROM $tbl_tool WHERE id = ".$row_tool['id']; - Log::notice('New LP - Migration - Updating tool table (dead link): '.$sql_tool_upd); - // Make sure there is a way of retrieving which links were updated (to revert) - fwrite($fh, $sql_tool_upd." AND link ='$link'"); - fwrite($fh_revert, "INSERT INTO $tbl_tool (link) VALUES ('$link');\n"); - //echo $sql_tool_upd." (and link='$link')
    \n"; - $res_tool_upd = Database::query($sql_tool_upd); - } - } else { - //echo "No scorm link found in tool link $link
    "; - } - //flush(); - } - /** - * Update course description (intro page) to use new links instead of learnpath/learnpath_handler.php - */ - $tbl_intro = $db.TABLE_TOOL_INTRO; - $sql_i = "SELECT * FROM $tbl_intro WHERE id='course_homepage'"; - $res_i = Database::query($sql_i); - //$link_to_course1 = 'scorm/scormdocument.php'; - while ($row_i = Database::fetch_array($res_i)) { - $intro = $row_i['intro_text']; - $update = 0; - $out = array(); - if (preg_match_all('/claroline\/learnpath\/showinframes\.php([^\s"\']*)learnpath_id=(\d*)/', $intro, $out, PREG_SET_ORDER)) { - foreach ($out as $results) { - //echo "---> replace ".'/learnpath\/showinframes\.php([^\s"\']*)learnpath_id='.$results[2].'/ by newscorm/lp_controller.php'.$results[1].'action=view&lp_id='.$lp_ids[$results[2]]; - $intro = preg_replace('/claroline\/learnpath\/showinframes\.php([^\s"\']*)learnpath_id='.$results[2].'/','main/newscorm/lp_controller.php'.$results[1].'action=view&lp_id='.$lp_ids[$results[2]], $intro); - } - } - if (preg_match_all('/claroline\/phpbb\/index.php/', $intro, $out, PREG_SET_ORDER)) { - foreach ($out as $results) { - $intro = preg_replace('/claroline\/phpbb\/index\.php([^\s"\']*)/','main/forum/index.php'.$results[1], $intro); - } - } - if ($intrp != $row_i['intro_text']) { - //echo "
    Replacing ".$row_i['intro_text']."\n by \n ".$intro."

    \n"; - $sql_upd = "update $tbl_intro set intro_text = '".Database::escape_string($intro)."' WHERE id = 'course_homepage' AND intro_text = '".Database::escape_string($row_i['intro_text'])."'"; - //echo $sql_upd."
    \n"; - fwrite($fh,"$sql_upd\n"); - fwrite($fh_revert,"UPDATE $tbl_intro set intro_text = '".$row_i['intro_text']."' WHERE id = 'course_homepage' AND intro_text = '$intro';\n"); - fwrite($fh_res,"$intro\n"); - Database::query($sql_upd); - } - } - - if ($loglevel > 0) { Log::notice("Done!".$msg); } - //flush(); - //ob_flush(); -} - -unset($lp_ids); -unset($lp_users); -unset($parent_chaps); -unset($lp_chap_items); -unset($ordered_chaps); -unset($lp_items); -unset($lp_ordered_items); -unset($parent_lps); - -fwrite($fh, "-- Recording course homepages links changes for SCORM to enable reverting\n"); -fwrite($fh_revert, "-- Recording reverted course homepages links changes for SCORM to enable reverting\n"); -fwrite($fh_res, "-- Recording resulting course homepages links changes for SCORM\n"); - -/** - * SCORM - * The migration needs to take all data from the scorm.scorm_main and scorm.scorm_sco_data tables - * and add them to the new lp, lp_view, lp_item and lp_item_view tables. - */ -if ($loglevel > 0) { Log::notice("Now starting migration of scorm tables from global SCORM database"); } - -$scorm_main = $dbScormForm.'.'.TABLE_SCORM_MAIN; -$scorm_item = $dbScormForm.'.'.TABLE_SCORM_SCO_DATA; -//$lp_main = Database::get_course_table(TABLE_LEARNPATH_MAIN,$db); -$course_pref = $table_prefix; -$lp_ids = array(); -$lp_item_ids = array(); -$lp_item_refs = array(); -$lp_course = array(); -$lp_course_code = array(); -$scorm_lp_paths = array(); - -// Avoid empty dokeosCourse fields as they potentially break the rest -Database::select_db($dbNameForm); -$course_main = TABLE_MAIN_COURSE; -$sql_crs = "SELECT * FROM $course_main WHERE target_course_code IS NULL"; -if ($loglevel > 0) { Log::notice("$sql_crs"); } -$res_crs = Database::query($sql_crs); -$num = Database::num_rows($res_crs); - -// Prepare an array that will contain course codes and for each course code a list of lps [by path prefixed by '/'] -$scorms = array(); -$course_code_swap = ''; -$scormdocuments_lps = array(); -while ($course_row = Database::fetch_array($res_crs)) { - - if ($loglevel > 0) { Log::notice("Now dealing with course ".$course_row['code']."..."); } - // Check the validity of this new course - $my_course_code = $course_row['code']; - - // Reinit the scormdocuments list - //$scormdocuments_lps = array(); - $db_name = $courses_id_full_table_prefix_list[$my_course_code]; - if (strlen($courses_id_list[$course_code]) > 40) { - Log::notice('Database '.$courses_id_list[$course_code].' is too long, skipping'); - continue; - } - - //echo "Now processing database $db_name
    "; - $tblscodoc = $db_name.TABLE_SCORMDOC; - $sql_scodoc = "SELECT path FROM $tblscodoc WHERE path IS NOT NULL AND path != ''"; - if ($loglevel > 1) { Log::notice("$sql_scodoc"); } - $res_scodoc = Database::query($sql_scodoc); - while ($row_scodoc = Database::fetch_array($res_scodoc)) { - - // Check if there's more than one slash in total - if (strpos($row_scodoc['path'], '/', 1) === false) { - $tmp_path = $row_scodoc['path']; - if ($loglevel > 1) { Log::notice("++Now opening $tmp_path"); } - - // Add a prefixing slash if there is none - if (substr($tmp_path, 0, 1) != '/') { - $tmp_path = '/'.$tmp_path; - } - - // If the path is just a slash, empty it - if ($tmp_path == '/') { - $tmp_path = ''; - } - - // There is only one 'slash' sign at the beginning, or none at all, so we assume - // it is a main directory that should be taken as path. - $courses_dir = $sys_course_path.''.$courses_dir_list[$my_course_code].'/scorm'.$tmp_path; - if (!is_dir($courses_dir)) { - //echo "Scormdocument path $my_content_id: $tmp_path doesn't exist in ".$sys_course_path.$courses_dir_list[$my_course_code]."/scorm, skipping
    \n"; - continue; - // Avoid if contentTitle is not the name of an existing directory - } elseif (!is_file($courses_dir."/imsmanifest.xml")) { - // If the imsmanifest file was not found there - if ($loglevel > 2) { Log::error(" !!imsmanifest.xml not found at scormdocument's $courses_dir/imsmanifest.xml, skipping"); } - // Try subdirectories on one level depth - if ($loglevel > 2) { Log::notice(" Trying subdirectories..."); } - $dh = opendir($courses_dir); - while ($entry = readdir($dh)) { - if (substr($entry, 0, 1) != '.') { - if (is_dir($courses_dir."/".$entry)) { - if (is_file($courses_dir."/".$entry."/imsmanifest.xml")) { - if ($loglevel > 2) { Log::notice(". .. and found $courses_dir/$entry/imsmanifest.xml!"); } - if (!in_array($tmp_path."/".$entry."/imsmanifest.xml",$scormdocuments_lps)) { - if ($loglevel > 2){ Log::notice(" Recording.
    "); } - $scormdocuments_lps[] = $tmp_path."/".$entry; - } - } - } - } - } - } else { - if ($loglevel > 2) { Log::notice(" Found scormdocument $tmp_path in ".$sys_course_path.$courses_dir_list[$my_course_code]."/scorm, treating it."); } - $scormdocuments_lps[] = $tmp_path; - } - } - } - - - // Because certain people with no admin skills had fun adding direct links to SCORM - // from the courses introductions, we have to check for SCORM packages from there too... - $tbl_intro = $db_name.TABLE_TOOL_INTRO; - $sql_i = "SELECT * FROM $tbl_intro WHERE id='course_homepage'"; - //echo $sql_i; - $res_i = Database::query($sql_i); - //$link_to_course1 = 'scorm/scormdocument.php'; - while ($row_scodoc = Database::fetch_array($res_i)) { - $intro = $row_scodoc['intro_text']; - //echo $intro."
    \n"; - $matches = array(); - $pattern = '@scorm/showinframes\.php([^\s"\']*)file=([^\s"\'&]*)@'; - if (preg_match_all($pattern, $intro, $matches, PREG_SET_ORDER)) { - if (count($matches) < 1) { - // Skip - } else { - //echo "Found matches in $tbl_intro
    "; - foreach ($matches as $match) { - //echo "Found match ".print_r($match,true)."
    "; - $mymatch = urldecode($match[2]); - $mymatch = str_replace($sys_course_path, $upd_course_path, $mymatch); - if (!empty($mymatch) && (strtolower(substr($mymatch, -15)) == 'imsmanifest.xml') && is_file(realpath(urldecode($mymatch)))) { - - //echo $mymatch." seems ok
    "; - // Found a new scorm course in the old directory - $courses_dir = $upd_course_path.''.$courses_dir_list[$my_course_code].'/scorm'; - // Check if the file is in the current course path, otherwise just forget about it - // as it would be too difficult to migrate - //echo "Comparing $mymatch with $courses_dir
    "; - if (strpos($mymatch, $courses_dir) !== false) { - // Remove the course dir up to /scorm from this path - $entry = substr($mymatch, strlen($courses_dir)); - // Remove the /imsmanifest.xml from the end of the path - $entry = substr($entry, 0, -16); - // If $entry was /var/www/dokeos/courses/ABC/scorm/tralala/imsmanifest.xml, - // $entry is now /tralala - //echo "Checking if manifest exists in ".$courses_dir.$entry."/imsmanifest.xml
    "; - if (is_file($courses_dir.$entry."/imsmanifest.xml")) { - //echo "found $courses_dir/$entry/imsmanifest.xml!
    "; - if ($loglevel > 2) { Log::notice(". .. and found $courses_dir/$entry/imsmanifest.xml!"); } - if (!in_array($entry."/imsmanifest.xml", $scormdocuments_lps)) { - if ($loglevel > 2) { Log::notice(" Recording.
    "); } - //echo "Recording $entry
    "; - $scormdocuments_lps[] = $entry; - } - } else { - //echo "Manifest does not exist in ".$courses_dir.$entry."/imsmanifest.xml
    "; - } - } - } - } - } - } - } - - // Prepare the new course's space in the scorms array - $scorms[$my_course_code] = array(); - - $sql_paths = "SELECT * FROM $scorm_main WHERE dokeosCourse = '".$my_course_code."'"; - if ($loglevel > 0) { Log::notice("$sql_paths"); } - $res_paths = Database::query($sql_paths); - $num = Database::num_rows($res_paths); - while ($scorm_row = Database::fetch_array($res_paths)) { - // Check if this is a new course - $my_content_id = $scorm_row['contentId']; - $my_path = $scorm_row['contentTitle']; - if (substr($my_path, 0, 1) != '/') { - $my_path = '/'.$my_path; - } - if ($my_path == '/') { - $my_path = ''; - } - if ($loglevel > 1) { Log::notice("++++Now opening $my_path"); } - if (!is_dir($courses_dir = $sys_course_path.''.$courses_dir_list[$my_course_code].'/scorm'.$my_path)) { - if ($loglevel > 1) { Log::notice("Path $my_content_id: $my_path doesn't exist in ".$sys_course_path.$courses_dir_list[$my_course_code]."/scorm, skipping"); } - continue; - // Avoid if contentTitle is not the name of an existing directory - } elseif (!is_file($sys_course_path.$courses_dir_list[$my_course_code].'/scorm'.$my_path."/imsmanifest.xml")) { - if ($loglevel > 1) { Log::notice("!!imsmanifest.xml not found at ".$sys_course_path.$courses_dir_list[$my_course_code].'/scorm'.$my_path."/imsmanifest.xml, skipping"); } - continue; - } else { - if ($loglevel > 1) { Log::notice("Found $my_path in ".$sys_course_path.$courses_dir_list[$my_course_code]."/scorm".$mypath."/imsmanifest.xml, keeping it."); } - $scorms[$my_course_code][$my_path] = $my_content_id; - } - } - // Check if all the lps from scormdocuments_lps are already in the course array, - // otherwise add them (and set ID of 0 so no tracking will be available) - foreach ($scormdocuments_lps as $path) { - if (!in_array($path,array_keys($scorms[$my_course_code]))) { - // Add it (-1 means no ID) - if ($loglevel > 1) { Log::notice("** Scormdocument path $path wasn't recorded yet. Added."); } - $scorms[$my_course_code][$path] = -1; - } - } - $course_code_swap = $my_course_code; - unset($scormdocuments_lps); -} - -//echo "
    courses_id_list: ".print_r($courses_id_list,true)."
    \n"; - -$my_count = 0; -foreach ($scorms as $mycourse => $my_paths) { - $my_count += count($my_paths); -} -if ($loglevel > 0) { Log::notice("---- Scorms array now contains ".$mycount." paths to migrate. Starting migration..."); } - -/** - * Looping through the SCO_MAIN table for SCORM learnpath attached to courses - * Order by course to try and reuse the maximum data - */ -$i_count = 0; -foreach ($scorms as $my_course_code => $paths_list) { - $max_dsp_lp = 0; - $course_lp_done = array(); - $db_name = $courses_id_full_table_prefix_list[$my_course_code]; - foreach ($paths_list as $my_path => $old_id) { - if ($loglevel > 1) { Log::notice("Migrating lp $my_path from course $my_course_code..."); } - $i_count ++; - //Log::notice('New LP - Migration script - Content '.$i_count.' on '.$num.' (course '.$scorm['dokeosCourse'].')'); - // Check whether there is no embedded learnpaths into other learnpaths (one root-level and another embedded) - $embedded = false; - foreach ($course_lp_done as $tmp_lp) { - if (empty($tmp_lp)) { - $tmp_lp = '/'; // Allows finding the lp as a subitem, otherwise strstr returns false - } - if (strstr($my_path, $tmp_lp) === false) { - // Let it be - } else { - // This lp is embedded inside another lp who's imsmanifest exists, so prevent from parsing - if ($loglevel > 1) { Log::notice("LP $my_path is embedded into $tmp_lp, ignoring..."); } - $embedded = true; - continue; - } - } - if ($embedded) { - continue; - } - $course_lp_done[] = $my_path; - //echo "
    scorm row: ".print_r($scorm,true)."
    \n"; - $my_content_id = $old_id; - $my_path = $my_path; - $my_name = basename($my_path); - - if ($loglevel > 1) { Log::notice("Try importing LP $my_path from imsmanifest first as it is more reliable"); } - - // Setup the ims path (path to the imsmanifest.xml file) - //echo "Looking for course with code ".$lp_course_code[$my_content_id]." (using $my_content_id)
    \n"; - //$courses_dir = $sys_course_path.$courses_dir_list[$my_course_code]; - $courses_dir = $upd_course_path.$courses_dir_list[$my_course_code]; - $sco_path_temp = ($my_path == '/') ? '' : $my_path; - $sco_middle_path = (empty($sco_path_temp) ? '' : (substr($sco_path_temp, 0, 1) == '/') ? substr($sco_path_temp, 1).'/' : $sco_path_temp.'/'); //same thing as sco_path_temp but with reversed slashes - $ims = $courses_dir.'/scorm'.$sco_path_temp.'/imsmanifest.xml'; - - if (is_file($ims)){ - //echo "Path $ims exists, importing...(line ".__LINE__.")
    "; - $oScorm = new scorm(); - // Check whether imsmanifest.xml exists at this location. If not, ignore the imsmanifest. - // That should have been done before already, now. - if ($loglevel > 1) { Log::notice("Found imsmanifest ($ims), importing..."); } - if (!empty($sco_middle_path)) { $oScorm->subdir = $sco_middle_path; } //this sets the subdir for the scorm package inside the scorm dir - // Parse manifest file - $manifest = $oScorm->parse_manifest($ims); - // The title is already escaped in the method - $oScorm->import_manifest($my_course_code); - //TODO: Add code to update the path in that new lp created, as it probably uses / where - // $sco_path_temp should be used... - $lp_ids[$my_content_id] = $oScorm->lp_id; // Contains the old LP ID => the new LP ID - if ($loglevel > 1) { Log::notice(" @@@ Created scorm lp ".$oScorm->lp_id." from imsmanifest [".$ims."] in course $my_course_code"); } - $lp_course[$my_content_id] = $courses_id_list[$my_course_code]; // Contains the old learnpath ID => the course DB name - $lp_course_code[$my_content_id] = $my_course_code; - $max_dsp_lp++; - - /* - * QUERY SCORM ITEMS FROM SCORM_SCO_DATA - * The danger here is that we might have several users for the same data, and so - * we have to avoid entering the same elements twice - */ - $sql_items = "SELECT * FROM $scorm_item WHERE contentId = '".$my_content_id."' ORDER BY scoId"; - //echo "$sql_items
    \n"; - $res_items = Database::query($sql_items); - while ($scormItem = Database::fetch_array($res_items)) { - $my_sco_id = $scormItem['scoId']; //the index for display??? (check that) - $my_identifier = $scormItem['scoIdentifier']; //the scorm item path/name - $my_title = Database::escape_string($scormItem['scoTitle']); - $my_status = $scormItem['status']; - $my_student = $scormItem['studentId']; - $my_score = $scormItem['score']; - $my_time = my_get_time($scormItem['time']); - $my_type = 'sco'; - //$my_item_path = $scorm_lp_paths[$my_content_id]['path']; - $my_item_path = ''; - - //echo "  FOUND item belonging to old learnpath num $my_content_id so belongs to course ".$lp_course[$my_content_id]."
    \n"; - $my_new_lp_item = $db_name.$new_lp_item; - $my_new_lp_view = $db_name.$new_lp_view; - $my_new_lp_item_view = $db_name.$new_lp_item_view; - - /* - * Check if a view is needed - */ - if ($my_score != '' and $my_status != 'not attempted') { - // It is worth creating an lp_view and an lp_item_view - otherwise not - $sel_sqlb = "SELECT * FROM $my_new_lp_view " . - "WHERE lp_id = ".$lp_ids[$my_content_id]." AND user_id = $my_student"; - $sel_resb = Database::query($sel_sqlb); - if (Database::num_rows($sel_resb) > 0) { - // Don't insert - $rowb = Database::fetch_array($sel_resb); - $view_insert_id = $rowb['id']; - } else { - $ins_sql = "INSERT INTO $my_new_lp_view (" . - "lp_id," . - "user_id," . - "view_count" . - ") VALUES (" . - $lp_ids[$my_content_id].", " . - $my_student.", " . - "1" . - ")"; - //echo "$ins_sql
    "; - $ins_res = Database::query($ins_sql); - $view_insert_id = Database::insert_id(); - } - $sel_sqlc = "SELECT * FROM $my_new_lp_item " . - "WHERE lp_id = ".$lp_ids[$my_content_id]." AND ref = '$my_identifier'"; - $sel_resc = Database::query($sel_sqlc); - if (Database::num_rows($sel_resc) > 0) { - $my_item_id_row = Database::fetch_array($sel_resc); - $item_insert_id = $my_item_id_row['id']; - $ins_sql = "INSERT INTO $my_new_lp_item_view (" . - "lp_item_id, lp_view_id, view_count," . - "start_time, total_time, score," . - "status" . - ") VALUES (" . - "$item_insert_id, $view_insert_id, 1," . - "0, $my_time, $my_score," . - "'$my_status'" . - ")"; - //echo "$ins_sql
    "; - $ins_res = Database::query($ins_sql); - } else { - //echo " Didn't find corresponding item for $my_identifier in new tables
    \n"; - } - } - } - - } else { - //echo "Could not find $ims... Proceeding from database...(line ".__LINE__.")
    "; - if ($loglevel > 1) { Log::notice("This is a normal SCORM path"); } - $scorm_lp_paths[$my_content_id]['path'] = $my_path; - //$scorm_lp_paths[$my_content_id]['ims'] = ''; - $table_name = $db_name.$new_lp; - $sql_ins = "INSERT INTO $table_name (" . - "lp_type," . - "name," . - "description," . - "path," . - "force_commit, " . - "default_encoding," . - "display_order," . - "content_maker," . - "content_local," . - "js_lib" . - ") VALUES (" . - "2," . - "'$my_name'," . - "''," . - "'$my_path'," . - "0," . - "'UTF-8'," . - "".$max_dsp_lp."," . - "'Unknown'," . - "'Unknown'," . - "'scorm_api.php'" . - ")"; - if ($loglevel > 1) { Log::notice("$sql_ins"); } - $sql_res = Database::query($sql_ins); - $in_id = Database::insert_id(); - if (!$in_id) die('Could not insert scorm lp: '.$sql_ins); - //echo "  Inserted item $in_id
    \n"; - $lp_ids[$my_content_id] = $in_id; //contains the old LP ID => the new LP ID - $lp_course[$my_content_id] = $courses_id_list[$my_course_code]; // Contains the old learnpath ID => the course DB name - $lp_course_code[$my_content_id] = $my_course_code; - $max_dsp_lp++; - - // Setup the ims path (path to the imsmanifest.xml file) - //echo "Looking for course with code ".$lp_course_code[$my_content_id]." (using $my_content_id)
    \n"; - $courses_dir = $sys_course_path.$courses_dir_list[$lp_course_code[$my_content_id]]; - //$scorm_lp_paths[$my_content_id]['path'] = str_replace(' ', '\\ ', $scorm_lp_paths[$my_content_id]['path']); - $sco_path_temp = ($scorm_lp_paths[$my_content_id]['path'] == '/') ? '' : $scorm_lp_paths[$my_content_id]['path']; - $scorm_lp_paths[$my_content_id]['ims'] = $courses_dir.'/scorm'.$sco_path_temp.'/imsmanifest.xml'; - - // Generate an imsmanifest object to get more info about the learnpath from the file - $oScorm = new scorm(); - // Check whether imsmanifest.xml exists at this location. If not, ignore the imsmanifest. - // That should have been done before already, now. - if (!is_file($scorm_lp_paths[$my_content_id]['ims'])) { - if ($loglevel > 1) { Log::notice("!!! imsmanifest file not found at ".$scorm_lp_paths[$my_content_id]['ims'].' for old lp '.$my_content_id.' and new '.$lp_ids[$my_content_id]); } - $manifest = false; - } else { - //echo "Parsing ".$scorm_lp_paths[$my_content_id]['ims']."
    \n"; - // Parse manifest file - $manifest = $oScorm->parse_manifest($scorm_lp_paths[$my_content_id]['ims']); - // The title is already escaped in the method - //$my_lp_title = api_convert_encoding($oScorm->get_title(),'ISO-8859-1',$oScorm->manifest_encoding); - $my_lp_title = api_convert_encoding($oScorm->get_title(), 'ISO-8859-1', 'UTF-8'); // TODO: This "magic" conversion to be checked. - if (!empty($my_lp_title)) { - $my_new_lp = $db_name.$new_lp; - $my_sql = "UPDATE $my_new_lp " . - "SET name = '$my_lp_title', " . - "default_encoding = '".strtoupper($oScorm->manifest_encoding)."' " . - "WHERE id = ".$lp_ids[$my_content_id]; - if ($loglevel > 1) { Log::notice("Updating title and encoding: ".$my_sql); } - $my_res = Database::query($my_sql); - } - } - - /* - * QUERY SCORM ITEMS FROM SCORM_SCO_DATA - * The danger here is that we might have several users for the same data, and so - * we have to avoid entering the same elements twice - */ - $sql_items = "SELECT * FROM $scorm_item WHERE contentId = '".$my_content_id."' ORDER BY scoId"; - //echo "$sql_items
    \n"; - $res_items = Database::query($sql_items); - while ($scormItem = Database::fetch_array($res_items)) { - $my_sco_id = $scormItem['scoId']; // The index for display??? (check that) - $my_identifier = $scormItem['scoIdentifier']; //the scorm item path/name - $my_title = Database::escape_string($scormItem['scoTitle']); - $my_status = $scormItem['status']; - $my_student = $scormItem['studentId']; - $my_score = $scormItem['score']; - $my_time = my_get_time($scormItem['time']); - $my_type = 'sco'; - //$my_item_path = $scorm_lp_paths[$my_content_id]['path']; - $my_item_path = ''; - - //echo "  FOUND item belonging to old learnpath num $my_content_id so belongs to course ".$lp_course[$my_content_id]."
    \n"; - $my_new_lp_item = $db_name.$new_lp_item; - $my_new_lp_view = $db_name.$new_lp_view; - $my_new_lp_item_view = $db_name.$new_lp_item_view; - - /* - * Query items from the new table to check if it doesn't exist already - * Otherwise insert it - */ - $sel_sql = "SELECT * FROM $my_new_lp_item " . - "WHERE ref = '$my_identifier' " . - "AND lp_id = ".$lp_ids[$my_content_id].""; - //echo $sel_sql."
    \n"; - $sel_res = Database::query($sel_sql); - if (Database::num_rows($sel_res) > 0) { - // This item already exists, reuse - $row = Database::fetch_array($sel_res); - $item_insert_id = $row['lp_id']; - } else { - $ins_sql = "INSERT INTO $my_new_lp_item (" . - "lp_id," . - "item_type," . - "ref," . - "title," . - "path" . - ") " . - "VALUES (" . - "'".$lp_ids[$my_content_id]."'," . //insert new learnpath ID - "'$my_type'," . - "'".$my_identifier."'," . - "'".$my_title."'," . - "'$my_item_path'" . - ")"; - $ins_res = Database::query($ins_sql); - $item_insert_id = Database::insert_id(); - $lp_item_ids[$lp_ids[$my_content_id]][$my_sco_id] = $item_insert_id; - $lp_item_refs[$lp_ids[$my_content_id]][$my_identifier] = $item_insert_id; - } - /* - * Check if a view is needed - */ - if ($my_score != '' and $my_status != 'not attempted') { - // It is worth creating an lp_view and an lp_item_view - otherwise not - $sel_sqlb = "SELECT * FROM $my_new_lp_view " . - "WHERE lp_id = ".$lp_ids[$my_content_id]." AND user_id = $my_student"; - $sel_resb = Database::query($sel_sqlb); - if (Database::num_rows($sel_resb) > 0) { - // Don't insert - $rowb = Database::fetch_array($sel_resb); - $view_insert_id = $rowb['id']; - } else { - $ins_sql = "INSERT INTO $my_new_lp_view (" . - "lp_id," . - "user_id," . - "view_count" . - ") VALUES (" . - $lp_ids[$my_content_id].", " . - $my_student.", " . - "1" . - ")"; - $ins_res = Database::query($ins_sql); - $view_insert_id = Database::insert_id(); - } - $ins_sql = "INSERT INTO $my_new_lp_item_view (" . - "lp_item_id, lp_view_id, view_count," . - "start_time, total_time, score," . - "status" . - ") VALUES (" . - "$item_insert_id, $view_insert_id, 1," . - "0, $my_time, $my_score," . - "'$my_status'" . - ")"; - $ins_res = Database::query($ins_sql); - } - } - // UPDATE THE LP_VIEW progress - if (!empty($view_insert_id)) { - $sql = "SELECT count(distinct(lp_item_id)) FROM $my_new_lp_item_view WHERE lp_view_id = ".$view_insert_id." AND status IN ('passed','completed','succeeded','browsed','failed')"; - $myres = Database::query($sql); - $myrow = Database::fetch_array($myres); - $completed = $myrow[0]; - $mylpid = $lp_ids[$my_content_id]; - $sql = "SELECT count(*) FROM $my_new_lp_item WHERE lp_id = '".$mylpid."'"; - $myres = Database::query($sql); - $myrow = Database::fetch_array($myres); - $total = $myrow[0]; - $progress = ((float)$completed / (float)$total) * 100; - $progress = number_format($progress, 0); - $sql = "UPDATE $my_new_lp_view SET progress = '$progress' WHERE id = '$view_insert_id'"; - $myres = Database::query($sql); - } - - /* - * Set all information that might be more correct coming from imsmanifest - */ - - //$my_new_lp = $db_name.$new_lp; - //$my_new_lp_item = $db_name.$new_lp_item; - //$my_new_lp_view = $db_name.$new_lp_view; - //$my_new_lp_item_view = $db_name.$new_lp_item_view; - //$sel_sql = "SELECT * FROM $my_new_lp WHERE id = $in_id"; - //$res = @Database::query($sel_sql); - //if (!$res) { - // echo "Error selecting lp: $sel_sql - ".Database::error()."
    \n"; - //} - $lp_details = array(); - //while ($row = Database::fetch_array($res)) { - $ordered_list = array(); - $mylist = array(); - foreach ($oScorm->organizations as $org) { - // There should be only one organization (generally) - // and if there are more, we are not supposed to have been - // able to manage them before the new tool, so ignore - if (count($ordered_list) > 0) { - break; - } - $ordered_list = $org->get_flat_items_list(); - } - $previous = 0; - $stock = array(0); - $level = 0; - $parent_id = 0; - foreach ($ordered_list as $index => $subarray) { - // $subarray is an array representing one item and that contains info like - // identifier, level, rel_order, prerequisites, title, masteryscore, etc. - //echo "
    Lookin for ".$subarray['identifier']." ".print_r($lp_item_refs,true)."
    \n"; - if (!empty($lp_item_refs[$in_id][$subarray['identifier']])) { - $new_id = $lp_item_refs[$in_id][$subarray['identifier']]; - $next = 0; - $dsp = $subarray['rel_order']; - if ($subarray['level'] > $level) { - // Getting one level deeper, just consult - $parent_id = $previous; - array_push($stock,$previous); - $level = $subarray['level']; - } elseif ($subarray['level'] == $level) { - // We are on the same level, going to the next id - //array_pop($stock); - //array_push($stock, $new_id); - } else { - // Getting back from one level deeper - array_pop($stock); - $parent_id = array_pop($stock); - array_push($stock, $parent_id); - $level = $subarray['level']; - } - if (!empty($ordered_list[$index + 1]['identifier']) && !empty($lp_item_refs[$in_id][$ordered_list[$index + 1]['identifier']])){ - $next = $lp_item_refs[$in_id][$ordered_list[$index + 1]['identifier']]; - } - $path = $oScorm->get_res_path($subarray['identifierref']); - $update_path = ''; - if (!empty($path)) { - // If new path is not empty, update - $update_path = "path = '$path', "; - } - $type = $oScorm->get_res_type($subarray['identifierref']); - $update_type = ''; - if (!empty($type)) { - // If type is defined, update - $update_type = "item_type = '$type', "; - } - if (empty($path)) { - // If path is empty, it is a dir anyway - $update_type = "item_type = 'dir', "; - } - $prereq = $subarray['prerequisites']; - $update_prereq = ''; - if (!empty($prereq)) { - $update_prereq = "prerequisite = '$prereq', "; - } - - // We had previous data about this element, update - $sql2 = "UPDATE $my_new_lp_item " . - "SET parent_item_id = $parent_id, " . - "previous_item_id = $previous, " . - "next_item_id = $next, " . - $update_path. - $update_type. - $update_prereq. - "display_order = $dsp " . - "WHERE lp_id = ".$in_id." AND id = ".$new_id; - //echo "$sql2
    \n"; - $res2 = Database::query($sql2); - $previous = $new_id; - } - } - /** - * Migrate links on the homepage as well now (look into the TABLE_TOOL_LIST table and - * update the links to newscorm/lp_controller.php?action=view&lp_id=x) - * See scorm_migrate_hometools.php - */ - //} - // end of case where $my_content_id != -1 - - } - - /** - * Update course description (intro page) to use new links instead of learnpath/learnpath_handler.php - */ - $tbl_intro = $db_name.TABLE_TOOL_INTRO; - $sql_i = "SELECT * FROM $tbl_intro WHERE id='course_homepage'"; - $res_i = Database::query($sql_i); - //$link_to_course1 = 'scorm/scormdocument.php'; - while ($row_i = Database::fetch_array($res_i)) { - $intro = $row_i['intro_text']; - $out = array(); - $enc_path = str_replace('/', '%2F', $my_path); - $enc_path = str_replace(' ', '\+', $enc_path); - //echo "Looking for path ".$enc_path."
    \n"; - $pattern = '@claroline/scorm/scormdocument\.php([^\s"\']*)openDir='.$enc_path.'([\\"\'\s&]*)@'; - if (preg_match_all($pattern, $intro, $out, PREG_SET_ORDER)) { - foreach ($out as $results) { - //echo "---> replace ".'/'.$results[0].'/ by newscorm/lp_controller.php'.$results[1].'action=view&lp_id='.$lp_ids[$my_content_id]; - //$intro = preg_replace('/scorm\/scormdocument\.php([^\s"\']*)openDir='.$enc_path.'([\\"\'\s&])/', 'newscorm/lp_controller.php'.$results[1].'action=view&lp_id='.$lp_ids[$my_content_id], $intro); - $intro = preg_replace('@claroline/scorm/scormdocument\.php([^\s"\']*)openDir='.$enc_path.'([^\s"\']*)@','main/newscorm/lp_controller.php'.$results[1].'action=view&lp_id='.$lp_ids[$my_content_id], $intro); - } - } else { - //echo "No scorm link found in intro text
    "; - } - $pattern = '@claroline/scorm/showinframes\.php([^\s"\']*)file=([^\s"\'&]*)'.$enc_path.'@'; - if (preg_match_all($pattern, $intro, $out, PREG_SET_ORDER)) { - foreach ($out as $results) { - //echo "---> replace ".'/'.$results[0].'/ by newscorm/lp_controller.php'.$results[1].'action=view&lp_id='.$lp_ids[$my_content_id]; - //$intro = preg_replace('/scorm\/showinframes\.php([^\s"\']*)file=([^\s"\']*)'.$enc_path.'/', 'newscorm/lp_controller.php'.$results[1].'action=view&lp_id='.$lp_ids[$my_content_id], $intro); - $intro = preg_replace('@claroline/scorm/showinframes\.php([^\s"\']*)file=([^\s"\'&]*)'.$enc_path.'([^\s"\']*)@','main/newscorm/lp_controller.php'.$results[1].'action=view&lp_id='.$lp_ids[$my_content_id], $intro); - } - } else { - //echo "No scorm link found in intro text
    "; - } - if ($intro != $row_i['intro_text']) { - //echo "
    Replacing ".$row_i['intro_text']."\n by \n ".$intro."

    \n"; - $sql_upd = "update $tbl_intro set intro_text = '".Database::escape_string($intro)."' WHERE id = 'course_homepage' AND intro_text = '".Database::escape_string($row_i['intro_text'])."'"; - //echo $sql_upd."
    \n"; - fwrite($fh, $sql_upd."\n"); - fwrite($fh_revert, "UPDATE $tbl_intro set intro_text = '".$row_i['intro_text']."' WHERE id = 'course_homepage' AND intro_text = '$intro';\n"); - fwrite($fh_res, $intro."\n"); - Database::query($sql_upd); - } - } - - flush(); - } -} -fclose($fh); -fclose($fh_revert); -fclose($fh_res); -if ($loglevel > 0) { Log::notice("All done!"); } -//echo ""; diff --git a/main/install/update-files-1.6.x-1.8.0.inc.php b/main/install/update-files-1.6.x-1.8.0.inc.php deleted file mode 100755 index faa18b022a..0000000000 --- a/main/install/update-files-1.6.x-1.8.0.inc.php +++ /dev/null @@ -1,152 +0,0 @@ - audio - if (!is_dir($currentCourseRepositorySys . "document/audio")) { - mkdir($currentCourseRepositorySys . "document/audio", $perm); - insert_db($db_name, "audio", get_lang('Audio')); - } - - // document > flash - if (!is_dir($currentCourseRepositorySys . "document/flash")) { - mkdir($currentCourseRepositorySys . "document/flash", $perm); - insert_db($db_name, "flash", get_lang('Flash')); - } - - // document > images - if (!is_dir($currentCourseRepositorySys . "document/images")) { - mkdir($currentCourseRepositorySys . "document/images", $perm); - insert_db($db_name, "images", get_lang('Images')); - } - - // document > video - if (!is_dir($currentCourseRepositorySys . "document/video")) { - mkdir($currentCourseRepositorySys . "document/video", $perm); - insert_db($db_name, "video", get_lang('Video')); - } - - // document > video > flv - if (!is_dir($currentCourseRepositorySys . "document/video/flv")) { - mkdir($currentCourseRepositorySys . "document/video/flv", $perm); - insert_db($db_name, "video", get_lang('Video') . " (flv)"); - } - - // FOLDER UPLOAD - // upload - if (!is_dir($currentCourseRepositorySys . "upload")) { - mkdir($currentCourseRepositorySys . "upload", $perm); - } - - // upload > blog - if (!is_dir($currentCourseRepositorySys . "upload/blog")) { - mkdir($currentCourseRepositorySys . "upload/blog", $perm); - } - - // upload > forum - if (!is_dir($currentCourseRepositorySys . "upload/forum")) { - mkdir($currentCourseRepositorySys . "upload/forum", $perm); - } - - // upload > test - if (!is_dir($currentCourseRepositorySys . "upload/test")) { - mkdir($currentCourseRepositorySys . "upload/test", $perm); - } - - // Updating index file in courses directories to change claroline/ into main/ - $content = ''; - unlink($currentCourseRepositorySys . 'index.php'); - $fp = @ fopen($currentCourseRepositorySys . 'index.php', 'w'); - if ($fp) { - Log::error('Writing redirection file in ' . $currentCourseRepositorySys . 'index.php'); - fwrite($fp, $content); - fclose($fp); - } else { - Log::error('Could not open file ' . $currentCourseRepositorySys . 'index.php'); - } - } - - // Write the config file - write_system_config_file(api_get_path(CONFIGURATION_PATH) . 'configuration.php'); - // Write a distribution file with the config as a backup for the admin - write_system_config_file(api_get_path(CONFIGURATION_PATH) . 'configuration.dist.php'); - // Write a .htaccess file in the course repository - write_courses_htaccess_file($urlAppendPath); - copy($updatePath . 'claroline/inc/conf/add_course.conf.php', $pathForm . 'main/inc/conf/add_course.conf.php'); - copy($updatePath . 'claroline/inc/conf/course_info.conf.php', $pathForm . 'main/inc/conf/course_info.conf.php'); - copy($updatePath . 'claroline/inc/conf/mail.conf.php', $pathForm . 'main/inc/conf/mail.conf.php'); - copy($updatePath . 'claroline/inc/conf/profile.conf.inc.php', $pathForm . 'main/inc/conf/profile.conf.php'); - - Log::notice('Renaming ' . $updatePath . 'claroline/upload/users to ' . $pathForm . 'main/upload/users'); - rename($updatePath . 'claroline/upload/users', $pathForm . 'main/upload/users'); - Log::notice('Renaming ' . $updatePath . 'claroline/upload/audio to ' . $pathForm . 'main/upload/audio'); - rename($updatePath . 'claroline/upload/audio', $pathForm . 'main/upload/audio'); - Log::notice('Renaming ' . $updatePath . 'claroline/upload/images to ' . $pathForm . 'main/upload/images'); - rename($updatePath . 'claroline/upload/images', $pathForm . 'main/upload/images'); - Log::notice('Renaming ' . $updatePath . 'claroline/upload/linked_files to ' . $pathForm . 'main/upload/linked_files'); - rename($updatePath . 'claroline/upload/linked_files', $pathForm . 'main/upload/linked_files'); - Log::notice('Renaming ' . $updatePath . 'claroline/upload/video to ' . $pathForm . 'main/upload/video'); - rename($updatePath . 'claroline/upload/video', $pathForm . 'main/upload/video'); -} else { - - echo 'You are not allowed here !' . __FILE__; -} diff --git a/main/install/update-files-1.8.3-1.8.4.inc.php b/main/install/update-files-1.8.3-1.8.4.inc.php deleted file mode 100755 index 048a22b32b..0000000000 --- a/main/install/update-files-1.8.3-1.8.4.inc.php +++ /dev/null @@ -1,58 +0,0 @@ -') !== false) { - // Ignore the line - $ignore = true; - } - if (!$ignore) { - fwrite($fh, $line); - } - } - if (!$found_version) { - fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n"); - } - if (!$found_stable) { - fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n"); - } - fwrite($fh, '?>'); - fclose($fh); - -} else { - - echo 'You are not allowed here !' . __FILE__; - -} diff --git a/main/install/update-files-1.8.4-1.8.5.inc.php b/main/install/update-files-1.8.4-1.8.5.inc.php deleted file mode 100755 index 179c401d31..0000000000 --- a/main/install/update-files-1.8.4-1.8.5.inc.php +++ /dev/null @@ -1,58 +0,0 @@ -') !== false) { - // Ignore the line - $ignore = true; - } - if (!$ignore) { - fwrite($fh, $line); - } - } - if (!$found_version) { - fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n"); - } - if (!$found_stable) { - fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n"); - } - fwrite($fh, '?>'); - fclose($fh); - -} else { - - echo 'You are not allowed here !' . __FILE__; - -} diff --git a/main/install/update-files-1.8.5-1.8.6.inc.php b/main/install/update-files-1.8.5-1.8.6.inc.php deleted file mode 100755 index b267a05d58..0000000000 --- a/main/install/update-files-1.8.5-1.8.6.inc.php +++ /dev/null @@ -1,121 +0,0 @@ -') !== false) { - // Ignore the line - $ignore = true; - } - if (!$ignore) { - fwrite($fh, $line); - } - } - if (!$found_version) { - fwrite($fh, '$_configuration[\'dokeos_version\'] = \'' . $new_version . '\';' . "\r\n"); - } - if (!$found_stable) { - fwrite($fh, '$_configuration[\'dokeos_stable\'] = ' . ($new_version_stable ? 'true' : 'false') . ';' . "\r\n"); - } - fwrite($fh, '?>'); - fclose($fh); - - $sys_course_path = $pathForm . 'courses/'; - - //$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE); - //// Linking (The following line is disabled, connection has been already done) - //$res = @iDatabase::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm)); - //iDatabase::select_db($dbNameForm, $link); - iDatabase::select_db($dbNameForm); - - $db_name = $dbNameForm; - $sql = "SELECT * FROM $db_name.course"; - Log::notice('Getting courses for files updates: ' . $sql); - $result = iDatabase::query($sql); - - while ($courses_directories = iDatabase::fetch_array($result)) { - - $currentCourseRepositorySys = $sys_course_path . $courses_directories['directory'] . '/'; - - $db_name = $courses_directories['db_name']; - $origCRS = $updatePath . 'courses/' . $courses_directories['directory']; - - if (!is_dir($origCRS)) { - Log::error('Directory ' . $origCRS . ' does not exist. Skipping.'); - continue; - } - // Move everything to the new hierarchy (from old path to new path) - Log::notice('Renaming ' . $origCRS . ' to ' . $sys_course_path . $courses_directories['directory']); - rename($origCRS, $sys_course_path . $courses_directories['directory']); - Log::notice('Creating dirs in ' . $currentCourseRepositorySys); - - // DOCUMENT FOLDER - // document > shared_folder - if (!is_dir($currentCourseRepositorySys . "document/shared_folder")) { - mkdir($currentCourseRepositorySys . "document/shared_folder", $perm); - } - - // UPLOAD FOLDER - // upload > forum > images - if (!is_dir($currentCourseRepositorySys . "upload/forum/images")) { - mkdir($currentCourseRepositorySys . "upload/forum/images", $perm); - } - - // upload > learning_path - if (!is_dir($currentCourseRepositorySys . "upload/learning_path")) { - mkdir($currentCourseRepositorySys . "upload/learning_path", $perm); - } - - // upload > learning_path > images - if (!is_dir($currentCourseRepositorySys . "upload/learning_path/images")) { - mkdir($currentCourseRepositorySys . "upload/learning_path/images", $perm); - } - - // upload > calendar - if (!is_dir($currentCourseRepositorySys . "upload/calendar")) { - mkdir($currentCourseRepositorySys . "upload/calendar", $perm); - } - - // upload > calendar > images - if (!is_dir($currentCourseRepositorySys . "upload/calendar/images")) { - mkdir($currentCourseRepositorySys . "upload/calendar/images", $perm); - } - } -} else { - - echo 'You are not allowed here !' . __FILE__; -} diff --git a/main/install/update-files-1.8.6-1.8.6.1.inc.php b/main/install/update-files-1.8.6-1.8.6.1.inc.php deleted file mode 100755 index 79100af115..0000000000 --- a/main/install/update-files-1.8.6-1.8.6.1.inc.php +++ /dev/null @@ -1,66 +0,0 @@ -') !== false) { - //ignore the line - $ignore = true; - } - if (!$ignore) { - fwrite($fh, $line); - } - } - if (!$found_version) { - fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n"); - } - if (!$found_stable) { - fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n"); - } - fwrite($fh, '?>'); - fclose($fh); - - //// Ccreate a specific directory for global thumbails - // home > default_platform_document > template_thumb - if (!is_dir($pathForm.'home/default_platform_document/template_thumb')) { - mkdir($pathForm.'home/default_platform_document/template_thumb', $perm); - } - -} else { - - echo 'You are not allowed here !' . __FILE__; - -} diff --git a/main/install/update-files-1.8.6.1-1.8.6.2.inc.php b/main/install/update-files-1.8.6.1-1.8.6.2.inc.php deleted file mode 100755 index 98e071ba76..0000000000 --- a/main/install/update-files-1.8.6.1-1.8.6.2.inc.php +++ /dev/null @@ -1,98 +0,0 @@ -') !== false) { - //ignore the line - $ignore = true; - } - if (!$ignore) { - fwrite($fh, $line); - } - } - if (!$found_version) { - fwrite($fh, '$_configuration[\'dokeos_version\'] = \'' . $new_version . '\';' . "\r\n"); - } - if (!$found_stable) { - fwrite($fh, '$_configuration[\'dokeos_stable\'] = ' . ($new_version_stable ? 'true' : 'false') . ';' . "\r\n"); - } - fwrite($fh, '?>'); - fclose($fh); - - $sys_course_path = $pathForm . 'courses/'; - - $perm = api_get_permissions_for_new_directories(); - - // The following line is disabled, connection has been already done - //$link = iDatabase::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm)); - //iDatabase::select_db($dbNameForm, $link); - iDatabase::select_db($dbNameForm); - - $db_name = $dbNameForm; - $sql = "SELECT * FROM $db_name.course"; - Log::notice('Getting courses for files updates: ' . $sql); - $result = iDatabase::query($sql); - - if (iDatabase::num_rows($result) > 0) { - while ($courses_directories = iDatabase::fetch_array($result)) { - $currentCourseRepositorySys = $sys_course_path . $courses_directories['directory'] . '/'; - // upload > announcements - $path = $currentCourseRepositorySys . "upload/announcements"; - if (!is_dir($path)) { - $success = mkdir($path, $perm, true); - if(!$success){ - $course_directory = $courses_directories['directory']; - Log::error("Failed to create dir path: $path, course directory: $course_directory, sys course path: $sys_course_path, perm: , perm: $perm"); - } - } - - // upload > announcements > images - $path = $currentCourseRepositorySys . "upload/announcements/images"; - if (!is_dir($path)) { - $success = mkdir($path, $perm, true); - if(!$success){ - $course_directory = $courses_directories['directory']; - Log::error("Failed to create dir path: $path, course directory: $course_directory, sys course path: $sys_course_path, perm: $perm"); - } - } - } - } - - //// Create a specific directory for global thumbails - // home > default_platform_document > template_thumb - if (!is_dir($pathForm . 'home/default_platform_document/template_thumb')) { - mkdir($pathForm . 'home/default_platform_document/template_thumb', $perm); - } -} else { - - echo 'You are not allowed here !' . __FILE__; -} diff --git a/main/install/update-files-1.8.6.2-1.8.7.inc.php b/main/install/update-files-1.8.6.2-1.8.7.inc.php deleted file mode 100755 index fa8537fa96..0000000000 --- a/main/install/update-files-1.8.6.2-1.8.7.inc.php +++ /dev/null @@ -1,77 +0,0 @@ -') !== false) { - $ignore = true; - } - if (!$ignore) { - fwrite($fh, $line); - } - } - if (!$found_version) { - fwrite($fh, '$_configuration[\'system_version\'] = \''.$new_version.'\';'."\r\n"); - } - if (!$found_stable) { - fwrite($fh, '$_configuration[\'system_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n"); - } - if (!$found_software_name) { - fwrite($fh, '$_configuration[\'software_name\'] = \''.$software_name.'\';'."\r\n"); - } - if (!$found_software_url) { - fwrite($fh, '$_configuration[\'software_url\'] = \''.$software_url.'\';'."\r\n"); - } - fwrite($fh, '?>'); - fclose($fh); - -} else { - - echo 'You are not allowed here !' . __FILE__; - -} diff --git a/main/install/update-files-1.8.7-1.8.8.inc.php b/main/install/update-files-1.8.7-1.8.8.inc.php deleted file mode 100755 index 82b35a1c5d..0000000000 --- a/main/install/update-files-1.8.7-1.8.8.inc.php +++ /dev/null @@ -1,77 +0,0 @@ -') !== false) { - $ignore = true; - } - if (!$ignore) { - fwrite($fh, $line); - } - } - if (!$found_version) { - fwrite($fh, '$_configuration[\'system_version\'] = \''.$new_version.'\';'."\r\n"); - } - if (!$found_stable) { - fwrite($fh, '$_configuration[\'system_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n"); - } - if (!$found_software_name) { - fwrite($fh, '$_configuration[\'software_name\'] = \''.$software_name.'\';'."\r\n"); - } - if (!$found_software_url) { - fwrite($fh, '$_configuration[\'software_url\'] = \''.$software_url.'\';'."\r\n"); - } - fwrite($fh, '?>'); - fclose($fh); - -} else { - - echo 'You are not allowed here !' . __FILE__; - -} diff --git a/main/install/update-files-1.8.8-1.9.0.inc.php b/main/install/update-files-1.8.8-1.9.0.inc.php deleted file mode 100755 index eedff8cc2d..0000000000 --- a/main/install/update-files-1.8.8-1.9.0.inc.php +++ /dev/null @@ -1,87 +0,0 @@ -') !== false) { - $ignore = true; - } - if (!$ignore) { - fwrite($fh, $line); - } - } - if (!$found_version) { - fwrite($fh, '$_configuration[\'system_version\'] = \'' . $new_version . '\';' . "\r\n"); - } - if (!$found_stable) { - fwrite($fh, '$_configuration[\'system_stable\'] = ' . ($new_version_stable ? 'true' : 'false') . ';' . "\r\n"); - } - if (!$found_software_name) { - fwrite($fh, '$_configuration[\'software_name\'] = \'' . $software_name . '\';' . "\r\n"); - } - if (!$found_software_url) { - fwrite($fh, '$_configuration[\'software_url\'] = \'' . $software_url . '\';' . "\r\n"); - } - $string = " -//===========================================================================\n -// Hosting settings - Allows you to set limits to the Chamilo portal when\n -// hosting it for a third party. These settings can be overwritten by an\n -// optionally-loaded extension file with only the settings (no comments).\n -//===========================================================================\n -// Set a maximum number of users. Default (0) = no limit\n -".'$'."_configuration['hosting_limit_users'] = 0;\n -// Set a maximum number of teachers. Default (0) = no limit\n -".'$'."_configuration['hosting_limit_teachers'] = 0;\n -// Set a maximum number of courses. Default (0) = no limit\n -".'$'."_configuration['hosting_limit_courses'] = 0;\n -// Set a maximum number of sessions. Default (0) = no limit\n -".'$'."_configuration['hosting_limit_sessions'] = 0;\n -// Set a maximum disk space used, in MB (set to 1024 for 1GB, 5120 for 5GB).\n -// Default (0) = no limit\n -".'$'."_configuration['hosting_limit_disk_space'] = 0;\n -"; - fwrite($fh, $string); - fwrite($fh, '?>'); - fclose($fh); - //Adds events.conf file - if (! file_exists(api_get_path(CONFIGURATION_PATH).'events.conf.php')) { - copy(api_get_path(CONFIGURATION_PATH).'events.conf.dist.php', api_get_path(CONFIGURATION_PATH).'events.conf.php'); - } - -} else { - - echo 'You are not allowed here !'. __FILE__; -} diff --git a/main/install/version.php b/main/install/version.php index 9ccd6283fd..ca7b7d00f6 100755 --- a/main/install/version.php +++ b/main/install/version.php @@ -2,20 +2,21 @@ /* For licensing terms, see /license.txt */ /** * This script lists the necessary variables that allow the installation - * system to know in which version is the current Chamilo install. This + * system to know in which version is the current Chamilo install. This * script should be overwritten with each upgrade of Chamilo. It is not * required from any other process of Chamilo than the installation or upgrade. * It also helps for automatic packaging of unstable versions. - * + * * @package chamilo.install */ + /** * Variables used from the main/install/index.php */ -$new_version = '1.10.0'; -$new_version_status = 'alpha'; -$new_version_last_id = 0; -$new_version_stable = false; -$new_version_major = true; -$software_name = 'Chamilo'; -$software_url = 'http://www.chamilo.org/'; +$new_version = '1.10.0'; +$new_version_status = 'alpha'; +$new_version_last_id = 0; +$new_version_stable = false; +$new_version_major = true; +$software_name = 'Chamilo'; +$software_url = 'http://www.chamilo.org/'; diff --git a/main/link/category_form.class.php b/main/link/category_form.class.php deleted file mode 100755 index 8389483df3..0000000000 --- a/main/link/category_form.class.php +++ /dev/null @@ -1,75 +0,0 @@ - for the Univesity of Genevas - * @license /license.txt - */ -class CategoryForm extends \FormValidator -{ - - protected $category; - - function __construct($form_name = 'category', $method = 'post', $action = '', $target = '', $attributes = null, $track_submit = true) - { - parent::__construct($form_name, $method, $action, $target, $attributes, $track_submit); - } - - /** - * - * @return object - */ - public function get_category() - { - return $this->category; - } - - public function set_category($value) - { - $this->category = $value; - } - /** - * - * @param \Link\LinkCategory $category - */ - function init($category = null) - { - $this->set_category($category); - - $defaults = array(); - $defaults['category_title'] = $category->category_title; - $defaults['category_description'] = $category->description; - - $this->addElement('hidden', 'c_id', $category->c_id); - $this->addElement('hidden', 'id', $category->id); - $this->addElement('hidden', 'session_id', $category->session_id); - - $form_name = $category->id ? get_lang('ModifyCategory') : get_lang('AddCategory'); - $this->addHeader($form_name); - $this->addText('category_title', get_lang('Title')); - $this->addRule('category_title', get_lang('Required'), 'required'); - - $this->addElement('textarea', 'category_description', get_lang('Description')); - $this->addElement('button', 'save', get_lang('Save'), array('class' => 'btn save')); - $this->setDefaults($defaults); - } - - function update_model() - { - $values = $this->exportValues(); - $category = $this->get_category(); - $category->category_title = $values['category_title']; - $category->description = $values['category_description']; - } -} diff --git a/main/link/import_csv.class.php b/main/link/import_csv.class.php deleted file mode 100755 index 3739ae4524..0000000000 --- a/main/link/import_csv.class.php +++ /dev/null @@ -1,188 +0,0 @@ - - */ -class ImportCsv -{ - - protected $c_id; - protected $session_id; - protected $path; - protected $links_imported = 0; - protected $links_skipped = 0; - protected $update_existing_entries = false; - - public function __construct($c_id, $session_id, $path, $update_existing_entries = false) - { - $this->c_id = $c_id; - $this->session_id = $session_id; - $this->path = $path; - $this->update_existing_entries = $update_existing_entries; - } - - public function get_path() - { - return $this->path; - } - - public function get_c_id() - { - return $this->c_id; - } - - public function get_session_id() - { - return $this->session_id; - } - - public function get_links_imported() - { - return $this->links_imported; - } - - public function get_links_skipped() - { - return $this->links_skipped; - } - - public function get_update_existing_entries() - { - return $this->update_existing_entries; - } - - /** - * Read file and returns an array filled up with its' content. - * - * @return array of objects - */ - public function get_data() - { - $result = array(); - - $path = $this->path; - if (!is_readable($path)) { - return array(); - } - - $items = \Import::csv_reader($path); - foreach ($items as $item) { - $item = (object) $item; - $url = isset($item->url) ? trim($item->url) : ''; - $title = isset($item->title) ? trim($item->title) : ''; - $description = isset($item->description) ? trim($item->description) : ''; - $target = isset($item->target) ? trim($item->target) : ''; - $category_title = isset($item->category_title) ? trim($item->category_title) : ''; - $category_description = isset($item->category_description) ? trim($item->category_description) : ''; - if (empty($url)) { - continue; - } - if ($category_title) { - $category_title = \Security::remove_XSS($category_title); - $category_description = \Security::remove_XSS($category_description); - } else { - $category_description = ''; - } - - $url = \Security::remove_XSS($url); - $title = \Security::remove_XSS($title); - $description = \Security::remove_XSS($description); - $target = \Security::remove_XSS($target); - - $item->url = $url; - $item->title = $title; - $item->description = $description; - $item->target = $target; - $item->category_title = $category_title; - $item->category_description = $category_description; - $result[] = $item; - } - return $result; - } - - public function run() - { - $path = $this->path; - if (!is_readable($path)) { - return false; - } - $this->links_imported = 0; - $this->links_skipped = 0; - - $items = $this->get_data(); - foreach ($items as $item) { - $url = $item->url; - $title = $item->title; - $description = $item->description; - $target = $item->target; - $category_title = $item->category_title; - $category_description = $item->category_description; - - if ($category_title) { - $category = $this->ensure_category($category_title, $category_description); - } - - $link = $this->find_link_by_url($url); - if ($link && $this->update_existing_entries == false) { - $this->links_skipped++; - continue; - } - if (empty($link)) { - $link = new Link(); - $link->c_id = $this->c_id; - $link->session_id = $this->session_id; - $link->url = $url; - } - - $link->title = $title; - $link->description = $description; - $link->target = $target; - $link->category_id = $category ? $category->id : 0; - $repo = LinkRepository::instance(); - $repo->save($link); - $this->links_imported++; - } - } - - public function ensure_category($title, $description = '') - { - $c_id = $this->c_id; - $session_id = $this->session_id; - $repo = LinkCategoryRepository::instance(); - $result = $repo->find_one_by_course_and_name($c_id, $session_id, $title); - if (empty($result)) { - $result = new LinkCategory(); - $result->c_id = $c_id; - $result->category_title = $title; - $result->description = $description; - $result->session_id = $session_id; - $repo->save($result); - } - return $result; - } - - public function find_link_by_url($url) - { - $c_id = $this->c_id; - $session_id = $this->session_id; - $repo = LinkRepository::instance(); - $link = $repo->find_one_by_course_and_url($c_id, $session_id, $url); - return $link; - } - -} diff --git a/main/link/resources/js/main.js b/main/link/resources/js/main.js deleted file mode 100755 index b4cd8e7f2b..0000000000 --- a/main/link/resources/js/main.js +++ /dev/null @@ -1,105 +0,0 @@ - -function Proxy() {}; - -Proxy.prototype.root = function(){ - return www + '/main/inc/ajax/link.ajax.php'; -} - -Proxy.prototype.post = function(data, f){ - if(typeof(sec_token)!=='undefined'){ - data.sec_token = sec_token; - } - $.post(this.root(), data, f, 'json'); -} - -var Link = new Proxy(); - -Link.hide = function(c_id, id, f) -{ - var data = { - c_id: c_id, - id: id, - action: 'hide_link' - }; - this.post(data, f); -}; - -Link.show = function(c_id, id, f) -{ - var data = { - c_id: c_id, - id: id, - action: 'show_link' - }; - this.post(data, f); -}; - -Link.del = function(c_id, id, f) -{ - var data = { - c_id: c_id, - id: id, - action: 'delete_link' - }; - this.post(data, f); -}; - -Link.delete_by_course = function(c_id, session_id, f) -{ - var data = { - c_id: c_id, - session_id: session_id, - action: 'delete_by_course' - }; - this.post(data, f); -}; - -Link.sort = function(c_id, ids, f){ - var data = { - c_id: c_id, - ids: ids, - action: 'sort_links' - }; - this.post(data, f); -}; - -Link.validate = function(c_id, id, f) -{ - var data = { - c_id: c_id, - id: id, - action: 'validate_link' - }; - this.post(data, f); -}; - - - -var LinkCategory = new Proxy(); - -LinkCategory.del = function(c_id, id, f) -{ - var data = { - c_id: c_id, - id: id, - action: 'delete_category' - }; - this.post(data, f); -}; - -LinkCategory.sort = function(c_id, ids, f){ - var data = { - c_id: c_id, - ids: ids, - action: 'sort_categories' - }; - this.post(data, f); -}; - - -var message = {}; - -message.update = function(data){ - text = typeof(data)=='string' ? data : data.message; - $('#messages').html(text) -} \ No newline at end of file diff --git a/main/messages/new_message.php b/main/messages/new_message.php index 995f4af2fc..9669b904a7 100755 --- a/main/messages/new_message.php +++ b/main/messages/new_message.php @@ -254,11 +254,7 @@ function manage_form($default, $select_from_user_list = null, $sent_to = null) $parent_id ); if ($res) { - if (is_string($res)) { - $html .= Display::return_message($res, 'error'); - } else { - $html .= MessageManager::display_success_message($user); - } + $html .= MessageManager::display_success_message($user); } } } else { @@ -384,8 +380,8 @@ if (api_get_setting('allow_social_tool') == 'true') { $tpl->display($social_layout); } else { $content = $social_right_content; - $tpl->assign('actions', $actions); - $tpl->assign('message', $show_message); + //$tpl->assign('actions', $actions); + //$tpl->assign('message', $show_message); $tpl->assign('content', $content); $tpl->display_one_col_template(); } diff --git a/main/messages/outbox.php b/main/messages/outbox.php index 7166aba7b4..c8eae17aac 100755 --- a/main/messages/outbox.php +++ b/main/messages/outbox.php @@ -27,9 +27,7 @@ if (api_get_setting('allow_message_tool')!='true'){ //jquery thickbox already called from main/inc/header.inc.php $htmlHeadXtra[]=' - - - - - - - - -

    - -
    - -  Click a keyword in the tree to select or deselect it. -
    - -
    -
    - Click '+' button to open, '-' button to close, '++' button to open all, '--' button to close all.
    -
    - Clear all selected keywords by closing the tree and opening it again with the '+' button.
    - Alt-click '+' searches the current keywords in the tree.
    - Control-Alt-click '+' searches the keywords of the current slide.
    -
    - Alt-click keyword selects a keyword without broader terms or - deselects a keyword with broader terms.

    - Selected keywords are available in the Clipboard.
    -
    - 'nei' stands for 'not elswhere included'.

    -
    - -
    - - -   -
    - -
    - - - - - - - - - - - - - - -
    - - - - - - - -   - - - - - - - - - -
    - - - -
    -
    - - - - \ No newline at end of file diff --git a/main/metadata/doc/dcex.php b/main/metadata/doc/dcex.php deleted file mode 100755 index 64aaf11b5b..0000000000 --- a/main/metadata/doc/dcex.php +++ /dev/null @@ -1,23 +0,0 @@ -mds_get_dc_elements($mdObj))) { - echo '
    ', htmlspecialchars($dcelems['Identifier']), ': ', - htmlspecialchars($dcelems['Description']), '
    '; -} -// Store example: -$langMdCopyright = 'Provided the source is acknowledged'; -$mdStore->mds_put_dc_elements($mdObj, array('Description'=>time())); diff --git a/main/metadata/doc/imsmanifest_reload.xml b/main/metadata/doc/imsmanifest_reload.xml deleted file mode 100755 index 3aee83d1a5..0000000000 --- a/main/metadata/doc/imsmanifest_reload.xml +++ /dev/null @@ -1,189 +0,0 @@ - - - - - - IMS Content - 1.2.2 - - - - Summer Pictures - - - - - - - - en - - Simple exemplar content package - - - Exemplar - - - - LOMv1.0 - - - Linear - - - - - - 0.1 - - - - LOMv1.0 - - - Draft - - - - - - - - LOMv1.0 - - - Creator - - - - BEGIN:VCARD FN:Dr.Colin D. Milligan END:VCARD - - - 2003-07-08 - - - UKCMF - en - - - text/html - http://www.reload.ac.uk/ex/testpkg.zip - - - - - - - - LOMv1.0 - - - no - - - - - LOMv1.0 - - - no - - - - This content is copyright free. - - - - - BEGIN:VCARD FN:Dr.Colin D. Milligan END:VCARD - - - 2003-07-08 - - - These materials are very simplistic. - - - - - - - Summer Pictures - - Loch Katrine - - - Ben Ledi - - - Jencks Earthwork - - - MSP Cells - - - Holyrood Building Site - - - Salisbury Crags - - - Castle Sunset - - - Bridges Sunset - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/main/metadata/doc/mdApiTest.php b/main/metadata/doc/mdApiTest.php deleted file mode 100755 index 087752962b..0000000000 --- a/main/metadata/doc/mdApiTest.php +++ /dev/null @@ -1,140 +0,0 @@ -mdo_eid; - - $titlePath = $mdObj->mdo_dcmap_v['Title']; // no IEEE dependencies here... - - if (($mdt_rec = $mdStore->mds_get($eid)) === FALSE) - { - $mdt = $mdObj->mdo_generate_default_xml_metadata(); - - $xmlDoc = new xmddoc(explode("\n", $mdt)); - if (!$xmlDoc->error) - { - echo htmlspecialchars($titlePath), ': '; - $mdTitle = $xmlDoc->xmd_value($titlePath); - if ($mdTitle == $langMdTitle) - { - $mdTitle = EID_TYPE . ' ' . $eid_id; - $xmlDoc->xmd_update($titlePath, $mdTitle); - $mdt = $xmlDoc->xmd_xml(); - } - echo htmlspecialchars($mdTitle), ':'; - } - - $mdStore->mds_put($eid, $mdt, 'mdxmltext', FALSE); - echo '', - htmlspecialchars($eid), '
    '; - } -} -echo '
    '; - - -$xmlDoc = new xmddoc(explode("\n", $mdStore->mds_get($eid = EID_TYPE . '.1002'))); -if ($xmlDoc->error) give_up($xmlDoc->error); - -$mdObj = new mdobject($_course, '1002'); -$mda = "~~"; // delete metadata of 'Document.1002' -$mdt = $mdStore->mds_update_xml_and_mdt($mdObj, $xmlDoc, $mda, $eid, $trace); -// note: $xmlDoc and $trace are passed by reference... - - -$mdObj = new mdobject($_course, '1003'); -$xmlDoc = new xmddoc(explode("\n", $mdStore->mds_get($eid = EID_TYPE . '.1003'))); -if ($xmlDoc->error) give_up($xmlDoc->error); - -$map_lang = 'string/@language'; -$dcmap_e_kwplace = 'metadata/lom/general'; $dcmap_e_kwelem = 'keyword'; -$dcmap_e_keyword = $dcmap_e_kwplace . '/' . $dcmap_e_kwelem; - -$mda = $mdObj->mdo_dcmap_v['Description'] . '=Nouvelle description' . - "\n" . $mdObj->mdo_dcmap_e['Coverage'] . "~" . - "\n" . $dcmap_e_kwplace . '!' . $dcmap_e_kwelem . - "\n" . $dcmap_e_keyword . "[-1]!string=afrique" . - "\n" . $dcmap_e_keyword . "[-1]/" . $map_lang . "=en" . - "\n" . $mdObj->mdo_dcmap_e['Title'] . ',' . - $mdObj->mdo_dcmap_e['Description'] . ',' . - $dcmap_e_keyword . ";" . $map_lang . "=fr" . - ""; // update metadata of 'Document.1003' - see md_funcs - // note we don't go far with IEEE independence... -$mdt = $mdStore->mds_update_xml_and_mdt($mdObj, $xmlDoc, $mda, $eid, $trace); - -echo htmlspecialchars($trace), '

    '; - - -// The simplest API calls: store and fetch DC metadata element values: - -$mdObj = new mdobject($_course, '1003'); -$mdStore->mds_put_dc_elements($mdObj, array('Coverage' => 'broad...', 'Type' => 'aggressive text')); -// Coverage won't work, because that element has been removed above... -$dcelem = $mdStore->mds_get_dc_elements($mdObj); -foreach (array('Identifier', 'Title', 'Language', 'Description', 'Coverage', - 'Type', 'Date', 'Creator', 'Format', 'Rights') as $dce) -{ - echo $dce, '= ', htmlspecialchars($dcelem[$dce]), '
    '; -} - -echo '
    '; - -$mdObj = new mdobject($_course, '1002'); -$mdStore->mds_put_dc_elements($mdObj, array('Coverage' => 'broad...')); -$dcelem = $mdStore->mds_get_dc_elements($mdObj); -foreach (array('Identifier', 'Title', 'Language', 'Description', 'Coverage', - 'Type', 'Date', 'Creator', 'Format', 'Rights') as $dce) -{ - echo $dce, '= ', htmlspecialchars($dcelem[$dce]), '
    '; -} - -echo '
    '; - -$mdStore->mds_append(EID_TYPE . '.1001', ' search words'); -$mdStore->mds_append(EID_TYPE . '.1001', ' more findable terms'); - - -Display::display_footer(); -?> diff --git a/main/metadata/doc/mdp_scorm.htt b/main/metadata/doc/mdp_scorm.htt deleted file mode 100755 index d6d3543a55..0000000000 --- a/main/metadata/doc/mdp_scorm.htt +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - -{-D level {-V @level-}-}{-T level == 0 C SCORM0-}{-T level != 0 C SCORM123-} - - - - -

    {-X title-}

    - - - {-R child C SUBITEM-} -
    - - - - - - {-X @identifier-} - {-X title-} - - - - - -
    -{-D prv {-V previous/@identifier-}-}{-D nxt {-V next/@identifier-}-}{-D kwds {-X metadata/lom/general/keyword/string , -}-} - - - - - - - - - -
    - {-T prv != empty {-H {-P prv-}-}-}{-T prv == empty X @identifier-} - - {-X parent/@identifier-} - - {-T nxt != empty {-H {-P nxt-}-}-}{-T nxt == empty X @identifier-} -
    {-X @identifier-}: {-X title-}
    - - - - -{-X title-} - - - - -Expires: Mon, 26 Jul 1997 05:00:00 GMT - - - \ No newline at end of file diff --git a/main/metadata/doc/testMiniDom.php b/main/metadata/doc/testMiniDom.php deleted file mode 100755 index 0a03fb186c..0000000000 --- a/main/metadata/doc/testMiniDom.php +++ /dev/null @@ -1,241 +0,0 @@ -= PHP 4.3.0 - - return str_replace("\r", "\n", str_replace("\r\n", "\n", $buffer)); -} - - -require("../../inc/lib/xmd.lib.php"); - - -$testdoc = new xmddoc(''); // docroot is element 0 - - -function showDoc($title, $morestuff = '') -{ - global $testdoc; echo '

    ', $title, '

    ', '
    ',
    -        htmlspecialchars($morestuff ? $morestuff : $testdoc->xmd_xml()), '
    '; -} - - -$sometag1 = $testdoc->xmd_add_element('sometag'); -$testdoc->xmd_set_attribute(0, 'owner', 'rene'); -$testdoc->xmd_add_text('text in my first child element', $sometag1); - -showDoc('Small XML document'); - -$sometag2 = $testdoc->xmd_add_element('sometag', 0, array('x' => 'somevalue')); -$testdoc->xmd_add_text('bizarre in "my& 2nd child', $sometag2); -$testdoc->xmd_add_text(' + more text in first one', $sometag1); -$testdoc->xmd_set_attribute($sometag2, 'owner', ''); -$testdoc->xmd_add_element('innertag', $sometag2); - -showDoc('Slightly changed'); - -showDoc('All text', $testdoc->xmd_text()); - -$stuff = ''; -foreach ($testdoc->xmd_get_element($sometag2) as $key => $value) - $stuff .= $key . ': ' . $value . "\n"; - -showDoc('Children, attributes, name and parent of 2nd sometag', $stuff); - -$testdoc->xmd_remove_nodes('text in my first child element', $sometag1); -// note: remove text may remove more than one node... -$testdoc->xmd_set_attribute(0, 'owner', 'haentjens'); // new value - -showDoc('Text removed from 1st sometag, docroot owner changed'); - -$testdoc->xmd_remove_element($sometag2); -$sometag2 = $testdoc->xmd_add_text_element('��', 'alors!'); - -showDoc('2nd sometag replaced by new subelement with French name'); - -$testdoc->name[$sometag2] = 'sometag'; // properties are read/write -$testdoc->xmd_set_attribute($sometag2, 'xmlns:tn', 'urn:ugent-be'); // namesp def -$subtag = $testdoc->xmd_add_element('urn:ugent-be:subtag', $sometag2); -$testdoc->xmd_set_attribute($sometag2, 'urn:ugent-be:owner', 'FTW'); - -showDoc('French name replaced, namespace definition added and used'); - -$testdoc->xmd_set_attribute($sometag1, 'urn:ugent-be:owner', 'FTW'); -$testdoc->xmd_set_attribute($sometag1, 'urn:rug-ac-be:owner2', 'FLA'); -// restriction: cannot add attribute 'urn:rug-ac-be:owner' (same name) - -showDoc('Attributes with namespaces added, ns def is auto-generated'); - -$stuff = 'subtag => ' . $testdoc->xmd_get_ns_uri($subtag) . "\n"; -foreach ($testdoc->attributes[$sometag1] as $name => $value) - $stuff .= $name . ' => ' . $testdoc->xmd_get_ns_uri($sometag1, $name) . "\n"; - -showDoc('Namespace-URI of subtag, of 1st sometag attributes', $stuff); - -$subsub = $testdoc->xmd_add_element('urn:sample-default:subsub', $subtag, - array('xmlns' => 'urn:sample-default', 'someatt' => 'somevalue')); -$subsubsub = $testdoc->xmd_add_element('urn:sample-default:subsubsub', $subsub); - -showDoc('Subsub element has default namespace'); - -$stuff = 'subsub => ' . $testdoc->xmd_get_ns_uri($subsub) . "\n"; -$stuff .= 'subsubsub => ' . $testdoc->xmd_get_ns_uri($subsubsub) . "\n"; -foreach ($testdoc->attributes[$subsub] as $name => $value) - $stuff .= $name . ' => ' . $testdoc->xmd_get_ns_uri($subsub, $name) . "\n"; - -showDoc('Namespace-URI of subsub and subsubsub; attributes have none', $stuff); - -$testdoc->xmd_update('!newtag', 'text for newtag'); -showDoc("After update '!newtag', 'text for newtag'"); - -$testdoc->xmd_update('newtag', 'new text for newtag'); -showDoc("After update 'newtag', 'new text for newtag'"); - -$testdoc->xmd_update('newtag/@someatt', 'attval'); -showDoc("After update 'newtag/@someatt', 'attval'"); - -$testdoc->xmd_update('newtag/~', ''); -showDoc("After update 'newtag/~', ''"); - -$keepdoc = $testdoc; - -$wrongdoc = "\n \n

    Text

    \n

    More text" . - "\n \n"; -$testdoc = new xmddoc(explode("\n", $wrongdoc)); - -showDoc('Xml doc with syntax error + error message', - $wrongdoc . "\n\n" . $testdoc->error); - -$xmlFile = 'imsmanifest_reload.xml'; - -($presXmlFileContents = @file_get_contents_n($xmlFile)) - or die('XML file ' . htmlspecialchars($xmlFile) . ' is missing...'); - -showDoc('XML file to be parsed', $presXmlFileContents); - -$testdoc = new xmddoc(explode("\n", $presXmlFileContents)); -unset($presXmlFileContents); - -if ($testdoc->error) die($xmlFile . ':

    ' . $testdoc->error); - -$testdoc->xmd_update_many('metadata/lom/general/title,metadata/lom/general/description', 'langstring/@lang', 'fr'); -$testdoc->xmd_copy_foreign_child($keepdoc, $keepdoc->xmd_select_single_element('sometag[2]')); - -showDoc('After parsing, and after changing 2* langstring/@lang to fr, ' . - 'and after adding a foreign doc, reconstruction from memory'); - -showDoc('Element tagname of first metadata/lom/* element', - $testdoc->name[$testdoc->xmd_select_single_element('metadata/lom/*')]); - -showDoc('Element namespace URI of metadata/lom/*[2]', - $testdoc->xmd_get_ns_uri($testdoc->xmd_select_single_element('metadata/lom/*[2]'))); - -showDoc('Number of metadata/lom/* elements', - count($testdoc->xmd_select_elements('metadata/lom/*'))); - -showDoc('Number of resources/resource/file elements with @href', - count($testdoc->xmd_select_elements_where_notempty( - 'resources/resource/file', '@href'))); - -$elems = $testdoc->xmd_select_elements_where('resources/resource', - 'file[1]/@href', 'three.html'); -showDoc('Resource identifier where file[1]/@href is three.html', - $testdoc->xmd_value('@identifier', $elems[0])); - -$elems = $testdoc->xmd_select_elements_where('resources/resource', '@identifier', - $testdoc->xmd_value('organizations/organization/item[2]/@identifierref')); -showDoc('Resource href for item[2]', - $testdoc->xmd_value('@href', $elems[0])); - -$stuff = ''; -foreach (array('@identifier', 'metadata/schema', '*/*/*/*[1]/langstring', - 'resources/resource[3]/@href', 'resources/resource[3]/file/@href', - 'resources/resource[3]/@*', 'resources/resource[3]/-/@href', - 'resources/resource[3]/+/@href', 'resources/resource[1]/-/@href', - 'resources/../../../../../../../@identifier', '@*', 'resources/@*', - 'organizations/organization/item[4]/title', - 'organizations/organization/item[-2]/title', - 'organizations/organization/item[4]/@*', - 'organizations/organization/item[4]/@*item', - 'organizations/organization/item[2]/+item/title', - 'organizations/organization/item[2]/+/+/+/title', - 'organizations/organization/item[2]/-item', - 'organizations/organization/item[1]/-item', - 'organizations/organization/item[1]/-', - 'organizations/organization/item[1]/-/@.' - ) as $path) - $stuff .= $path . ' => ' . $testdoc->xmd_value($path) . "\n"; - -showDoc('Values of: @identifier, metadata/schema, ... (see below)', $stuff); - - -function showHtml($path) -{ - global $testdoc; echo '

    Html-value of ', htmlspecialchars($path), - '

    ', $testdoc->xmd_html_value($path), '
    '; -} - - -showHtml('/*/organizations/organization/item[1]/title'); - -showHtml('organizations/organization/item/title'); - -showHtml('organizations/organization/item/title *'); - -showHtml('Titles: -% organizations/organization/item/titl , %- .'); -// if no elements are found, prefix and postfix are not generated - -showHtml('Titles: -% organizations/organization/item/title , %- .'); - -showHtml('
    • -% resources/resource/file/../@identifier
    • %-
    '); - -showHtml('metadata/lom/general/description/langstring'); -echo '
    The same, but in a HTML construct:
    ', - $testdoc->xmd_html_value('metadata/lom/general/description/langstring'); - - -function getmicrotime() -{ - list($usec, $sec) = explode(" ",microtime()); - return ((float)$usec + (float)$sec); -} - -$xmlFile = 'imsmanifest_reload.xml'; - -($presXmlFileContents = @file_get_contents_n($xmlFile)) - or die('XML file ' . htmlspecialchars($xmlFile) . ' is missing...'); -$presXmlFileContents = explode("\n", $presXmlFileContents); - -$seconds = getmicrotime(); -$testdoc2 = new xmddoc($presXmlFileContents); -$seconds = getmicrotime() - $seconds; - -showDoc('Time to parse', $seconds); - -$seconds = getmicrotime(); -$testdoc2->xmd_cache(); -$seconds = getmicrotime() - $seconds; - -showDoc('Time to cache', $seconds); - -$seconds = getmicrotime(); -$testdoc = new xmddoc($testdoc2->names, $testdoc2->numbers, - $testdoc2->textstring); -$seconds = getmicrotime() - $seconds; - -showDoc('Time to restore from cache', $seconds); - -showDoc('OK after restore'); -?> diff --git a/main/metadata/doc/testXht.php b/main/metadata/doc/testXht.php deleted file mode 100755 index 2876f33b23..0000000000 --- a/main/metadata/doc/testXht.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @package chamilo.metadata - */ -/** - * Chamilo Metadata: XHT test and demo - */ - -require('../../inc/lib/xmd.lib.php'); -require('../../inc/lib/xht.lib.php'); - - -// XML DOCUMENT ---------------------------------------------------------------> - -$testdoc = new xmddoc( -<< - Test for XML HTML Templates - This is a [b]test[/b] for &#911; XML with <some> "funny" stuff... - a new line and 1 inside tag. - - kw1 - kw2 - kw3 - - - IMS Content - 1.2.2 - - - - - - - - - en - - Simple exemplar content package - - -, this description was - modified -by - René - - - - - -
    -EOD -); - -if ($testdoc->error) die($testdoc->error); - - -// TEMPLATES ------------------------------------------------------------------> - -$xhtDoc = new xhtdoc( -<< - -Expires: Mon, 26 Jul 1997 05:00:00 GMT - - - - - - - - - -

    testXht

    - -

    {-X title-}

    - -Hello {-P p1-}! {-X description-}
    -{-X metadata/lom/general/description/langstring-}

    - -{-D label This is a funny -}{-C LABEL-}

    - - {-R keywords/keyword C KEYWORD-} -
    -There are {-R keywords/keyword P empty-}{-P number-} keywords...

    - - -

    - -{-R Langnames C LEVEL1-}

    - -{-D author {-V author-}-} -{-T author != empty -
    There is an author
    - - - -This text is re-calculated when the cache is no longer valid. - - - - -{-H {-P label-}-} :  - - - - - - {-D label {-L Kw-}-}{-C LABEL-}{-X .-} - - - - - - - - - - - -{-P rdepth-}.{-P key-}: {-R keywords/keyword C LEVEL2-}
    - - - - -{-P rdepth-}.{-P number-} - - - -EOD -); - -if ($xhtDoc->htt_error) die($xhtDoc->htt_error); - -$xhtDoc->xht_xmldoc = $testdoc; - - -// PREPARE FOR PROCESSING -----------------------------------------------------> - -function get_lang($word) -{ - if ($word == 'Kw') return 'Keyword'; - elseif ($word == 'Am') return '"Automatic"'; - elseif ($word == 'Langnames') - return array("de"=>"German", "fr"=>"French", "nl"=>"Dutch"); - else return 'To be translated'; -} - -$xhtDoc->xht_get_lang = 'get_lang'; - -$xhtDoc->xht_param['p1'] = 'world'; - -function md_cache($newtext) // callback from template (for cached HTML) -{ - if ($newtext === FALSE) // this is always the first callback - { - $cachedHtmlIsValid = FALSE; // in real examples, not always - - if ($cachedHtmlIsValid) - return 'Cached HTML'; - else - // do some preparations - return FALSE; // signals XHT to generate new text from template - } - else // after template expansion, XHT does a second callback - { - // store the new text in the cache... - // possibly modify the text to be output... - return $newtext; // often the output is identical to the new text - } -} - - -// GENERATE OUTPUT ------------------------------------------------------------> - -foreach (explode("\n", $xhtDoc->htt_array['HTTP']) as $httpXtra) - if ($httpXtra) header($httpXtra); - -echo "\n", $xhtDoc->xht_fill_template('HEAD'), - "\n\n\n\n"; - -$xhtDoc->xht_dbgn = 0; // for template debug info, set to e.g. 10000 - -echo $xhtDoc->xht_fill_template('MAIN'), - '

    Child nodes of "description":'; - -foreach($testdoc->children[$testdoc->xmd_select_single_element('description')] as $child) - echo '
    ', strlen($child), ': ', htmlspecialchars($child); -echo "\n\n\n\n"; - -if ($xhtDoc->xht_dbgn) echo $xhtDoc->xht_dbgo; - -// Note: XML document and templates would normally be fetched from (different) -// external sources, such as a file or a DB record... -?> diff --git a/main/metadata/importdocs.php b/main/metadata/importdocs.php deleted file mode 100755 index 43139ee4c0..0000000000 --- a/main/metadata/importdocs.php +++ /dev/null @@ -1,106 +0,0 @@ - -$getpostvars = array('dmo'); require('md_funcs.php'); - -define('EID_TYPE', 'Document'); define('AFTER_DOT', strlen(EID_TYPE) + 1); -define('OF_EID_TYPE', "eid LIKE '" . EID_TYPE . ".%'"); - -require('md_' . strtolower(EID_TYPE) . '.php'); - -// name of the language file that needs to be included -$language_file = 'md_' . strtolower(EID_TYPE); -include('../inc/global.inc.php'); -$nameTools = get_lang('Tool'); - -($nameTools && get_lang('Sorry')) or give_up( - 'Language file ' . $language_file . " doesn't define 'Tool' and 'Sorry'"); - -$_course = api_get_course_info(); isset($_course) or give_up(get_lang('Sorry')); - -$is_allowed_to_edit = isset($_user['user_id']) && $is_courseMember && api_is_allowed_to_edit(); -if (!$is_allowed_to_edit) give_up(get_lang('Denied')); - -$mdObj = new mdobject($_course, 0); -$mdStore = new mdstore($is_allowed_to_edit); // create table if needed - -require(api_get_path(LIBRARY_PATH) . 'xmd.lib.php'); -require(api_get_path(LIBRARY_PATH) . 'xht.lib.php'); - -require('md_phpdig.php'); - -$mdObj->mdo_add_breadcrump_nav(); // see 'md_' . EID_TYPE . '.php' - -$htmlHeadXtra[] = ' - - -'; -Display::display_header($nameTools); - - -if (isset($dmo)) // for future use -{ - echo '

    ', $dmo, '

    ', "\n"; // document metadata op - - // if ($dmo == get_lang('Index')) $dmo = $dmo; -} - -$result = $mdStore->mds_get_many('eid,indexabletext', OF_EID_TYPE); -echo get_lang('Tool'), ': ', Database::num_rows($result), "

    \n"; - -$idt = array(); $cidpar = '?cidReq=' . $_course['sysCode']; - -while ($row = Database::fetch_array($result)) // load indexabletexts in memory -{ - $mdObj = new mdobject($_course, substr($row['eid'], AFTER_DOT)); - $idt[$mdObj->mdo_url . $cidpar] = $row['indexabletext']; -} - -if (count($idt) && file_exists($phpDigIncCn)) -{ - require($phpDigIncCn); // switch to PhpDig DB - - foreach ($idt as $url => $text) - if (ereg('^http://([^/]+)/(.+)/([^/]+)\?cidReq=(.+)$', $url, $regs)) - { - $path = $regs[2] .'/'; $file = $regs[3] . '?cidReq=' . $regs[4]; - if ($site_id = remove_engine_entries('http://' . $regs[1] .'/', - $path, $file)) - { - echo '', "\n"; - index_words($site_id, $path, $file, - get_first_words($text, $path, $file), - get_keywords($text)); - echo '
    ', "\n"; - } - } - - if(isset($db)) - { - //mysql_select_db($_configuration['main_database'], $db); - Database::select_db($_configuration['main_database'], $db); - } -} -else -{ - echo 'No documents with metadata or no PhpDig in this course...
    '; -} - -if (false && file_exists($phpDigIncCn)) // future: buttons for operations -{ - echo '
    ', "\n", - '', "\n", - '', "\n", - '
    ', "\n"; -} - -Display::display_footer(); -?> diff --git a/main/metadata/importlinks.php b/main/metadata/importlinks.php deleted file mode 100755 index 7d2485a9aa..0000000000 --- a/main/metadata/importlinks.php +++ /dev/null @@ -1,355 +0,0 @@ - - -$getpostvars = array('lcn', 'slo'); require('md_funcs.php'); - -define('EID_TYPE', 'Link'); -define('OF_EID_TYPE', "eid LIKE '" . EID_TYPE . ".%'"); - -require('md_' . strtolower(EID_TYPE) . '.php'); - -// name of the language file that needs to be included -$language_file = 'md_' . strtolower(EID_TYPE); -include('../inc/global.inc.php'); -$nameTools = get_lang('Tool'); - -($nameTools && get_lang('Sorry')) or give_up( - 'Language file ' . $language_file . " doesn't define 'Tool' and 'Sorry'"); - -$_course = api_get_course_info(); isset($_course) or give_up(get_lang('Sorry')); - -$is_allowed_to_edit = isset($_user['user_id']) && $is_courseMember && api_is_allowed_to_edit(); -if (!$is_allowed_to_edit) give_up(get_lang('Denied')); - -$mdStore = new mdstore($is_allowed_to_edit); // create table if needed - -require(api_get_path(LIBRARY_PATH) . 'xmd.lib.php'); -require(api_get_path(LIBRARY_PATH) . 'xht.lib.php'); - -require('md_phpdig.php'); - -$mdObj = new mdobject($_course, 0); -$mdCat = $mdObj->mdo_dcmap_v['Coverage']; -$mdUrl = 'metadata/lom/technical/location[1]'; - -$mdObj->mdo_add_breadcrump_nav(); // see 'md_' . EID_TYPE . '.php' - -$htmldecode = array_flip(get_html_translation_table(HTML_SPECIALCHARS)); - - -function check_andor_get($row, $get = '', $check = '', $tobe = '') -{ - global $mdCat, $htmldecode; - - if (!$check && !$get) return FALSE; - - $regs = array(); // for use with ereg() - - if ($get == $mdCat && !$check) // cheat to be quicker - if (ereg('[^<]*([^<]+)<\/string>', - $row['mdxmltext'], $regs)) return strtr($regs[1], $htmldecode); - - if ($check == $mdCat && !$get) // cheat to be quicker - if (ereg('[^<]*([^<]+)<\/string>', - $row['mdxmltext'], $regs)) - return (strtr($regs[1], $htmldecode) == $tobe); - - $xmlDoc = new xmddoc(explode("\n", $row['mdxmltext'])); - if ($xmlDoc->error) return FALSE; - - if (!$check) return $xmlDoc->xmd_value($get); - - if ($xmlDoc->xmd_value($check) == $tobe) - return $get ? $xmlDoc->xmd_value($get) : TRUE; - - return FALSE; -} - - -function get_cat($catname) -{ - global $_course; $cateq = "category_title='". addslashes($catname) . "'"; - - $linkcat_table = Database::get_course_table(TABLE_LINK_CATEGORY); - $result = Database::query("SELECT id FROM $linkcat_table WHERE " . $cateq); - - if (Database::num_rows($result) >= 1 && ($row = Database::fetch_array($result))) - return $row['id']; // several categories with same name: take first - - return FALSE; -} - - -// SET CURRENT LINKS CATEGORY - HEADER ----------------------------------------> - -unset($lci); // category-id - -if (isset($lcn)) // category_title -{ - $lcn = substr(ereg_replace("[^\x20-\x7E\xA1-\xFF]", "", $lcn), 0, 255); - - $uceids = array(); $mceids = array(); - - $result = $mdStore->mds_get_many('eid,mdxmltext', OF_EID_TYPE); - - while ($row = Database::fetch_array($result)) - if (check_andor_get($row, '', $mdCat, $lcn)) $uceids[] = $row['eid']; - - if (($lci = get_cat($lcn)) !== FALSE) - { - $link_table = Database::get_course_table(TABLE_LINK); - $result = Database::query("SELECT id FROM $link_table WHERE category_id=" . $lci); - - while ($row = Database::fetch_array($result)) - { - $lceids[$id = (int) $row['id']] = ($eid = EID_TYPE . '.' . $id); - - if (in_array($eid, $uceids)) $mceids[] = $eid; - } - - $hdrInfo = ' ' . get_lang('WorkOn') . ' ' . htmlspecialchars($lcn, ENT_QUOTES, $charset) . - ', LC-id= ' . htmlspecialchars($lci, ENT_QUOTES, $charset); - } - elseif ($lcn) - { - $hdrInfo = ' (' . htmlspecialchars($lcn, ENT_QUOTES, $charset) . - ': ' . get_lang('NotInDB') . ')'; - } - else - unset($lcn); - - $uceids = array_diff($uceids, $mceids); // old entries with no link - - if (count($lceids) && count($uceids)) - { - $mdStore->mds_delete_many($uceids); $ufos = Database::affected_rows(); - } - - $interbreadcrumb[]= array( - 'url' => api_get_self() . '?lcn=' . urlencode($lcn), - 'name'=> get_lang('Continue') . ' ' . htmlspecialchars($lcn, ENT_QUOTES, $charset)); -} - -$htmlHeadXtra[] = ' - - -'; -Display::display_header($nameTools); - -// OPERATIONS -----------------------------------------------------------------> - -if ($ufos) echo '

    ', $ufos, ' ', get_lang('RemainingFor'), ' ', - htmlspecialchars($lcn, ENT_QUOTES, $charset), '

    ', "\n"; - -if (isset($slo)) echo '

    ', $slo, '

    ', "\n"; // selected links op - -if (isset($slo)) -if ($slo == get_lang('Create') && count($lceids)) -{ - foreach ($lceids as $id => $eid) - { - $mdObj = new mdobject($_course, $id); $xht = $mdObj->mdo_define_htt(); - $mdStore->mds_put($eid, $mdt = $mdObj->mdo_generate_default_xml_metadata(), - 'mdxmltext', '?'); - $xht->xht_xmldoc = new xmddoc(explode("\n", $mdt)); - $mdStore->mds_put($eid, $xht->xht_fill_template('INDEXABLETEXT'), - 'indexabletext'); - echo '", htmlspecialchars($eid, ENT_QUOTES, $charset), ' '; - } - echo '
    '; -} -elseif ($slo == get_lang('Remove') && count($lceids)) -{ - $mdStore->mds_delete_many($mceids); $aff = Database::affected_rows(); - - echo $aff, ' MDEs/ ', count($lceids), ' ', get_lang('MdCallingTool'), - '

    ', get_lang('AllRemovedFor'), - ' ', htmlspecialchars($lcn, ENT_QUOTES, $charset), '
    '; -} -elseif ($slo == get_lang('Remove') && count($mceids)) // obsolete category -{ - $mdStore->mds_delete_many($mceids); - - echo get_lang('AllRemovedFor'), ' ', htmlspecialchars($lcn, ENT_QUOTES, $charset), '
    '; -} -elseif ($slo == get_lang('Index') && file_exists($phpDigIncCn) && count($mceids)) -{ - $result = $mdStore->mds_get_many('eid,mdxmltext,indexabletext', - OF_EID_TYPE . " AND eid IN ('" . - implode("','", array_map('addslashes', $mceids)) . "')"); - - while ($row = Database::fetch_array($result)) // load indexabletexts in memory - $idt[check_andor_get($row, $mdUrl)] = $row['indexabletext']; - - require($phpDigIncCn); // switch to PhpDig DB - - foreach ($idt as $url => $text) - { - $pu = parse_url($url); - if (!isset($pu['scheme'])) $pu['scheme'] = "http"; - - if (isset($pu['host'])) - { - $url = $pu['scheme'] . "://" . $pu['host'] . "/"; $file = ''; - - if (($path = $pu['path'])) - if (substr($path, -1) == '/') $path = substr($path, 1); - else - { - $pi = pathinfo($path); $path = $pi['dirname']; - if ($path{0} == '\\') $path = substr($path, 1); - if ($path{0} == '/') $path = substr($path, 1) . '/'; - - $file = $pi['basename']; - } - - $file .= ($pu['query'] ? '?'.$pu['query'] : '') . - ($pu['fragment'] ? '#'.$pu['fragment'] : ''); - - - if ($site_id = remove_engine_entries($url, $path, $file)) - { - echo '', "\n"; - index_words($site_id, $path, $file, - get_first_words($text, $url . $path, $file), - get_keywords($text)); - echo '
    ', "\n"; - } - else - { - echo '', "\n"; - echo ''; - echo '
    ', htmlspecialchars($url, ENT_QUOTES, $charset), - '', htmlspecialchars($path, ENT_QUOTES, $charset), - '', htmlspecialchars($file, ENT_QUOTES, $charset), '
    ', "\n"; - } - } - elseif (isset($pu['scheme']) && $pu['scheme'] == 'mailto' && isset($pu['path'])) - { - if ($site_id = remove_engine_entries($url = 'mailto:' . $pu['path'], '')) - { - echo '', "\n"; - index_words($site_id, '', '', - get_first_words($text, $url, ''), - get_keywords($text)); - echo '
    ', "\n"; - } - else - { - echo '', "\n"; - echo ''; - echo '
    ', htmlspecialchars($url, ENT_QUOTES, $charset), - '', htmlspecialchars($path, ENT_QUOTES, $charset), - '', htmlspecialchars($file, ENT_QUOTES, $charset), '
    ', "\n"; - } - } - } - - if(isset($db)) - { - //mysql_select_db($_configuration['main_database'], $db); - Database::select_db($_configuration['main_database'], $db); - } -} -elseif ($slo == get_lang('Index')) -{ - echo 'Problem! PhpDig connect.php has gone ...'; -} - - -// STATISTICS -----------------------------------------------------------------> - -echo '

    ', get_lang('Statistics'), '

    ', "\n"; - -$result = $mdStore->mds_get_many('eid,mdxmltext', OF_EID_TYPE); -echo get_lang('TotalMDEs'), Database::num_rows($result), "\n"; - -while ($row = Database::fetch_array($result)) -{ - $cat = check_andor_get($row, $mdCat); - $perCat[$cat] = ($pc = $perCat[$cat]) ? $pc + 1 : 1; -} - -if (count($perCat)) -{ - echo '', "\n"; - foreach ($perCat as $cat => $number) - { - echo '', "\n"; - } - echo '
    ', $cat == $lcn ? '' : '(', htmlspecialchars($cat, ENT_QUOTES, $charset), - $cat == $lcn ? '' : ')', ':', - $number, '
    ', "\n"; -} - -if (isset($lci)) -{ - echo '

    ', htmlspecialchars($lcn, ENT_QUOTES, $charset), ' ', get_lang('MdCallingTool'), - ': ', count($lceids), '
    ', "\n"; -} - - - -// SELECT & FOOTER ------------------------------------------------------------> - -echo '

    ', $nameTools, $hdrInfo, '

    ', "\n"; - -echo '
    ', "\n"; - -if (count($lceids)) echo - '', "\n"; -if ($perCat[$lcn]) echo - '', "\n"; -if ($perCat[$lcn] && file_exists($phpDigIncCn)) echo - '', "\n"; - -echo '
    ', "\n"; - -if (count($perCat)) foreach ($perCat as $cat => $number) - $perCat[$cat] = '(' . htmlspecialchars($cat, ENT_QUOTES, $charset) . ')'; - -$linkcat_table = Database::get_course_table(TABLE_LINK_CATEGORY); -$result = Database::query("SELECT category_title FROM $linkcat_table"); - -while ($row = Database::fetch_array($result)) -{ - $cat = $row['category_title']; $hcat = htmlspecialchars($cat, ENT_QUOTES, $charset); - if ($perCat[$cat] == $hcat) $dups[] = $cat; - else $perCat[$cat] = $hcat; -} - -if (count($dups)) -{ - $warning = get_lang('WarningDups');; - - foreach ($dups as $cat) unset($perCat[$cat]); -} - -echo '

    ', get_lang('OrElse'), $warning, '

    ', "\n", // select new target - '
    ', "\n", - '
    ', "\n", - get_lang('SLC'), ' :', "\n", '', "\n", - '
    ', "\n", '
    ', "\n"; - -Display::display_footer(); -?> diff --git a/main/metadata/importmanifest.php b/main/metadata/importmanifest.php deleted file mode 100755 index 15ab0d7f41..0000000000 --- a/main/metadata/importmanifest.php +++ /dev/null @@ -1,662 +0,0 @@ - - -$getpostvars = array('sdisub','workWith','sdi','smo'); require('md_funcs.php'); - -define('EID_TYPE', 'Scorm'); define('TPLEN', strlen(EID_TYPE) + 1); - -require('md_' . strtolower(EID_TYPE) . '.php'); - -// name of the language file that needs to be included -$language_file = 'md_' . strtolower(EID_TYPE); -include('../inc/global.inc.php'); -$nameTools = get_lang('Tool'); - -if (!isset($sdisub)) $sdisub = ''; -$sdisub = substr(ereg_replace("[^0-9A-Za-z]", "", $sdisub), 0, 4); -// $sdisub is for split manifests - Scorm.NNN.$sdisub_xxx e.g. Scorm.3.1979_12 - -define('MFFNAME', 'imsmanifest'); define('MFFDEXT', '.xml'); -define('HTF', 'mdp_scorm.htt'); - -$regs = array(); - -($nameTools && get_lang('Sorry')) or give_up( - 'Language file ' . $language_file . " doesn't define 'Tool' and 'Sorry'"); - -$_course = api_get_course_info(); isset($_course) or give_up(get_lang('Sorry')); - -$is_allowed_to_edit = isset($_user['user_id']) && $is_courseMember && api_is_allowed_to_edit(); -if (!$is_allowed_to_edit) give_up(get_lang('Denied')); - -$baseWorkDir = get_course_path() . ($courseDir = $_course['path'] . '/scorm'); - -$mdStore = new mdstore($is_allowed_to_edit); // create table if needed - -require(api_get_path(LIBRARY_PATH) . 'xmd.lib.php'); -require(api_get_path(LIBRARY_PATH) . 'xht.lib.php'); - -require('md_phpdig.php'); - - -// SET CURRENT SCORM DIRECTORY - HEADER ---------------------------------------> - -if (isset($workWith)) // explicit in URL, or selected at bottom of screen -{ - $scormdocument = Database::get_course_table(TABLE_LP_MAIN); - $sql = "SELECT id FROM $scormdocument WHERE path='". Database::escape_string(api_substr($workWith,1)) . "' OR path='". Database::escape_string(substr($workWith,1)) . "/.'"; - $result = Database::query($sql); - - if (Database::num_rows($result) == 1) - { - if (($row = Database::fetch_array($result))) - { - $sdi = $row['id']; - } - } -} - -if (isset($sdi) && is_numeric($sdi) && $sdi > 0 && $sdi == (int) $sdi) -{ - $mdObj = new mdobject($_course, $sdi); $workWith = $mdObj->mdo_path; - $hdrInfo = ' ' . get_lang('WorkOn') . ' ' . - ($workWith ? htmlspecialchars($workWith, ENT_QUOTES, $charset) . ', ' : '') . - 'SD-id= ' . htmlspecialchars($sdi, ENT_QUOTES, $charset) . - ($sdisub ? ' (' . htmlspecialchars($sdisub, ENT_QUOTES, $charset) . ')' : ''); -} -else -{ - unset($sdi); $mdObj = new mdobject($_course, 0); - if ($workWith) $hdrInfo = ' (' . htmlspecialchars($workWith, ENT_QUOTES, $charset) . - ': ' . get_lang('NotInDB') . ')'; unset($workWith); -} - -define('UZYX', 'UZYX'); // magic word to repeat for all $sdisub - -if (($sdiall = ($sdisub == UZYX))) -{ - $sdisub = ''; $sdiall = array(); - if (($dh = opendir($baseWorkDir . $workWith))) - { - while (FALSE !== ($file = readdir($dh))) - if (ereg('^'.MFFNAME.'(.+)\\'.MFFDEXT .'$', $file, $regs)) - $sdiall[] = $regs[1]; - closedir($dh); - } - sort($sdiall); -} - -$originalHdrInfo = $hdrInfo; - -function slurpmanifest() -{ - global $baseWorkDir, $workWith, $sdisub, $mfContents, $xht_doc, $charset; - $fmff = $baseWorkDir .'/'. $workWith . '/' . MFFNAME . $sdisub . MFFDEXT; - if (file_exists($fmff)) - { - if (($mfContents = @fgc($fmff))) - { - set_time_limit(120); // for analyzing the manifest file - $xht_doc = new xmddoc(explode("\n", $mfContents)); - if (!$xht_doc->error) return ''; // keeping $mfContents and $xht_doc - - unset($mfContents); - return get_lang('ManifestSyntax') . ' ' . htmlspecialchars($xht_doc->error, ENT_QUOTES, $charset); - } - else - { - return get_lang('EmptyManifest'); - } - } - else - { - return get_lang('NoManifest'); - } -} - -if (isset($workWith)) // now checked to be a valid path in scormdocument -{ - if ($mdObj->mdo_filetype == 'folder') // a folder with a manifest? - { - if (($errmsg = slurpmanifest())) $hdrInfo .= ' ' . $errmsg; - } - else - { - $hdrInfo .= ' ' . get_lang('NotFolder'); unset($sdi); - } -} - -$mdObj->mdo_add_breadcrump_nav(); // see 'md_' . EID_TYPE . '.php' -if (isset($sdi)) $interbreadcrumb[]= array( - 'url' => api_get_self() . '?sdi=' . urlencode($sdi) . - ($sdisub ? '&sdisub=' . urlencode($sdisub) : - ($sdiall ? '&sdisub='.UZYX : '')), - 'name'=> get_lang('Continue') . ' ' . $sdi . - ($sdisub ? ' (' . $sdisub . ')' : ($sdiall ? ' ('.UZYX.')' : ''))); - -$htmlHeadXtra[] = ' - - -'; -Display::display_header($nameTools); - -// OPERATIONS -----------------------------------------------------------------> - -if (isset($smo)) echo '

    ', $smo, '

    ', "\n"; // selected manifest op - -if (isset($smo)) -if ($smo == get_lang('UploadMff')) -{ - if (is_uploaded_file($filespec = $_FILES['import_file']['tmp_name']) && - filesize($filespec) && ($myFile = @fopen($filespec, 'r'))) - { - fclose($myFile); - - if (move_uploaded_file($filespec, - $baseWorkDir . $workWith . '/' . MFFNAME . $sdisub . MFFDEXT)) - { - echo get_lang('MffOk'); $hdrInfo = $originalHdrInfo; - - if (($errmsg = slurpmanifest())) $hdrInfo .= ' ' . $errmsg; - } - else echo get_lang('MffNotOk'); - } - else echo get_lang('MffFileNotFound'); -} -elseif ($smo == get_lang('UploadHtt')) -{ - $filespec = $_FILES['import_file']['tmp_name']; - if (is_uploaded_file($filespec) && filesize($filespec) && ($myFile = @fopen($filespec, 'r'))) - { - fclose($myFile); - $htt_file = $baseWorkDir .'/'. $workWith . '/' . HTF; - if (move_uploaded_file($filespec,$htt_file)) - { - echo get_lang('HttOk'); - } - else - { - echo get_lang('HttNotOk'); - } - } - else - { - echo get_lang('HttFileNotFound'); - } -} -elseif ($smo == get_lang('RemoveHtt')) -{ - @unlink($fhtf = $baseWorkDir . $workWith . '/' . HTF); - if (file_exists($fhtf)) - echo get_lang('HttRmvNotOk'); - else echo get_lang('HttRmvOk'); -} -elseif ($smo == get_lang('Import')) -{ - define('TREETOP', 'organizations/organization'); - define('TITLE', 'title'); - define('SUBITEM', 'item'); - define('IDENTIF', 'identifier'); - define('ITEMID', '@'.IDENTIF); - define('SUBIT', SUBITEM.'/'.ITEMID); - define('RESOURCE', 'resources/resource'); - define('WHERE', ITEMID); - define('ISITEM', '@identifierref'); - define('HREF', 'href'); - define('WEBF', '@'.HREF); - define('FILE', 'file'); - define('THUMB', FILE.'[1]/'.WEBF); - - function resource_for($elem) - { - global $xht_doc; - - $resForItem = $xht_doc->xmd_select_elements_where(RESOURCE, - WHERE, $xht_doc->xmd_value(ISITEM, $elem)); - - return (count($resForItem) == 0) ? -1 : $resForItem[0]; - } - - function store_md_and_traverse_subitems($mfdocId, $level, $counter, - $contextElem, $treeElem, $parentElem) - { - global $_user, $xht_doc, $mdStore, $mdObj, $sdisub, $charset; - - // $contextElem -> @identifier, metadata/lom - // $treeElem -> title, items - - $itemId = $xht_doc->xmd_value(ITEMID, $contextElem); - if ($sdisub && $level == 1 && $sdisub != $itemId) return; - - // : - // ... - // - // ... - // - // ... - // - // ... - // - - set_time_limit(30); // again 30 seconds from here on... - - $mddoc = new xmddoc(''); // version, name ? - $mddoc->xmd_set_attribute(0, 'level', $level, FALSE); - $mddoc->xmd_set_attribute(0, 'number', $counter, FALSE); - $mddoc->xmd_set_attribute(0, IDENTIF, $itemId, FALSE); - - if ($level == 0) - { - $mddoc->xmd_set_attribute(0, 'created', date('Y/m/d H:i:s'), FALSE); - $mddoc->xmd_set_attribute(0, 'by', $_user['user_id'], FALSE); - } - - - $mddoc->xmd_add_text_element(TITLE, - $xht_doc->xmd_value(TITLE, $treeElem)); - - if (($ppnId = $xht_doc->xmd_value(ITEMID, $parentElem))) $mddoc-> - xmd_add_element('parent', 0, array(IDENTIF => $ppnId)); - if (($ppnId = $xht_doc->xmd_value('-'.SUBIT, $treeElem))) $mddoc-> - xmd_add_element('previous', 0, array(IDENTIF => $ppnId)); - if (($ppnId = $xht_doc->xmd_value('+'.SUBIT, $treeElem))) $mddoc-> - xmd_add_element('next', 0, array(IDENTIF => $ppnId)); - - if (($srcElem = resource_for($treeElem)) > 0) - { - // change stuff below to xmd_copy_foreign_child ? - $resElem = $mddoc->xmd_add_element('resource', 0, - array(HREF => $xht_doc->xmd_value(WEBF, $srcElem))); - foreach ($xht_doc->xmd_select_elements(FILE, $srcElem) as $fileElem) - $mddoc->xmd_add_element(FILE, $resElem, - array(HREF => $xht_doc->xmd_value(WEBF, $fileElem))); - } - - $mddoc->xmd_copy_foreign_child($xht_doc, - $xht_doc->xmd_select_single_element('metadata', $contextElem)); - - foreach ($xht_doc->xmd_select_elements(SUBITEM, $treeElem) as $subElem) - $mddoc->xmd_add_element('child', 0, - array(IDENTIF => $xht_doc->xmd_value(ITEMID, $subElem))); - - $mdt = $mddoc->xmd_xml(); - - $xhtDoc = $mdObj->mdo_define_htt(); - $xhtDoc->xht_xmldoc = $mddoc; // $xhtDoc->xht_param['xxx'] = 'yyy'; - - $mdStore->mds_put($eid = EID_TYPE . '.' . $mfdocId . '.' . $itemId, - $mdt, 'mdxmltext', '?'); - $mdStore->mds_put($eid, $ixt = - $xhtDoc->xht_fill_template('INDEXABLETEXT'), 'indexabletext'); - - if ($level == 0) // store a copy as 'Scorm.nnn' - { - $mdStore->mds_put(EID_TYPE . '.' . $mfdocId, $mdt, 'mdxmltext', '?'); - $mdStore->mds_put(EID_TYPE . '.' . $mfdocId, $ixt, 'indexabletext'); - } - - echo $level <= 1 ? '
    '.$level.'/ ' : ' ', htmlspecialchars($itemId, ENT_QUOTES, $charset); - flush(); $loopctr = 0; - - foreach ($xht_doc->xmd_select_elements(SUBITEM, $treeElem) as $subElem) - { - store_md_and_traverse_subitems($mfdocId, $level + 1, ++$loopctr, - $subElem, $subElem, $contextElem); - // note: replacing this recursion by queue+loop makes it slower! - } - } - - function content_for_index_php($scid) - { - // 'if {}' and 'else {}' are string literals spanning several lines - - return '', api_get_path(SYS_PATH), - str_replace('', $scid, // 2 * replace in $drs-line below -' - else - { - $drs = ""; $scormid = ""; - require($drs. "main/metadata/playscormmdset.inc.php"); - } -' )) . '?' . '>'; - } - - if ($mfContents) - { - if ($sdiall) - { - foreach ($sdiall as $sdisub) - { - if (($errmsg = slurpmanifest())) - echo '? ', $sdisub, ': ', $errmsg, '
    '; - else - store_md_and_traverse_subitems($sdi, 0, 1, 0, - $xht_doc->xmd_select_single_element(TREETOP), -1); - } - $sdisub = ''; - } - else // just once, slurpmanifest() has already been done - store_md_and_traverse_subitems($sdi, 0, 1, 0, - $xht_doc->xmd_select_single_element(TREETOP), -1); - - $playIt = $baseWorkDir .'/'. $workWith . '/index.php'; - $fileHandler = @fopen($playIt, 'w'); - @fwrite($fileHandler, content_for_index_php($sdi)); - @fclose($fileHandler); - - echo '
    ', htmlspecialchars($workWith, ENT_QUOTES, $charset); - if (file_exists($playIt)) echo '/index.php ', - htmlspecialchars(date('Y/m/d H:i:s', filemtime($playIt)), ENT_QUOTES, $charset); - } -} -elseif ($smo == get_lang('Remove') && $sdisub) -{ - $screm = EID_TYPE . '.' . $sdi . '.' . $sdisub; - $mdStore->mds_delete_offspring($screm, '\_'); // SQL LIKE underscore - echo htmlspecialchars($screm . '_*: ' . Database::affected_rows(), ENT_QUOTES, $charset), '
    '; -} -elseif ($smo == get_lang('Remove')) // remove all, regardless of $sdiall -{ - $mdStore->mds_delete($screm = EID_TYPE . '.' . $sdi); - echo htmlspecialchars($screm . ': ' . Database::affected_rows(), ENT_QUOTES, $charset), '
    '; - $mdStore->mds_delete_offspring($screm); - echo htmlspecialchars($screm . '.*: ' . Database::affected_rows(), ENT_QUOTES, $charset), '

    ', - '' . get_lang('AllRemovedFor') . ' ' . $screm . '
    '; -} -elseif ($smo == get_lang('Index') && file_exists($phpDigIncCn) && - ereg('^http://([^/]+)/(.+)/index\.php$', $mdObj->mdo_url, $regs)) -{ - $result = $mdStore->mds_get_many('eid,mdxmltext,indexabletext', - "eid LIKE '" . EID_TYPE . "." . $sdi . - ($sdisub ? "." . $sdisub . "\_%'" : ".%'") . - ($sdiall ? "" : " AND NOT INSTR(eid,'_')")); // SQL LIKE underscore - - while ($row = Database::fetch_array($result)) // load indexabletexts in memory - { - // URL: index.php[?sid=xxx[&thumb=yyy]] (file[1]/@href: pptslnnn_t.jpg) - - $th = ''; $indtxt = $row['indexabletext']; - - if (($fh = strpos($rx = $row['mdxmltext'], 'file href="')) !== FALSE) - if (($cq = strpos($rx, '"', $fh += 11)) !== FALSE) - if (ereg('^pptsl[0-9]+_t\.jpg$', $thwf = substr($rx, $fh, $cq - $fh))) - $th = '&thumb=' . urlencode($thwf); - - if ($th == '' && ($sclvl = strpos($indtxt, 'scorm-level-')) !== FALSE) - $th = '&thumb=scorm-level-' . $indtxt{$sclvl + 12} . '.jpg'; - - $idt[($dotpos = strpos($ri = $row['eid'], '.', TPLEN)) !== FALSE ? - ('index.php?sid=' . urlencode(substr($ri, $dotpos+1)) . $th) : - 'index.php'] = $indtxt; - } - - require($phpDigIncCn); // switch to PhpDig DB - - if (($site_id = remove_engine_entries('http://' . $regs[1] .'/', $path = - $regs[2] . '/', $sdisub ? 'index.php?sid=' . $sdisub . '_' : ''))) - { - echo '', "\n"; - foreach ($idt as $url => $text) - { - set_time_limit(30); // again 30 seconds from here on... - index_words($site_id, $path, $url, - get_first_words($text, $path, $url), get_keywords($text)); - } - echo '
    ', "\n"; - } - // possible enhancement: UPDATE spider record for still existing pages - - if(isset($db)) { - //mysql_select_db($_configuration['main_database'], $db); - Database::select_db($_configuration['main_database'], $db); - } -} -elseif ($smo == get_lang('Index')) -{ - echo 'Problem! PhpDig connect.php has gone or else URL "' . - htmlspecialchars($mdObj->mdo_url, ENT_QUOTES, $charset) . - '" is not like "http://xxxx/yyy.../zzz/index.php"'; -} - - -// STATISTICS -----------------------------------------------------------------> - -echo '

    ', get_lang('Statistics'), '

    ', "\n"; - -$result = $mdStore->mds_get_many('eid', "eid LIKE '" . EID_TYPE . ".%'"); -echo get_lang('TotalMDEs'), Database::num_rows($result), "\n"; - -while ($row = Database::fetch_array($result)) -{ - $eid_id = substr($eid = $row['eid'], TPLEN); - - if (($dotpos = strpos($eid_id, '.'))) - $eid_id = substr($eid_id, 0, $dotpos); - else - $mdtmain[$eid_id] = $mdStore->mds_get($eid); - - $perId[$eid_id] = ($pi = $perId[$eid_id]) ? $pi + 1 : 1; -} - - -if (isset($sdi)) -{ - $mdo = new mdobject($_course, $sdi); - echo '
    ', htmlspecialchars($mdo->mdo_path, ENT_QUOTES, $charset), ', SD-id ', $sdi, ': ', - ($perId[$sdi] ? $perId[$sdi] : '0'), ' ', - ($mdtmain[$sdi] ? '- " . - get_lang('MainMD') . '' : ''), "\n"; -} - -if (count($perId)) -{ - foreach ($perId as $id => $number) - { - $mdo = new mdobject($_course, $id); - if (!($pth = $mdo->mdo_path)) - { - $pth = $mdtmain[$id]; // fetch something simple without parsing - if ($ttopen = strpos($pth, '')) - if ($ttclose = strpos($pth, '', $ttopen)) - $pth = ' ' . api_html_entity_decode - (substr($pth, $ttopen+7, $ttclose-$ttopen-7), ENT_QUOTES, $charset); - else $pth = ' ' . substr($pth, $ttopen+7, 30); - else $pth = ' ' . substr($pth, 0, 30); - } - - $pathId[$pth] = $id; - } - - echo '

    ', "\n"; ksort($pathId); $wwl = strlen($workWith); - - foreach ($pathId as $pth => $id) if ($wwl == 0 || - ($wwl < strlen($pth) && substr($pth, 0, $wwl) == $workWith)) - { - $tmfdt = file_exists($tfmff = $baseWorkDir . $pth . '/' . MFFNAME . $sdisub . MFFDEXT) ? - date('Y/m/d H:i:s', filemtime($tfmff)) : '-'; - echo '', - '', "\n"; - } - echo '
    ', htmlspecialchars($tmfdt, ENT_QUOTES, $charset), '', htmlspecialchars($pth, ENT_QUOTES, $charset), - '(SD-id ', $id, - '):', $perId[$id], '
    ', "\n"; -} - -if ($mfContents) -{ - echo $workWith, '/', MFFNAME . $sdisub . MFFDEXT, ': ', - htmlspecialchars(date('Y/m/d H:i:s', filemtime($fmff)), ENT_QUOTES, $charset) , ", \n", - substr_count($mfContents, "\n") + 1, - ' ' . get_lang('Lines') . '.', "\n"; - - if (!$sdisub && ($dh = opendir($baseWorkDir . $workWith))) - { - $nsplit = array(); - while (FALSE !== ($file = readdir($dh))) - if (ereg('^'.MFFNAME.'(.+)\\'.MFFDEXT .'$', $file, $regs)) - { - $nsplit []= $regs[1]; - } - closedir($dh); - - if (count($nsplit)) - { - echo '
    ', get_lang('SplitData'); sort($nsplit); - foreach ($nsplit as $ns) - { - $result = $mdStore->mds_get_many('eid', "eid LIKE '" . - EID_TYPE . "." . $sdi . "." . $ns . "\_%'"); - $nns = Database::num_rows($result); - echo $ns, $nns ? '_ ' . $nns : '', '; '; - } - echo '
    '; - } - } -} - -if (file_exists($baseWorkDir . $workWith . '/index.php')) - echo "mdo_url . "', '', '')\">" . get_lang('Play'), '', "\n"; - -if (file_exists($fhtf = $baseWorkDir . $workWith . '/' . HTF)) - echo '
    ', $workWith, '/', HTF, ': ', - htmlspecialchars(date('Y/m/d H:i:s', filemtime($fhtf)), ENT_QUOTES, $charset) , "\n"; - - - -// SELECT & FOOTER ------------------------------------------------------------> - -if ($mfContents || $xht_doc->error) -{ - echo '

    ', get_lang('UploadMff'), "

    \n\n", - '
    ', "\n", - '', "\n", - '', "\n", - '' . "\n
    \n"; -} - -echo '

    ', get_lang('UploadHtt'), file_exists($fhtf) ? - (' + ' . get_lang('RemoveHtt')) : '', "

    \n\n", - - '
    ', "\n", - '', "\n", - '', "\n", - ''; -if (file_exists($fhtf)) echo - ''; -echo "\n
    \n"; - -echo '

    ', $nameTools, $hdrInfo, '

    ', "\n"; - -if ($mfContents || $perId[$sdi]) // buttons for manifest operations -{ - echo '
    ', "\n"; - if ($mfContents) echo - '', "\n"; - if ($perId[$sdi]) echo - '', "\n"; - if ($mfContents && $perId[$sdi] && file_exists($phpDigIncCn)) echo - '', "\n"; - echo - '
    ', "\n"; -} -else -{ - echo '(', get_lang('NonePossible'), '...)'; -} - - -function showSelectForm($label, $specifics) -{ - echo '', "\n", - '
    ', "\n", - get_lang($label), ' :', "\n", $specifics, "\n", - '', "\n", - '
    ', "\n"; -} - -echo '

    ', get_lang('OrElse'), '

    ', "\n\n"; - -$specifics = ''); - -showSelectForm('SDI', - '' . - '()' . "\n"); - -echo '
    ', "\n"; - - -Display::display_footer(); -?> diff --git a/main/metadata/index.php b/main/metadata/index.php deleted file mode 100755 index 29178c7516..0000000000 --- a/main/metadata/index.php +++ /dev/null @@ -1,186 +0,0 @@ - - -$result = Database::query("SELECT isocode FROM " .Database :: get_main_table(TABLE_MAIN_LANGUAGE) ." WHERE available='1' ORDER BY isocode ASC"); - -$sep = ":"; $langLangs = $sep . "xx" . $sep . "xx"; - -while ($row = Database::fetch_array($result)) - if (($isocode = $row['isocode'])) - $langLangs .= ",, " . $isocode . $sep . $isocode; - - -// XML and DB STUFF -----------------------------------------------------------> - -$is_allowed_to_edit = isset($_user['user_id']) && $is_courseMember && api_is_allowed_to_edit(); - -$mdStore = new mdstore($is_allowed_to_edit); - -if (($mdt_rec = $mdStore->mds_get(EID)) === FALSE) // no record, default XML - $mdt = $mdObj->mdo_generate_default_xml_metadata(); -else $mdt = $mdt_rec; - -$xhtxmldoc = new xmddoc(explode("\n", $mdt)); - -$httfile = ($xhtxmldoc->error) ? 'md_editxml.htt' : HTT . '.htt'; - -if (!$xhtxmldoc->error && $mdt_rec !== FALSE && - method_exists($mdObj, 'mdo_override')) - $mdt = $mdObj->mdo_override($xhtxmldoc); - -$xhtDoc = define_htt($httfile, $urlp, $_course['path']); - -define('HSH', md5($mdt . LFN . $nameTools . get_lang('Sorry') . $httfile . - implode('{}', $xhtDoc->htt_array))); // cached HTML depends on LFN+HTT - -$xhtDoc->xht_param['traceinfo'] = $xhtxmldoc->error; -$xhtDoc->xht_param['dbrecord'] = $mdt_rec !== FALSE ? 'TRUE' : ''; - -$xhtDoc->xht_xmldoc = $xhtxmldoc; - -if ($is_allowed_to_edit) $xhtDoc->xht_param['isallowedtoedit'] = 'TRUE'; - -// MD updates to Doc and DB -if ($is_allowed_to_edit && isset($_POST['mda'])) { - $mdt = $mdStore->mds_update_xml_and_mdt($mdObj, $xhtDoc->xht_xmldoc, - get_magic_quotes_gpc() ? stripslashes($_POST['mda']) : $_POST['mda'], - EID, $xhtDoc->xht_param['traceinfo'], $mdt_rec !== FALSE); - - if ($mdt_rec !== FALSE) { - if (strpos($xhtDoc->xht_param['traceinfo'], 'DELETE') !== FALSE) - $xhtDoc->xht_param['dbrecord'] = ''; - } else if (strpos($xhtDoc->xht_param['traceinfo'], 'INSERT') !== FALSE) - $xhtDoc->xht_param['dbrecord'] = 'TRUE'; - - if (method_exists($mdObj, 'mdo_storeback')) - $mdObj->mdo_storeback($xhtDoc->xht_xmldoc); - - $mdt_rec = FALSE; // cached HTML obsolete, must re-apply templates -} elseif ($is_allowed_to_edit && $_POST['mdt']) { - // md_editxml.htt - $mdStore->mds_put(EID, - get_magic_quotes_gpc() ? stripslashes($_POST['mdt']) : $_POST['mdt'], - 'mdxmltext', '?'); - $mdStore->mds_put(EID, HSH, 'md5'); - - $xhtDoc->xht_param['dbrecord'] = 'TRUE'; - - $mdt = ''; $xhtDoc->xht_param['traceinfo'] = get_lang('PressAgain'); - - $mdt_rec = FALSE; // cached HTML obsolete, must re-apply templates -} - -$xhtDoc->xht_param['mdt'] = $mdt; - -define('CACHE_IS_VALID', isset($mdt_rec) && $mdt_rec !== FALSE && - HSH && HSH == $mdStore->mds_get(EID, 'md5')); - - -function md_part($part, $newtext) // callback from template (HTML cache in DB) -{ - global $mdStore; - - if ($newtext === FALSE) - { - if (!CACHE_IS_VALID) return FALSE; - return '' . $mdStore->mds_get(EID, $part); - } - else - { - $mdStore->mds_put(EID, HSH, 'md5'); - $mdStore->mds_put(EID, $newtext, $part); - - return $newtext; - } -} - -function md_part1($newtext) { return md_part('htmlcache1', $newtext); } -function md_part2($newtext) { return md_part('htmlcache2', $newtext); } -function md_indexabletext($newtext) { return md_part('indexabletext', $newtext); } - - -// GENERATE OUTPUT ------------------------------------------------------------> - -foreach (explode("\n", $xhtDoc->htt_array['HTTP']) as $httpXtra) - if ($httpXtra) $httpHeadXtra[] = $httpXtra; - -$xhtDoc->xht_get_lang = 'get_lang'; - -function resource_for($e) {return $e;} // dummy, '=/' not used here -$xhtDoc->xht_resource = 'resource_for'; - -$htmlHeadXtra[] = $xhtDoc->xht_fill_template('HEAD'); - -$mdObj->mdo_add_breadcrump_nav(); // see 'md_' . EID_TYPE . '.php' -$noPHP_SELF = TRUE; // in breadcrumps - -Display::display_header($nameTools); echo "\n"; - -$xhtDoc->xht_dbgn = DBG; // for template debug info, set to e.g. 10000 -if (($ti = $xhtDoc->xht_param['traceinfo'])) $xhtDoc->xht_param['traceinfo'] = - '
    Trace information
    ' . htmlspecialchars($ti, ENT_QUOTES, $charset); - -echo $xhtDoc->xht_fill_template('METADATA'), "\n"; - -if ($xhtDoc->xht_dbgn) echo $xhtDoc->xht_dbgo; - -Display::display_footer(); -?> diff --git a/main/metadata/md_document.htt b/main/metadata/md_document.htt deleted file mode 100755 index 0f3f76f976..0000000000 --- a/main/metadata/md_document.htt +++ /dev/null @@ -1,262 +0,0 @@ - - - - - - - - -{-D TRUE TRUE-}{-D XML application/xml;utf-8-} - -
    -{-H {-E md_indexabletext C METADATA_INDEXABLETEXT-}-} -
    - - - -
    -{-T dbrecord == empty
    -} -{-E md_part1 C METADATA_PART1-} -{-T dbrecord == empty
    -} - -{-T isallowedtoedit == TRUE - -
    {-P traceinfo-}
    - -
    - - - - - - {-T dbrecord != empty - - - -} -   -{-D techfmt {-V metadata/lom/technical/format-}-}{-T techfmt == XML - - -} -
    - - - - -} - -{-T keywordscache != empty - -
    - - - -  {-L ClickKw-} - {-P keywordscache-} -
    - -
    - {-L KwHelp-} -
    - - -} - -{-T keywordscache == empty - - -} - - -
    - - - - - - -

    {-L Tool-}: {-X metadata/lom/general/identifier/entry-}

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
         
    {-D label Language-}{-C LABEL-}{-D xpath metadata/lom/general/language-}{-C LANGSELECT-}{-D xpath metadata/lom/general/identifier/catalog-}{-D iclass disabled class="wd2" -}{-C INPUT-}{-D label Identifier-}{-C LABEL-}{-D xpath metadata/lom/general/identifier/entry-}{-D iclass class="wd2" onKeyPress="javascript: return isValidChar(event, '[a-z0-9\x08\x25\x27\*\.\'\(\)_!-]', 'i');" -}{-C INPUT-}
    {-D label Title-}{-C LABEL-}{-D xpath metadata/lom/general/title/string/@language-}{-C LANGSELECT-}{-D xpath metadata/lom/general/title/string-}{-C INPUTW-}
    {-D label Description-}{-C LABEL-}{-C MDLANGSELECT-}{-D xpath metadata/lom/general/description/string-}{-C INPUTW-}
    {-D label Coverage-}{-C LABEL-}{-D xpath metadata/lom/general/coverage/string-}{-C INPUTW-}
    {-D label Keyword-}{-C LABEL-}{-C INPUT_ALLKWDS-}
    {-D label Rights-}{-C LABEL-}{-D xpath metadata/lom/rights/description/string-}{-C INPUTW-}
    {-D label Version-}{-C LABEL-}{-D xpath metadata/lom/lifeCycle/version/string-}{-D iclass class="wd2" -}{-C INPUT-}{-D label Status-}{-C LABEL-} - {-D xpath metadata/lom/lifeCycle/status/value-}{-D optionarray Statuses-}{-C SELECT-} - {-D xpath metadata/lom/rights/cost/value-}{-D optionarray Costs-}{-C SELECT-} - {-D xpath metadata/lom/rights/copyrightAndOtherRestrictions/value-}{-D optionarray Copyrights-}{-C SELECT-} -
    {-D label CreatedSize-}{-C LABEL-} - {-D xpath metadata/lom/lifeCycle/contribute[1]/date/dateTime-}{-D iclass class="wd1" onKeyUp="javascript: checkValid(this,'^[0-9]{4}-[0-9]{2}-[0-9]{2}$','i');" -}{-C INPUT-} - {-D xpath metadata/lom/technical/size-}{-D iclass class="wd1" onKeyPress="javascript: return isValidChar(event, '[0-9\x08\x25\x27]', 'i');" -}{-C INPUT-} - {-D label Author-}{-C LABEL-}{-D xpath metadata/lom/lifeCycle/contribute[1]/entity-}{-C INPUTW-}
    {-D label Format-}{-C LABEL-}{-D xpath metadata/lom/technical/format-}{-D optionarray Formats-}{-C SELECT-}{-D label Location-}{-C LABEL-}{-D xpath metadata/lom/technical/location-}{-C INPUTW-}
         
    - - - - - {-V metadata/lom/general/title/string-} txt-sep - {-R metadata/lom/general/keyword C KWTEXT-} txt-sep - {-V metadata/lom/general/description[1]/string-} txt-end - document-type - {-V metadata/lom/lifeCycle/contribute[1]/entity-} - {-V metadata/lom/lifeCycle/contribute[1]/date/dateTime-} - {-V metadata/lom/technical/format-} - - - - - {-V string-}-kw - - - - -{-L {-P label-}-} : - - - - - - - - - -{-D optionarray Langs-}{-C SELECT-} - - - - - - - - - - - - - - -{-D iclass class="wide" -}{-C INPUT-} - - - - - - - - - - - - - - - - - - - - - - -Expires: Mon, 26 Jul 1997 05:00:00 GMT - - - - - - {-D label Keyword-}{-D tip {-L KeywordTip-}-}{-C LABEL-} - - - {-D value {-X string-}-}{-D title metadata/lom/general/keyword[{-P number-}]/string-}{-C INPUTKWD-} - - - - - - - {-D label Keyword-}{-D tip {-L KeywordTip-}-}{-C LABEL-} - - {-D value {-X string-}-}{-D title metadata/lom/general/keyword[{-P number-}]/string-}{-C INPUTKWD-} - - - - - - - - - - -Small problems with NS 7 and Mozilla 1.7... - -1. See 'End Of script Output' below: a double diff --git a/main/metadata/md_document.php b/main/metadata/md_document.php deleted file mode 100755 index 8769748a13..0000000000 --- a/main/metadata/md_document.php +++ /dev/null @@ -1,189 +0,0 @@ - - * @package chamilo.metadata - */ -/** - * Chamilo Metadata: class mdobject for Document-type items - * @package chamilo.metadata - */ -class mdobject { - -var $mdo_course; -var $mdo_type; -var $mdo_id; -var $mdo_eid; - -var $mdo_dcmap_e; -var $mdo_dcmap_v; - -var $mdo_path; -var $mdo_title; -var $mdo_comment; -var $mdo_filetype; -var $mdo_group; -var $mdo_url; - - -function mdo_define_htt() { return new xhtdoc(<< - - {-V metadata/lom/general/title/string-} txt-sep - {-R metadata/lom/general/keyword C KWTEXT-} txt-sep - {-V metadata/lom/general/description[1]/string-} txt-end - document-type - {-V metadata/lom/lifeCycle/contribute[1]/entity-} - {-V metadata/lom/lifeCycle/contribute[1]/date/dateTime-} - {-V metadata/lom/technical/format-} - - - - - {-V string-}-kw - - - -EOD -); -} - -function mdo_generate_default_xml_metadata() -{ - global $iso639_2_code, $ieee_xml; - - $xhtDoc = new xhtdoc($ieee_xml); $_user = api_get_user_info(); - - if ($xhtDoc->htt_error) - give_up('IEEE XML (metadata/md_funcs): ' . $xhtDoc->htt_error); - - $xhtDoc->xht_get_lang = 'get_lang'; $xhtDoc->xht_xmldoc = new xmddoc(''); - if ($xhtDoc->xht_xmldoc->error) give_up($xhtDoc->xht_xmldoc->error); - - $xhtDoc->xht_param['siteUri'] = make_uri(); - - $xhtDoc->xht_param['entry'] = $this->mdo_course['sysCode'] . - '.Document.' . $this->mdo_id; // 2005-05-30: path->sysCode - - $xhtDoc->xht_param['location'] = api_get_path(WEB_PATH) . - 'main/metadata/openobject.php?cidReq=' . - urlencode($this->mdo_course['sysCode']) . '&eid=' . - urlencode($this->mdo_eid); - - $xhtDoc->xht_param['mdlang'] = strtolower($iso639_2_code); - $xhtDoc->xht_param['lang'] = strtolower($iso639_2_code); - - $xhtDoc->xht_param['title'] = - $this->mdo_title ? $this->mdo_title : - ($this->mdo_path ? $this->mdo_path : get_lang('MdTitle', '')); - $xhtDoc->xht_param['description'] = - $this->mdo_comment ? $this->mdo_comment : get_lang('MdDescription', ''); - $xhtDoc->xht_param['coverage'] = get_lang('MdCoverage', ''); - - if (isset($_user)) - { - $xhtDoc->xht_param['author'] = "BEGIN:VCARD\\nFN:" . - api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS) . - "\\nEMAIL:".$_user['mail'] . "\\nEND:VCARD\\n"; - } - - $xhtDoc->xht_param['dateTime'] = date('Y-m-d'); - - if ($this->mdo_filetype == 'folder') $format = "inode/directory"; - else - { - require_once(api_get_path(LIBRARY_PATH) . 'document.lib.php'); - $format = DocumentManager::file_get_mime_type($this->mdo_path); - } - - $xhtDoc->xht_param['format'] = $format; - - $xhtDoc->xht_param['size'] = (($s = filesize(get_course_path() . - $this->mdo_course['path'] . '/document' . $this->mdo_path))) ? $s : '0'; - - return $xhtDoc->xht_fill_template('XML'); -} - - -function mdo_add_breadcrump_nav() -{ - global $interbreadcrumb, $langFormats; - $regs = array(); // for use with ereg() - - $docurl = api_get_self(); // should be .../main/xxx/yyy.php - if (ereg('^(.+[^/\.]+)/[^/\.]+/[^/\.]+.[^/\.]+$', $docurl, $regs)) - $docurl = $regs[1] . '/document/document.php'; - - $interbreadcrumb[]= array ('url' => $docurl, - "name"=> get_lang('MdCallingTool')); - - if (($docpath = $this->mdo_path)) - { - $docpath = substr($docpath, 0, strrpos($docpath, '/')); - - if (strlen($docpath) > 1) $interbreadcrumb[]= array ('url' => - $docurl . '?curdirpath=' . urlencode($docpath) . - ($this->mdo_group ? '&gidReq=' . $this->mdo_group : ''), "name" => - htmlspecialchars(substr($docpath, strrpos($docpath, '/') + 1))); - } - - // Complete assoclist $langFormats from mime types - - require_once(api_get_path(LIBRARY_PATH) . 'xht.lib.php'); - require_once(api_get_path(LIBRARY_PATH) . 'document.lib.php'); - - $sep = $langFormats{0} ? $langFormats{0} : ":"; - $arrFormats = xht_explode_assoclist($langFormats); - - foreach (DocumentManager::file_get_mime_type(TRUE) as $format) - if (!isset($arrFormats[$format])) - $langFormats .= ",, " . $format . $sep . $format; - - if (!isset($arrFormats["inode/directory"])) - $langFormats .= ",, inode/directory" . $sep . "inode/directory"; - - if (substr($langFormats, 0, 3) == ",, ") - $langFormats = $sep . substr($langFormats, 3); -} - - -function mdobject($_course, $id) { - global $ieee_dcmap_e, $ieee_dcmap_v; // md_funcs - $course_id = api_get_course_int_id(); - - $this->mdo_course = $_course; $this->mdo_type = 'Document'; - $this->mdo_id = $id; $this->mdo_eid = $this->mdo_type . '.' . $id; - - $this->mdo_dcmap_e = $ieee_dcmap_e; $this->mdo_dcmap_v = $ieee_dcmap_v; - - $document_table = Database::get_course_table(TABLE_DOCUMENT); - $sql = "SELECT path,title,comment,filetype FROM $document_table WHERE c_id = $course_id AND id='" .intval($id) . "'"; - - if (($docinfo = Database::fetch_array(Database::query($sql)))) { - $this->mdo_path = $docinfo['path']; - $this->mdo_title = $docinfo['title']; - $this->mdo_comment = $docinfo['comment']; - $this->mdo_filetype = $docinfo['filetype']; - $this->mdo_group = ''; // 2005-05-30: find group_id, if any - - $group_info = Database::get_course_table(TABLE_GROUP); - $sql = "SELECT id,secret_directory FROM $group_info WHERE c_id = $course_id"; - if (($result = Database::query($sql))) - while (($row = Database::fetch_array($result))) - if (($secdir = $row['secret_directory'] . '/') == - substr($this->mdo_path, 0, strlen($secdir))) - { - $this->mdo_group = $row['id']; break; - } - - // 2005-05-30: use direct URL - $this->mdo_url = api_get_path(WEB_COURSE_PATH) . $_course['path'] . - '/document' . str_replace('%2F', '/', urlencode($this->mdo_path)) . - ($this->mdo_group ? '?gidReq=' . $this->mdo_group : ''); - } -} - -} -?> diff --git a/main/metadata/md_editxml.htt b/main/metadata/md_editxml.htt deleted file mode 100755 index a45e42adc1..0000000000 --- a/main/metadata/md_editxml.htt +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - -{-P traceinfo-} -
    -
    - - -
    - - - -Expires: Mon, 26 Jul 1997 05:00:00 GMT - - - \ No newline at end of file diff --git a/main/metadata/md_funcs.php b/main/metadata/md_funcs.php deleted file mode 100755 index 4a9f9e20e7..0000000000 --- a/main/metadata/md_funcs.php +++ /dev/null @@ -1,406 +0,0 @@ - - * 2006/12/15 - * Copyright (C) 2006 rene.haentjens@UGent.be - see note at end of text --> - * @package chamilo.metadata -*/ - -/** -* Chamilo Metadata: common functions and mdstore class -* -* This script requires xmd.lib.php and xht.lib.php (Chamilo inc/lib). -* -* Note on the funny characters used in mds_update_xml_and_mdt: -* -* ! and ~ and , are handled by xmd_update, see xmd.lib.php -* ~~ !! ; and = are handled here; note that = excludes newlines in value -* -* path!elem create new element (not for attributes!) -* path=value assign new value to existing element or value to attribute -* path~ delete element (you cannot delete an attribute) -* ~~ delete the whole xmldoc and the DB entry -* !! this (xml) document contains the course keywords -* -* path1,path2,...;subpath=value for all elements in path1, path2, ... -* assign value to subpath (see also xmd_update_many) -* -*/ - -// FETCH GET/POST-DATA; GENERAL FUNCTIONS - -define('MDS_TABLE', Database::get_course_table(TABLE_METADATA)); - - -if (isset($getpostvars) && is_array($getpostvars)) - foreach ($getpostvars as $gpvar) - if (is_string($gpvar) && (isset($_POST[$gpvar]) || isset($_GET[$gpvar]))) { - $val = isset($_POST[$gpvar]) ? $_POST[$gpvar] : $_GET[$gpvar]; - $GLOBALS[$gpvar] = get_magic_quotes_gpc() ? stripslashes($val) : $val; - } - -function fgc($filename) { - $fp = fopen($filename, 'rb'); $buffer = fread($fp, filesize($filename)); - fclose($fp); return $buffer; // file_get_contents: PHP >= 4.3.0 -} - - -function give_up($msg) { - global $charset; - echo '

    MetaData:
    ? ', - htmlspecialchars($msg, ENT_QUOTES, $charset), '

    '; exit; -} - - -function getpar($name, $description, $default = '') -{ - $value = isset($_GET[$value = api_strtolower($name)]) ? $_GET[$value] : ''; - $value = get_magic_quotes_gpc() ? stripslashes($value) : $value; - if (!$value) $value = $default; - if ($value == '') give_up('URL parameter ' . api_strtoupper($name) . ' - ' . - $description . ' - is required'); - - define(api_strtoupper($name), $value); -} - - -function get_course_path() { - return api_get_path(SYS_COURSE_PATH); -} - -function get_course_web() { - return api_get_path(WEB_COURSE_PATH); -} - - -function define_htt($htt_file, $urlp, $course_path) { - global $charset; - - ($htt_file_contents = @fgc($htt_file)) - or give_up('Templates file "' . $htt_file . '" is missing...'); - - $xhtDoc = new xhtdoc($htt_file_contents); - if ($xhtDoc->htt_error) - give_up('Templates file "' . $htt_file . '": ' . $xhtDoc->htt_error); - - $xhtDoc->xht_param['self'] = api_get_self() . $urlp; - - $xhtDoc->xht_param['dateTime'] = date('Y-m-d'); - - $ckw = $course_path . '/CourseKwds.js'; - define('KEYWORDS_CACHE', get_course_path() . $ckw); - - if (file_exists(KEYWORDS_CACHE)) $kcdt = - htmlspecialchars(date('Y/m/d H:i:s', filemtime(KEYWORDS_CACHE)), ENT_QUOTES, $charset); - - $xhtDoc->xht_param['keywordscache'] = $kcdt ? - '' . - '
    (CourseKwds cache: ' . $kcdt . ')' : ''; - - return $xhtDoc; -} - - -function make_uri() { - $regs = array(); // for use with ereg() - - $uri = strtr(ereg_replace( - "[^0-9A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF\*\(\('!_.-]", "_", - api_get_setting('siteName')), "\\", "_"); // allow letdigs, and _-.()'!* - - if (($p = strpos($uri, '.')) !== FALSE) - $uri = substr($uri, 0, $p); - if (ereg('^([^/]+//)?([^/\?]+)[/\?]',api_get_path(WEB_PATH).'/',$regs)) - if (ereg('([^\.]+)(\.ca)?(\.[^\.]+)?', strrev($regs[2]), $regs)) - $uri = str_replace('.', '-', - strrev($regs[1].$regs[2].$regs[3])) . ':' . $uri; - $uri = 'urn:' . strtolower($uri); - while (substr($uri, -1)=='.') $uri = substr($uri,0,-1); - - return $uri; -} - - -// IEEE LOM: DEFAULT XML AND DUBLIN CORE MAPPING ------------------------------> - -$ieee_xml = << - - - - - - {-H {-P siteUri-}-}.{-H {-P entry-}-} - <string language="{-H {-P mdlang-}-}">{-H {-P title-}-}</string> - {-H {-P lang-}-} - {-H {-P description-}-} - {-H {-P coverage-}-} - - - 0.5 - LOMv1.0draft - - LOMv1.0author - {-H {-P author-}-} - {-H {-P dateTime-}-} - - - - ADLv1.3 - - - {-H {-P format-}-} - {-H {-P size-}-} - {-H {-P location-}-} - - - LOMv1.0narrative text - - - LOMv1.0yes - LOMv1.0yes - {-L MdCopyright-} - - - LOMv1.0educational objective - - - - - -EOD; - -$ieee_dcmap_e = array( -'Identifier'=> 'metadata/lom/general/identifier[1]', -'Title'=> 'metadata/lom/general/title[1]', -'Language'=> 'metadata/lom/general/language[1]', -'Description'=> 'metadata/lom/general/description[1]', -'Coverage'=> 'metadata/lom/general/coverage[1]', -'Type'=> 'metadata/lom/educational/learningResourceType[1]', -'Date'=> 'metadata/lom/lifeCycle/contribute[1]/date', -'Creator'=> 'metadata/lom/lifeCycle/contribute[1]/entity', -'Format'=> 'metadata/lom/technical/format[1]', -'Rights'=> 'metadata/lom/rights/description[1]'); -// maps Dublin Core elements to xmd paths for elements (not yet complete) - -$ieee_dcmap_v = array( -'Identifier'=> 'metadata/lom/general/identifier[1]/entry', -'Title'=> 'metadata/lom/general/title[1]/string', -'Language'=> 'metadata/lom/general/language[1]', -'Description'=> 'metadata/lom/general/description[1]/string', -'Coverage'=> 'metadata/lom/general/coverage[1]/string', -'Type'=> 'metadata/lom/educational/learningResourceType[1]/value', -'Date'=> 'metadata/lom/lifeCycle/contribute[1]/date/dateTime', -'Creator'=> 'metadata/lom/lifeCycle/contribute[1]/entity', -'Format'=> 'metadata/lom/technical/format[1]', -'Rights'=> 'metadata/lom/rights/description[1]/string'); -// maps Dublin Core elements to xmd paths for values (not yet complete) - - -// KEYWORD TREE -function define_kwds($mdo) { - if (!($newtext = trim(@fgc(get_course_path() . $mdo->mdo_course['path'] . - '/document' . $mdo->mdo_path )))) - { - unlink(KEYWORDS_CACHE); return; - } - // templates to define the tree as JScript object - $xhtDocKw = new xhtdoc(<< - -KWTREE_OBJECT = {n:"", ti:"{-X @title-}" -, c:[{-R * C DOWN_THE_KWTREE-}]}; - -document.write(traverseKwObj(KWTREE_OBJECT, '', 0)); KWDS_ARRAY.sort(); - - -{-T number > 1 , -}{n:"{-V @.-}"{-D cm {-X @comment-}-}{-T cm != empty , cm:"{-P cm-}"-}{-D pt {-X @postit-}-}{-T pt != empty , pt:"{-P pt-}"-}{-R * P empty-}{-T number >= 1 -, c:[-}{-T number >= 1 R * C DOWN_THE_KWTREE-}{-R * P empty-}{-T number >= 1 ]-}} - - -EOD - ); // traverseKwObj (md_script) generates clickable tree and populates KWDS_ARRAY - - - if ($xhtDocKw->htt_error) - give_up('KwdTree template (metadata/md_funcs): ' . $xhtDocKw->htt_error); - - $xhtDocKw->xht_xmldoc = new xmddoc(explode("\n", $newtext)); - if ($xhtDocKw->xht_xmldoc->error) - give_up('CourseKwds (metadata/md_funcs): XML error: ' . - $xhtDocKw->xht_xmldoc->error); - - if (count($xhtDocKw->xht_xmldoc->children[0]) < 2) - { - unlink(KEYWORDS_CACHE); return; - } - - $fileHandler = @fopen(KEYWORDS_CACHE, 'w'); - @fwrite($fileHandler, $xhtDocKw->xht_fill_template('KWTREE_OBJECT')); - @fclose($fileHandler); -} - - -// METADATA STORE -/** - * mdstore class - * @package chamilo.metadata - */ -class mdstore { - - var $mds_something; - - function __construct($allow_create) { - global $_course; - $this->course_id = api_get_course_int_id(); - if (!isset($_course)) return; - } - - function mds_get($eid, $column = 'mdxmltext', $must_exist = '') { - // none: FALSE - if (($mdt = Database::fetch_array(Database::query("SELECT " . $column ." FROM ".MDS_TABLE." WHERE eid = '$eid' AND c_id = {$this->course_id} ")))) - return $mdt[$column]; - if ($must_exist) give_up($must_exist . $this->_coldat('eid', $eid)); - - return FALSE; - } - - function mds_get_dc_elements($mdo) // no record: FALSE - { - if (!($mdt = $this->mds_get($mdo->mdo_eid))) return FALSE; - $xmlDoc = new xmddoc(explode("\n", $mdt)); if ($xmlDoc->error) return FALSE; - $result = array(); - foreach ($mdo->mdo_dcmap_v as $dce => $xp) { - $result[$dce] = $xmlDoc->xmd_value($xp); - } - return $result; - } - - function mds_get_many($columns, $where_clause) { - $cols = ''; - foreach (explode(',', $columns) as $col) $cols .= "," . trim($col); - if (!$cols) return; - return $this->_query("SELECT " . api_substr($cols, 1) ." FROM " . MDS_TABLE . " WHERE c_id = {$this->course_id} AND ". $where_clause); - } - - function mds_put($eid, $data, $column = 'mdxmltext', $exists = TRUE) { - if ($exists === TRUE) - return $this->_query("UPDATE " . MDS_TABLE . " SET " .$this->_coldat($column, $data) . " WHERE c_id = {$this->course_id} AND ", $eid); - elseif ($exists === FALSE) - return $this->_query("INSERT INTO " . MDS_TABLE . " SET c_id = {$this->course_id} , ".$this->_coldat($column, $data).", ", $eid); - else // user doesn't know, check first whether the record exists - return $this->mds_put($eid, $data, $column, !($this->mds_get($eid) === FALSE)); - } - - function mds_put_dc_elements($mdo, $dcelem) { - if (($mdt = $this->mds_get($mdo->mdo_eid)) === FALSE) { - $mdt = $mdo->mdo_generate_default_xml_metadata(); $exists = FALSE; - } else - $exists = TRUE; - - $xmlDoc = new xmddoc(explode("\n", $mdt)); if ($xmlDoc->error) return FALSE; - foreach ($dcelem as $dce => $value) { - $xmlDoc->xmd_update($mdo->mdo_dcmap_v[$dce], (string) $value); - } - $this->mds_put($mdo->mdo_eid, '', 'md5', $exists); - return $this->mds_put($mdo->mdo_eid, $xmlDoc->xmd_xml()); - } - - function mds_append($eid, $moredata, $column = 'indexabletext') { - if (($olddata = $this->mds_get($eid, $column)) === FALSE) return FALSE; - $this->mds_put($eid, $olddata . $moredata, $column); return $olddata; - } - - function mds_delete($eid) { - return $this->_query("DELETE FROM " . MDS_TABLE . " WHERE c_id = {$this->course_id} AND ", $eid); - } - - function mds_delete_offspring($eid, $sep = '.') { - return $this->_query("DELETE FROM " . MDS_TABLE . " WHERE c_id = {$this->course_id} AND ", $eid, $sep); - } - - function mds_delete_many($idarray) { - if (!is_array($idarray) || count($idarray) == 0) return FALSE; - - return $this->_query("DELETE FROM " . MDS_TABLE . " WHERE c_id = {$this->course_id} AND eid IN ('" . - implode("','", array_map('addslashes', $idarray)) . "')"); - } - - function mds_update_xml_and_mdt($mdo, &$xmlDoc, $mda, $eid, &$traceinfo, - $exists = TRUE) // note: $xmlDoc and $traceinfo passed by reference - { - foreach (explode("\n", - str_replace("\r", "\n", str_replace("\r\n", "\n", $mda))) as $update) - { - if (!$update) continue; - - if (($nameLth = strpos($update, '='))) // e.g. 'gen/tit/str=new' - { - if (($text = api_substr($update, $nameLth + 1)) === FALSE) $text = ''; - - if (!($path = trim(api_substr($update, 0, $nameLth)))) continue; - - if (($sc = api_strpos($path, ';'))) // e.g. 'gen/tit,gen/des;str@lang' - $xmlDoc->xmd_update_many(api_substr($path, 0, $sc), - api_substr($path, $sc + 1), $text); - else - $xmlDoc->xmd_update($path, $text); - } - elseif ($nameLth === FALSE) // e.g. 'gen/tit/str[-1]~' - { - if ($update == '~~') - { - $update = 'DELETE ' . $eid; - if ($exists === FALSE) $update = ''; - else $this->mds_delete($eid); - $mda = ''; $exists = TRUE; - foreach ($xmlDoc->children[0] as $key => $child) - unset($xmlDoc->children[0][$key]); - } - elseif ($update == '!!') - { - define_kwds($mdo); - $update = ''; $mda = ''; $exists = TRUE; - } - else - { - $x = $xmlDoc->xmd_update(trim($update), ''); - } - } - if ($update) $traceinfo .= $update . '- '; - } - - $mdt = $xmlDoc->xmd_xml(); - - if ($exists === FALSE) - { - $this->mds_put($eid, $mdt, 'mdxmltext', FALSE); - $traceinfo .= 'INSERT ' . $eid . '- '; - } - elseif($mda) - { - $this->mds_put($eid, $mdt, 'mdxmltext'); - $traceinfo .= 'UPDATE ' . $eid . '- '; - } - - return $mdt; - } - - - function _coldatstart($column, $data) { - return $column . " LIKE '" . Database::escape_string($data) . "%'"; - } - - function _coldat($column, $data) { - return $column . "='" . Database::escape_string($data) . "'"; - } - - function _query($sql, $eid = '', $sep = '') { - if ($eid) $sql .= $sep ? $this->_coldatstart('eid', $eid . $sep) : - $this->_coldat('eid', $eid); - return Database::query($sql); - } - -} \ No newline at end of file diff --git a/main/metadata/md_link.htt b/main/metadata/md_link.htt deleted file mode 100755 index 293107b9a2..0000000000 --- a/main/metadata/md_link.htt +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - - - -{-D TRUE TRUE-} - -
    -{-H {-E md_indexabletext C METADATA_INDEXABLETEXT-}-} -
    - - - -
    -{-T dbrecord == empty
    -} -{-E md_part1 C METADATA_PART1-} -{-T dbrecord == empty
    -} - -{-T isallowedtoedit == TRUE - -
    {-P traceinfo-}
    - -
    - - - - -
    - - - - -} - -{-T keywordscache != empty - -
    - - - -  {-L ClickKw-} - {-P keywordscache-} -
    - -
    - {-L KwHelp-} -
    - - -} - -{-T keywordscache == empty - -
    -{-L KwNote-} -
    - - -} - - -
    - - - - - - -

    {-L Tool-}: {-X metadata/lom/general/identifier/entry-}

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
         
    {-D label Language-}{-C LABEL-}{-D xpath metadata/lom/general/language-}{-C LANGSELECT-}{-D xpath metadata/lom/general/identifier/catalog-}{-D iclass disabled class="wd2" -}{-C INPUT-}{-D label Identifier-}{-C LABEL-}{-D xpath metadata/lom/general/identifier/entry-}{-D iclass class="wd2" onKeyPress="return isValidChar(event, '[a-z0-9\x08\x25\x27\*\.\'\(\)_!-]', 'i');" -}{-C INPUT-}
    {-D label Title-}{-C LABEL-}{-D xpath metadata/lom/general/title/string/@language-}{-C LANGSELECT-}{-D xpath metadata/lom/general/title/string-}{-C INPUTW-}
    {-D label Description-}{-C LABEL-}{-C MDLANGSELECT-}{-D xpath metadata/lom/general/description/string-}{-C INPUTW-}
    {-D label Coverage-}{-C LABEL-}{-D xpath metadata/lom/general/coverage/string-}{-C INPUTW-}
    {-D label Keyword-}{-C LABEL-}{-C INPUT_ALLKWDS-}
    {-D label Location-}{-C LABEL-}{-D xpath metadata/lom/technical/location-}{-C INPUTW-}
         
    - - - - -Title: {-V metadata/lom/general/title/string-} txt-sep -Keyword(s): {-R metadata/lom/general/keyword C KWTEXT-} txt-sep -Category: {-V metadata/lom/general/coverage/string-} - {-V metadata/lom/general/description[1]/string-} txt-end - link-type - {-V metadata/lom/lifeCycle/contribute[1]/entity-} - {-V metadata/lom/lifeCycle/contribute[1]/date/dateTime-} - - - - {-V metadata/lom/general/identifier/entry-} - {-V metadata/lom/general/title/string-} - {-V metadata/lom/general/description/string-} - {-V metadata/lom/general/coverage/string-} - {-R metadata/lom/general/keyword C KWTEXT-} - - - - - {-V string-}-kw - - - - -{-L {-P label-}-} : - - - - - - - - - -{-D optionarray Langs-}{-C SELECT-} - - - - - - - - - - - - - - -{-D iclass class="wide" -}{-C INPUT-} - - - - - - - - - - - - - - - - - - - - - - -Expires: Mon, 26 Jul 1997 05:00:00 GMT - - - \ No newline at end of file diff --git a/main/metadata/md_link.php b/main/metadata/md_link.php deleted file mode 100755 index b84b22773e..0000000000 --- a/main/metadata/md_link.php +++ /dev/null @@ -1,256 +0,0 @@ - - -Title: {-V metadata/lom/general/title/string-} txt-sep -Keyword(s): {-R metadata/lom/general/keyword C KWTEXT-} txt-sep -Category: {-V metadata/lom/general/coverage/string-} txt-sep - {-V metadata/lom/general/description[1]/string-} txt-end - link-type - - - - - {-V string-}-kw - - - -EOD -); -} - -function mdo_generate_default_xml_metadata() -{ - global $iso639_2_code, $ieee_xml; - - $xhtDoc = new xhtdoc($ieee_xml); $_user = api_get_user_info(); - - if ($xhtDoc->htt_error) - give_up('IEEE XML (metadata/md_funcs): ' . $xhtDoc->htt_error); - - $xhtDoc->xht_get_lang = 'get_lang'; $xhtDoc->xht_xmldoc = new xmddoc(''); - if ($xhtDoc->xht_xmldoc->error) give_up($xhtDoc->xht_xmldoc->error); - - $xhtDoc->xht_param['siteUri'] = make_uri(); - - $xhtDoc->xht_param['entry'] = $this->mdo_course['sysCode'] . - '.Link.' . $this->mdo_id; // 2005-05-30: path->sysCode - - $xhtDoc->xht_param['location'] = $this->mdo_url . ''; - - $xhtDoc->xht_param['mdlang'] = strtolower($iso639_2_code); - $xhtDoc->xht_param['lang'] = strtolower($iso639_2_code); - - $xhtDoc->xht_param['title'] = - $this->mdo_title ? $this->mdo_title : get_lang('MdTitle'); - - if (($d = $this->mdo_description)) - { - if ($keywords = $this->_find_keywords($d)) $d = array_pop($keywords); - $xhtDoc->xht_param['description'] = $d; - } - else - $xhtDoc->xht_param['description'] = get_lang('MdDescription'); - - $xhtDoc->xht_param['coverage'] = $this->mdo_category_title ? - $this->mdo_category_title : get_lang('MdCoverage'); - - if (isset($_user)) - { - $xhtDoc->xht_param['author'] = "BEGIN:VCARD\\nFN:" . - api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS) . - "\\nEMAIL:".$_user['mail'] . "\\nEND:VCARD\\n"; - } - - $xhtDoc->xht_param['dateTime'] = date('Y-m-d'); - - $xhtDoc->xht_param['format'] = ''; $xhtDoc->xht_param['size'] = '0'; - - if (count($keywords)) - { - $xd = new xmddoc(explode("\n", - $mdt = $xhtDoc->xht_fill_template('XML'))); - if ($xd->error) return $mdt; // and worry later - - $this->_add_keywords($xd, $keywords); - - return $xd->xmd_xml(); - } - - return $xhtDoc->xht_fill_template('XML'); -} - - -function mdo_override(&$xmlDoc) // by ref! -{ - if ($this->mdo_url) - { - $xmlDoc->xmd_update('metadata/lom/technical/location', $this->mdo_url); - - $ge = $xmlDoc->xmd_select_single_element("metadata/lom/general"); - - $xmlDoc->xmd_update('title[1]/string', $this->mdo_title, $ge); - $xmlDoc->xmd_update('coverage[1]/string', $this->mdo_category_title, $ge); - - if (($d = $this->mdo_description)) - if ($keywords = $this->_find_keywords($d)) $d = array_pop($keywords); - - $xmlDoc->xmd_update('description[1]/string', $d, $ge); - - $xmlDoc->xmd_remove_nodes($xmlDoc->xmd_select_elements('keyword', $ge), $ge); - - if (count($keywords)) $this->_add_keywords($xmlDoc, $keywords); - } - - return $xmlDoc->xmd_xml(); -} - - -function mdo_storeback(&$xmlDoc) // by ref! -{ - $course_id = api_get_course_int_id(); - - if (!$this->mdo_url) return; // no record in link table, most probably - - if (!($v = $xmlDoc->xmd_value('metadata/lom/technical/location'))) return; - - if ($v != $this->mdo_url) - { $this->mdo_url = $v; $u .= ", url = '" . addslashes($v) . "'"; } - - $ge = $xmlDoc->xmd_select_single_element("metadata/lom/general"); - - $v = $xmlDoc->xmd_value('title[1]/string', $ge); - if ($v != $this->mdo_title) - { $this->mdo_title = $v; $u .= ", title = '" . addslashes($v) . "'"; } - - $vd = $xmlDoc->xmd_value('description[1]/string', $ge); - $vk = $xmlDoc->xmd_value('keyword/string', $ge, array('in' => ', ')); - $v = $vk ? '' . - ereg_replace('\[((/?(b|big|i|small|sub|sup|u))|br/)\]', '<\\1>', - htmlspecialchars($vd)) . '' : $vd; - - if ($v != $this->mdo_description) - { - $this->mdo_description = $v; - $u .= ", description = '" . addslashes($v) . "'"; - } - - // do not store back a modified coverage as category... - - $link_table = Database::get_course_table(TABLE_LINK); - if ($u) Database::query("UPDATE $link_table SET " . substr($u, 2) . - " WHERE c_id = $course_id AND id='" . addslashes($this->mdo_id) . "'"); -} - - -function mdo_add_breadcrump_nav() -{ - global $interbreadcrumb; - - $regs = array(); // for use with ereg() - - $docurl = api_get_self(); // should be .../main/xxx/yyy.php - if (ereg('^(.+[^/\.]+)/[^/\.]+/[^/\.]+.[^/\.]+$', $docurl, $regs)) - $docurl = $regs[1] . '/link/link.php'; - - $interbreadcrumb[]= array ('url' => $docurl, - "name"=> get_lang('MdCallingTool')); -} - - -function mdobject($_course, $id) -{ - global $ieee_dcmap_e, $ieee_dcmap_v; // md_funcs - $course_id = api_get_course_int_id(); - - $this->mdo_course = $_course; $this->mdo_type = 'Link'; - $this->mdo_id = $id; $this->mdo_eid = $this->mdo_type . '.' . $id; - - $this->mdo_dcmap_e = $ieee_dcmap_e; $this->mdo_dcmap_v = $ieee_dcmap_v; - - $link_table = Database::get_course_table(TABLE_LINK); - if (($linkinfo = @Database::fetch_array(Database::query( - "SELECT url,title,description,category_id FROM $link_table WHERE c_id = $course_id AND id='" .intval($id) . "'")))) - { - $this->mdo_url = $linkinfo['url']; - $this->mdo_title = $linkinfo['title']; - $this->mdo_description = $linkinfo['description']; - $this->mdo_category = ($lci = $linkinfo['category_id']); - - $linkcat_table = Database::get_course_table(TABLE_LINK_CATEGORY); - if (($catinfo = @Database::fetch_array(Database::query( - "SELECT category_title FROM $linkcat_table WHERE c_id = $course_id AND id='" . - addslashes($lci) . "'")))) - $this->mdo_category_title = $catinfo['category_title']; - } -} - - -function _find_keywords($d) -{ - $dd = new xmddoc($d); if ($dd->error) return NULL; - - $regs = array(); // for use with ereg() - - foreach ($dd->attributes[0] as $name => $value) - if ($name == 'kw' && ereg('^]+)>?$', $value, $regs)) - { - $kwa = array_map('trim', explode(',', $regs[1])); - - if (ereg('^<' . ($tag = $dd->name[0]) . '[^>]*>(.*)$', - $d, $regs)) // e.g. A & B! - { - $htdc = array_flip(get_html_translation_table(HTML_ENTITIES)); - $d = strtr(ereg_replace( // first -> [b] etc. - '<((/?(b|big|i|small|sub|sup|u))|br/)>', '[\\1]', - ($regs[1])), $htdc); // then & -> & etc. - $d = strtr(str_replace("\r\n", " ", $d), "\r\n", " "); - } - else $d = $dd->xmd_text(); - - array_push($kwa, $d); return $kwa; - } - - return NULL; -} - -function _add_keywords(&$xmlDoc, $keywords) // by ref! -{ - $ge = $xmlDoc->xmd_select_single_element("metadata/lom/general"); - $dl = array("language" => - $xmlDoc->xmd_value("description/string/@language", $ge)); - - foreach ($keywords as $kw) - $xmlDoc->xmd_add_text_element("string", $kw, - $xmlDoc->xmd_add_element("keyword", $ge), $dl); -} - -} -?> diff --git a/main/metadata/md_mix.php b/main/metadata/md_mix.php deleted file mode 100755 index ebb7e665a3..0000000000 --- a/main/metadata/md_mix.php +++ /dev/null @@ -1,85 +0,0 @@ -mdo_course = $_course; $this->mdo_eid = $eid; - $this->mdo_type = ($type = substr($eid, 0, $dotpos)); - $this->mdo_id = ($id = substr($eid, $dotpos + 1)); - - if ($type == 'Document' || $type == 'Scorm') - { - $table = $type == 'Scorm' ? - Database::get_course_table(TABLE_SCORMDOC) : - Database::get_course_table(TABLE_DOCUMENT); - - if (($dotpos = strpos($id, '.'))) - { - $urlp = '?sid=' . urlencode(substr($id, $dotpos+1)); - $id = substr($id, 0, $dotpos); - } - - if (($docinfo = @mysql_fetch_array(Database::query( - "SELECT path,comment,filetype FROM - $table WHERE id='" . - addslashes($id) . "'")))) - { - $this->mdo_path = $docinfo['path']; - $this->mdo_comment = $docinfo['comment']; - $this->mdo_filetype = $docinfo['filetype']; - - if ($type == 'Scorm') - { - $this->mdo_base_url = get_course_web() . - $this->mdo_course['path'] . '/scorm' . $this->mdo_path; - $this->mdo_url = $this->mdo_base_url . '/index.php' . $urlp; - } - else - { - $this->mdo_url = api_get_path(WEB_PATH) . 'main/document/' . - (($this->mdo_filetype == 'file') ? 'download' : 'document').'.php?'. - (($this->mdo_filetype == 'file') ? 'doc_url=' : 'curdirpath=') . - urlencode($this->mdo_path); - } - } - } - elseif ($type == 'Link') - { - $link_table = Database::get_course_table(TABLE_LINK); - if (($linkinfo = @mysql_fetch_array(Database::query( - "SELECT url,title,description,category_id FROM - $link_table WHERE id='" . addslashes($id) . - "'")))) - { - $this->mdo_url = $linkinfo['url']; - } - } -} - -} -?> diff --git a/main/metadata/md_phpdig.php b/main/metadata/md_phpdig.php deleted file mode 100755 index fd12e42b33..0000000000 --- a/main/metadata/md_phpdig.php +++ /dev/null @@ -1,215 +0,0 @@ - - -$phpDigInc = get_course_path() . $_course['path'] . '/phpdig-1.8.6/includes/'; -$phpDigIncCn = $phpDigInc. 'connect.php'; // to connect to PhpDig's database -$phpDigIncCw = $phpDigInc. 'common_words.txt'; // stopwords - -// if (!file_exists($phpDigIncCn)) return(); doesn't seem to work properly... - - -if (file_exists($phpDigIncCw)) - if (is_array($lines = @file($phpDigIncCw))) - while (list($id,$word) = each($lines)) - $common_words[trim($word)] = 1; - -define('SUMMARY_DISPLAY_LENGTH', 700); -//define('PHPDIG_ENCODING', 'iso-8859-1'); -define('PHPDIG_ENCODING', strtolower($charset)); -define('SMALL_WORDS_SIZE', 2); -define('MAX_WORDS_SIZE',50); -define('WORDS_CHARS_LATIN1', '[:alnum:]��ߵ'); - -foreach (array( 'A'=>'������', 'a'=>'������', 'O'=>'������', 'o'=>'������', - 'E'=>'����', 'e'=>'����', 'C'=>'�', 'c'=>'�', 'I'=>'����', - 'i'=>'����', 'U'=>'����', 'u'=>'����', 'Y'=>'�', 'y'=>'��', - 'N'=>'�', 'n'=>'�') as $without => $allwith) - foreach (explode('!', chunk_split($allwith, 1, '!')) as $with) - if ($with) // because last one will be empty! - { - $letterswithout .= $without; $letterswith .= $with; - } -define('LETTERS_WITH_ACCENTS', $letterswith); -define('SAME_WITHOUT_ACCENTS', $letterswithout); - -(strlen(LETTERS_WITH_ACCENTS) == strlen(SAME_WITHOUT_ACCENTS)) - or give_up('LETTERS_WITH_ACCENTS problem in md_phpdig.php'); - - -function find_site($url) -{ - $site_url = "site_url = '" . addslashes($url) . "'"; - - $result = Database::query("SELECT site_id FROM " . PHPDIG_DB_PREFIX . - "sites WHERE " . $site_url); // find site - - if (Database::num_rows($result) == 1) - { - $row = Database::fetch_array($result); return (int) $row['site_id']; - } - else - { - $result = Database::query("INSERT INTO " . PHPDIG_DB_PREFIX . - "sites SET " . $site_url); // new site - $site_id = Database::insert_id(); - - $result = Database::query("INSERT INTO " . PHPDIG_DB_PREFIX . - "site_page (site_id,num_page) VALUES ('$site_id', '0')"); - - return $site_id; - } -} - -function remove_engine_entries($url, $path, $file = '') -{ - global $charset; - - $and_path = " AND path = '" . addslashes($path) . "'"; - if ($file) $and_path .= " AND file LIKE '" . addslashes( - str_replace(array('_', '%'), array('\_', '\%'), $file)) . "%'"; - - $result = Database::query("SELECT spider_id FROM " . PHPDIG_DB_PREFIX . - "spider WHERE site_id=" . ($site_id = find_site($url)) . $and_path); // find page(s) - - while ($row = Database::fetch_array($result)) - { - Database::query("DELETE FROM " . PHPDIG_DB_PREFIX . - "engine WHERE spider_id=" . (int)$row['spider_id']); // delete all references to keywords - $aff .= ' +' . Database::affected_rows(); - } - - Database::query("DELETE FROM " . PHPDIG_DB_PREFIX . - "spider WHERE site_id=" . $site_id . $and_path); // delete page - - echo htmlspecialchars($url . $path . $file, ENT_QUOTES, $charset), ' (site_id ', - $site_id, '): ', Database::affected_rows(), $aff, - ' pages + word references removed from index.
    '; - - return $site_id; -} - -function index_words($site_id, $path, $file, $first_words, $keywords) -{ - global $common_words; - - $spider_set_path_etc = "spider SET path='" . addslashes($path) . - "',file='" . addslashes($file) . "',first_words='" . - addslashes($first_words) . "',site_id='$site_id'"; - // do not set upddate,md5,num_words,last_modified,filesize - - Database::query("INSERT INTO " . PHPDIG_DB_PREFIX . $spider_set_path_etc); - - $spider_id = Database::insert_id(); $new = 0; - - foreach ($keywords as $key => $w) - if (strlen($key) > SMALL_WORDS_SIZE and strlen($key) <= MAX_WORDS_SIZE and - !isset($common_words[$key]) and - ereg('^['.WORDS_CHARS_LATIN1.'#$]', $key)) - { - $result = Database::query("SELECT key_id FROM " . PHPDIG_DB_PREFIX . - "keywords WHERE keyword = '" . addslashes($key) . "'"); - - if (Database::num_rows($result) == 0) - { - Database::query("INSERT INTO " . PHPDIG_DB_PREFIX . - "keywords (keyword,twoletters) VALUES ('" . addslashes($key) . - "','" .addslashes(substr(str_replace('\\','',$key),0,2)) ."')"); - $key_id = Database::insert_id(); $new++; - } - else - { - $keyid = Database::fetch_row($result); $key_id = $keyid[0]; - } - - Database::query("INSERT INTO " . PHPDIG_DB_PREFIX . - "engine (spider_id,key_id,weight) VALUES ($spider_id,$key_id,$w)"); - } - global $charset; - echo '', htmlspecialchars($file, ENT_QUOTES, $charset), '(spider_id ', - $spider_id, '):', count($keywords), ' kwds, ', - $new , ' new', "\n"; -} - -function get_first_words($text, $path, $file) -{ - $db_some_text = preg_replace("/([ ]{2}|\n|\r|\r\n)/" ," ", $text); - if (strlen($db_some_text) > SUMMARY_DISPLAY_LENGTH) { - $db_some_text = substr($db_some_text, 0, SUMMARY_DISPLAY_LENGTH) . "..."; - } - - $titre_resume = $path . $file; - if (($psc = strpos($titre_resume, 'scorm/')) !== FALSE) - $titre_resume = substr($titre_resume, $psc + 6); - if (($pth = strpos($titre_resume, '&thumb')) !== FALSE) - $titre_resume = substr($titre_resume, 0, $pth); - - return $titre_resume."\n".$db_some_text; -} - -function get_keywords($text) -{ - if (($token = strtok(phpdigEpureText($text), ' '))) $nbre_mots[$token] = 1; - - while (($token = strtok(' '))) - $nbre_mots[$token] = ($nm = $nbre_mots[$token]) ? $nm + 1 : 1; - - return $nbre_mots; -} - -function phpdigEpureText($text) -{ - $text = strtr(phpdigStripAccents(strtolower($text)), '��', '��'); - - $text = ereg_replace('[^'.WORDS_CHARS_LATIN1.' \'._~@#$&%/=-]+',' ',$text); // RH: was ' \'._~@#$:&%/;,=-]+', also below - - $text = ereg_replace('(['.WORDS_CHARS_LATIN1.'])[\'._~@#$&%/=-]+($|[[:space:]]$|[[:space:]]['.WORDS_CHARS_LATIN1.'])','\1\2',$text); - - // the next two repeated lines needed - if (SMALL_WORDS_SIZE >= 1) { - $text = ereg_replace('[[:space:]][^ ]{1,'.SMALL_WORDS_SIZE.'}[[:space:]]',' ',' '.$text.' '); - $text = ereg_replace('[[:space:]][^ ]{1,'.SMALL_WORDS_SIZE.'}[[:space:]]',' ',' '.$text.' '); - } - //$text = ereg_replace('\.+[[:space:]]|\.+$|\.{2,}',' ',$text); - $text = ereg_replace('\.{2,}',' ',$text); - $text = ereg_replace('^[[:space:]]*\.+',' ',$text); - - return trim(ereg_replace("[[:space:]]+"," ",$text)); -} - -function phpdigStripAccents($chaine) -{ - $chaine = str_replace('�','ae',str_replace('�','ae',$chaine)); - return strtr($chaine, LETTERS_WITH_ACCENTS, SAME_WITHOUT_ACCENTS); -} -?> diff --git a/main/metadata/md_scorm.htt b/main/metadata/md_scorm.htt deleted file mode 100755 index 1cfeb60caa..0000000000 --- a/main/metadata/md_scorm.htt +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - -Expires: Mon, 26 Jul 1997 05:00:00 GMT - - - \ No newline at end of file diff --git a/main/metadata/md_scorm.php b/main/metadata/md_scorm.php deleted file mode 100755 index 2f7c7b22eb..0000000000 --- a/main/metadata/md_scorm.php +++ /dev/null @@ -1,106 +0,0 @@ - - -{-D scormlevel {-V @level-}-}{-D two 2-} -Title: {-V metadata/lom/general/title/string-} txt-sep -{-T scormlevel == two Author(s): {-V metadata/lom/lifeCycle/contribute[1]/entity-} txt-sep-} -Keyword(s): {-R metadata/lom/general/keyword C KWTEXT-} txt-sep - {-V metadata/lom/general/description[1]/string-} - {-V metadata/lom/technical/location-} txt-end - {-V metadata/lom/general/description[2]/string-} scorm-level-{-P scormlevel-} - {-V metadata/lom/lifeCycle/contribute[1]/entity-} - {-V metadata/lom/lifeCycle/contribute[1]/date/dateTime-} - - - - - {-V string-}-kw - - - -EOD -); -} - - -function mdo_generate_default_xml_metadata() -{ - return ''; -} - - -function mdo_add_breadcrump_nav() -{ - global $interbreadcrumb; - $regs = array(); // for use with ereg() - - $docurl = api_get_self(); // should be .../main/xxx/yyy.php - if (ereg('^(.+[^/\.]+)/[^/\.]+/[^/\.]+.[^/\.]+$', $docurl, $regs)) - $docurl = $regs[1] . '/newscorm/index.php'; - - $interbreadcrumb[] = array ('url' => $docurl, - 'name' => get_lang('MdCallingTool')); -} - - -function mdobject($_course, $id) -{ - global $ieee_dcmap_e, $ieee_dcmap_v; // md_funcs - - $scormdocument = Database::get_course_table(TABLE_LP_MAIN); - - $this->mdo_course = $_course; $this->mdo_type = 'Scorm'; - $this->mdo_id = $id; $this->mdo_eid = $this->mdo_type . '.' . $id; - - $this->mdo_dcmap_e = $ieee_dcmap_e; $this->mdo_dcmap_v = $ieee_dcmap_v; - $sql = "SELECT path,description,lp_type FROM $scormdocument WHERE id='" . addslashes($id) . "'"; - if (($docinfo = @Database::fetch_array(Database::query($sql)))) - { - $this->mdo_path = $docinfo['path']; - //Sometimes the new scorm-tool adds '/.' at the end of a directory name, so remove this before continue - //the process -- bmol - if(substr($this->mdo_path,-2) == '/.') - { - $this->mdo_path = substr($this->mdo_path,0, strlen($this->mdo_path)-2); - } - $this->mdo_comment = $docinfo['description']; - //Don't think the next line is correct. There used to be a 'type' field in the scormdocument table. - //This metadata tool only works on folder types -- bmol - $this->mdo_filetype = ($docinfo['lp_type'] == 2 ? 'folder' : 'xxx'); - - $this->mdo_url = get_course_web() . $this->mdo_course['path'] . - '/scorm/' . $this->mdo_path . '/index.php'; - } -} - -} -?> diff --git a/main/metadata/md_script.js b/main/metadata/md_script.js deleted file mode 100755 index 51ccf8fa29..0000000000 --- a/main/metadata/md_script.js +++ /dev/null @@ -1,577 +0,0 @@ -// md_script.js -// - -// Copyright (C) 2006 rene.haentjens@UGent.be - see metadata/md_funcs.php --> - - -// Part 1: General funcs & Keyword Tree: copied (with modifs) from SelKwds.xsl - - String.prototype.trim = function() - { - return this.replace(/^\s*/,"").replace(/\s*$/,""); // \f\n\r\t\v - } // Dave Anderson, dbforums.com/arch/195/2003/3/724117 - - String.prototype.removeExtraSpaces = function() - { - return this.replace(/\s+/g, ' ').trim(); - } - - function makeWindow(url, htmlText) - { - var newWindow = window.open(url, '', - 'toolbar=no, location=no, directories=no, status=yes, '+ - 'menubar=yes, scrollbars=yes, resizable=yes, ' + - 'width=800, height=600, left=10, top=10'); - if (url == '') newWindow.document.write('' + - htmlText + ''); - return newWindow; - } - - function isNotW3C() - { - if (!document.getElementById) - alert('Sorry, the buttons only work with W3C browsers. ' + - 'Use FireFox or IE6 or Moz1.7 or type in keywords manually...'); - return !document.getElementById; - } - - - function openOrCloseHelp(btn) - { - if (isNotW3C()) return false; - - document.getElementById('moreHelp').className = - (btn.value == "?") ? "dvo" : "dvc"; - btn.value = (btn.value == "?") ? "¿" : "?"; - } - - function hasTagAndClass(obj, tag, cl) - { - return obj.tagName && (obj.tagName.toUpperCase() == tag) && - (obj.className == cl); - } - - - function openOrClose(btn) // show or hide part of keyword-tree - { - var oldcl = (btn.value == "-") ? "dvo" : "dvc"; - var newcl = (oldcl == "dvo") ? "dvc" : "dvo"; - btn.value = (oldcl == "dvo") ? "+" : "-" ; - - var ch = btn.parentNode.childNodes; // opera crashes on with() - for (var i = 0; i < ch.length; i++) // netscape requires .item - if (hasTagAndClass(ch.item(i), 'DIV', oldcl)) - ch.item(i).className = newcl; - } - - function openOrCloseHere(div, wrong) // show or hide recursively - { - var ch = div.childNodes; - for (var i = 0; i < ch.length; i++) - { - var thisCh = ch.item(i); - if (thisCh.className == 'btn' && thisCh.value == wrong) - openOrClose(thisCh) - else if (thisCh.className == 'dvo' || thisCh.className == 'dvc') - openOrCloseHere(thisCh, wrong); - } - } - - function openOrCloseAll(btn) // show or hide whole keyword-tree - { - if (isNotW3C()) return false; - - var wrong = (btn.value == "--") ? "-" : "+" ; - btn.value = (wrong == "-") ? "++" : "--"; - - openOrCloseHere(btn.parentNode, wrong); - } - - - var selspans = new Array; // selected SPANs with keywords - - function deselect(span) - { - for (var s in selspans) if (selspans[s] == span) delete selspans[s]; - } - - function copyToClipboard(allKwds) // md_script: not used - { - if (window.clipboardData) - { - window.clipboardData.setData("Text", '<' + allKwds + '>\r\n'); - return; - } - - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - var gClipboardHelper = Components.classes['@mozilla.org/widget/clipboardhelper;1'] - .getService(Components.interfaces.nsIClipboardHelper); - gClipboardHelper.copyString('<' + allKwds + '>\n'); - } - - function getSelectedKeywords() - { - var sortedKwds = new Array, allKwds = ''; - - for (var s in selspans) - sortedKwds.push(selspans[s].parentNode.getAttribute('level') - + '.' + selspans[s].innerHTML) - - sortedKwds.sort(); // according to level, which follows the tree - - for (var k in sortedKwds) - { - var someWords = sortedKwds[k]; - allKwds += ', ' + someWords.substr(someWords.indexOf('.')+1); - } - - return allKwds.replace(/[,_\s]+/g, ', ').substr(2); // strip ', ' - } - - - var orkwds; // array of ', kw, ' strings - - function selectOriginal(div) - { - var ch = div.childNodes; - for (var i = 0; i < ch.length; i++) - { - var thisCh = ch.item(i); if (!thisCh.tagName) continue; - thisTag = thisCh.tagName.toUpperCase(); - - if (thisTag == 'SPAN') - { - var parkwds = ','+ thisCh.innerHTML.replace(/\s*/g,"") +','; - - for (var k = 0; k < orkwds.length; k++) - if (parkwds.indexOf(orkwds[k]) >=0 ) - { - deselect(thisCh); selspans.push(thisCh); - thisCh.className = "lbs"; - - openToTop(div, div.className); break; - } - } - else if (thisTag == 'DIV') - { - selectOriginal(thisCh); - } - } - } - - function openToTop(div, divclass) - { - if (!div.parentNode) return; var pdiv = div.parentNode; - - if (!pdiv.className) return; var pclass = pdiv.className; - if (pclass != 'dvo' && pclass != 'dvc') return; - - if (divclass == 'dvc') - { - var ch = pdiv.childNodes; - for (var i = 0; i < ch.length; i++) - { - var btn = ch.item(i); - if (hasTagAndClass(btn, 'INPUT', 'btn')) - if (btn.value == '+') openOrClose(btn); - } - } - - openToTop(pdiv, pclass); - } - - function deselectAll(ev, btn) - { - if (isNotW3C()) return false; - - if (!ev) var ev = window.event; - - var kws = document.getElementById('kwds_string'); - - for (var s in selspans) selspans[s].className = "lbl"; - selspans = new Array; - - document.getElementById('btnOpenOrCloseAll').value = "--"; - - if (!ev.altKey) { kws.value = ''; return; } - - // md_script: the calling HTML should define var kwdswere! - // in SelKwds.xsl, they are typed in by user or fetched from PPT - - var kwdsarray = kwdswere.split(','), allKwds = ''; - - for (var k = 0; k < kwdsarray.length; k++) - { - var kwd = kwdsarray[k].trim(); - if (kwd.substr(0,1) == '-') kwd = kwd.substr(1); - if (kwd != '') allKwds += '§,' + kwd + ','; - } - - if (allKwds == '') return; - - orkwds = allKwds.substr(1).split('§'); - - selectOriginal(btn.parentNode); - - allKwds = getSelectedKeywords(); kws.value = allKwds; - // no copyToClipboard(allKwds); - - allKwds = ','+ allKwds.replace(/\s*/g,"") +','; var missing = ''; - for (k = 0; k < orkwds.length; k++) - if (allKwds.indexOf(orkwds[k]) < 0 ) missing += orkwds[k]; - - if (missing != '') alert('!= ' + missing.replace(/,+/g," ")); - } - - function selectOrDeselect(span, newcl) - { - span.className = newcl; deselect(span); - if (newcl == "lbs") selspans.push(span); - } - - function alsoParents(div, oldcl, newcl) - { - while (div.parentNode) - { - div = div.parentNode; var ch = div.childNodes; - for (var i = 0; i < ch.length; i++) - if (hasTagAndClass(ch.item(i), 'SPAN', oldcl)) - selectOrDeselect(ch.item(i), newcl); - } - } - - function spanClick(span, ev) // md_script: no parents in search - { - var mda = getObj("mda"); if (!ev) ev = window.event; - - if (ev.shiftKey && ev.altKey) - { - makeWindow('', '
    ' + span.parentNode.innerHTML
    -                    .replace(/&/g, "&").replace(/"/g, """)
    -                    .replace(//g, ">") + '
    '); - return; // debugging... - } - - if (ev.ctrlKey || span.className == "lbs") - { - selectOrDeselect(span, "lbl"); // deselect - if (document.selection) document.selection.empty(); - if (ev.altKey) alsoParents(span.parentNode, "lbs", "lbl"); - } - else - { - selectOrDeselect(span, "lbs"); // select (search: no parents) - if (mda && !ev.altKey) alsoParents(span.parentNode, "lbl", "lbs"); - if (!mda && ev.altKey) // mda does not exist in search form - if (span.innerHTML.substr(0, 1) == '-') - span.innerHTML = (', ' + span.innerHTML).replace(/, -/g, ", ").substr(2); - else span.innerHTML = (', ' + span.innerHTML).replace(/, /g, ", -").substr(2); - } - - var allKwds = getSelectedKeywords(); // no copyToClipboard(allKwds); - document.getElementById('kwds_string').value = allKwds; - } - - - var KWDS_ARRAY = new Array, nkw = 0, pU; // alphabetic list popup - - function makeAlphaList(div) // md_script: not used (hopefully) - { - var ch = div.childNodes; - for (var i = 0; i < ch.length; i++) - { - var thisCh = ch.item(i); if (!thisCh.tagName) continue; - thisTag = thisCh.tagName.toUpperCase(); - - if (thisTag == 'SPAN') - { - var parkwds= thisCh.innerHTML.replace(/\s*/g,"").split(','); - for (k in parkwds) KWDS_ARRAY[nkw++] = parkwds[k]; - } - else if (thisTag == 'DIV') makeAlphaList(thisCh); - } - } - - function pU_show(anchor, offsetX, offsetY, defH) // XY: rel. to anchor - { - if (!anchor) return; - - thisx = anchor.offsetLeft; thisy = anchor.offsetTop; - - while ((anchor = anchor.offsetParent)) - { - thisx += anchor.offsetLeft; thisy += anchor.offsetTop; - } - - thisx += offsetX; thisy += offsetY; - - pU.style.left = thisx + "px"; - pU.style.top = thisy + "px"; - pU.style.height = defH; var maxH = pU.offsetHeight; - for (var curH = 20; curH <= maxH; curH += 20) - { - pU.style.height = curH + 'px'; - if (curH >= pU.scrollHeight) break; - } - // scrollHeight can be smaller than current in IE, not in Moz - pU.style.visibility = "visible"; - } - - function pU_hide() - { - if (pU) pU.style.visibility = "hidden"; - } - - function takeTypeIn(kws, oX, oY, defH) - { - if (isNotW3C()) return; - - if (!pU) - { - pU = document.getElementById('popup'); - - if (!KWDS_ARRAY.length) - { - makeAlphaList(document.getElementById('maindiv')); - KWDS_ARRAY.sort(); - } - } - - if (!(curValue = kws.value.toLowerCase())) return; - - var kwLines = ''; - - for (pos = 0; pos < KWDS_ARRAY.length; pos++) - if (KWDS_ARRAY[pos].toLowerCase().indexOf(curValue) == 0) - kwLines += '
    ' + KWDS_ARRAY[pos] + '
    '; - - if (kwLines == '') {pU_hide(); return; } - - pU.innerHTML = kwLines; pU_show(kws, oX, oY, defH); - } - - function pU_clicked(ev) - { - if (!pU) return false; if (!ev) var ev = window.event; - - var t = (ev.srcElement) ? ev.srcElement : ev.originalTarget; - try {var kw = t.innerHTML;} catch(exc) {return false;} // Moz - - while (true) try - { - if (t.id == pU.id) return kw ? kw : true; t = t.parentNode; - } - catch(exc) {return false;} // Moz: t.parentNode uncatched exc. - } - - function pU_select(kw) - { - if (kw === true) return; - - var kws = document.getElementById('kwds_string'); - var maindiv = document.getElementById('maindiv'); - - var ch = maindiv.childNodes; - for (var i = 0; i < ch.length; i++) - { - var btn = ch.item(i); - if (hasTagAndClass(btn, 'INPUT', 'btn')) - if (btn.value == '+') openOrClose(btn); - } - orkwds = new Array(',' + kw + ','); selectOriginal(maindiv); - - kws.value = getSelectedKeywords(); // no copyToClipboard(kws.value); - - pU_hide(); - } - - -// Part 2: Metadata Updates: W3C, IE4 and NS4 browsers - - function isValidChar(ev, pattern, flags) - { - // e.g. onKeyPress="return isValidChar(event, '[a-z]', 'i');" - - if (!ev) var ev = window.event; // PPK, see below - var kc = (ev.keyCode) ? ev.keyCode : ev.which; // PPK - return (new RegExp(pattern, flags)).test(String.fromCharCode(kc)); - - // PPK= Peter-Paul Koch, www.quirksmode.org - } - - function checkValid(inputField, pattern, flags) - { - // e.g. onKeyUp="checkValid(this, '^[a-z]{2,8}$', 'i');" - - var fieldColor = (new RegExp(pattern, flags)).test(inputField.value) ? '#000000' : '#D8366C'; - var fieldStyle = (document.getElementById || document.all) ? - inputField.style : inputField; - if (fieldStyle) fieldStyle.color = fieldColor; - - // OK for all browsers (see devedge.netscape.com - // /library/xref/2003/css-support/css1/mastergrid.html): - // color, background-color (not on NN4), display block/none (NN4?), - // overflow hidden/scroll/auto (not on NN4), - // position relative/static, - // text-align left/right/center, text-indent, - // font-style normal/italic, font-weight normal/bold, - // font-family serif/sans-serif/monospace, - // border-style none/solid/double/groove/ridge/inset/outset. - } - - function getObj(name) // PPK - { - return (document.getElementById) ? document.getElementById(name) - : (document.all) ? document.all[name] // IE4 - : (document.layers) ? document.layers[name] // NS4 - : null; // With NS4, nested layers are not supported! - } - - function spc(path, value) // set pending change in form field mda - { - var mda = getObj("mda"); - if (mda) mda.value += "\n" + path + '=' + value; - } - - function spcSel(path, selbox) // set pending change, language selection - { - var mda = getObj("mda"); - if (mda) mda.value += "\n" + path + '=' + - selbox.options[selbox.selectedIndex].value; - } - - function checkBeforeSubmit(ev) - { - if (!ev) var ev = window.event; - - if (ev.ctrlKey && ev.altKey) - { - var mdt = getObj("mdt"); if (!mdt) return false; - - makeWindow('', '
    ' +
    -                    ('' +
    -                     '  \n\n' +
    -                     mdt.value)
    -                        .replace(/&/g, '&').replace(/"/g, '"')
    -                        .replace(//g, '>') +
    -                    '
    '); - return false; - } - - var kwdsnow = getObj("kwds_string"); if (!kwdsnow) return true; - if (kwdsnow.value == kwdswere) return true; // unchanged - // note: calling HTML should define var kwdswere! - - var language = kwdsnow.title; - - var mda = getObj("mda"); - if (!mda) { alert('? Form does not contain mda'); return false; } - - var kwdsarray = kwdswere.split(','); - - for (var k = 0; k < kwdsarray.length; k++) // delete old - if (kwdsarray[k].trim() != '') - mda.value += "\nmetadata/lom/general/keyword[-1]~"; - - kwdsarray = kwdsnow.value - .replace(/[!-,:-@\[-\^{-~\s]+/g, ',').split(','); - - for (k = 0; k < kwdsarray.length; k++) - { - var newkw = kwdsarray[k].trim(); - if (newkw != '') mda.value += - "\nmetadata/lom/general!keyword" + - "\nmetadata/lom/general/keyword[-1]!string=" + newkw + - "\nmetadata/lom/general/keyword[-1]/string/@language=" + language; - } - - return true; - - } - - function setPendingOperation(op, ev) - { - if (!ev) var ev = window.event; - - var mda = getObj("mda"); - if (!mda) { alert('? Form does not contain mda'); return false; } - - if (op == '!!' || (op == '~~' && confirm(mda.title))) - { - mda.value = op; return true; - } - - return false; - } - - function prepSearch(ev) - { - if (!ev) var ev = window.event; - - var mdsc = getObj("mdsc"); - if (!mdsc) { alert('? Form does not contain mdsc'); return false; } - - var kwdsnow = getObj("kwds_string"); if (!kwdsnow) return true; - if (kwdsnow.value == '') return true; - - if (!KWDS_ARRAY.length) - { - makeAlphaList(getObj('maindiv')); - KWDS_ARRAY.sort(); - } - - var restricttokwds = false, checkbox = getObj("restricttokwds"); - if (checkbox) restricttokwds = checkbox.checked; - - var kwdsarray = kwdsnow.value - .replace(/[!-,:-@\[-\^{-~\s]+/g, ',').split(','); - - for (var k = 0; k < kwdsarray.length; k++) - { - var newkw = kwdsarray[k].trim().toLowerCase(); - - if (newkw != '') - { - var realkw = false; - - if (restricttokwds) - for (pos = 0; pos < KWDS_ARRAY.length; pos++) - if (KWDS_ARRAY[pos].toLowerCase() == newkw) - { realkw = true; break; } - mdsc.value += "\n" + newkw + (realkw ? '-kw' : ''); - - } - } - - return true; - } - - var CRLF = "\n"; // generates clickable tree and populates KWDS_ARRAY - - function traverseKwObj(node, parlev, num) // see KWTREE_OBJECT in md_funcs - { - var curlev = '00' + (num+1), kwn = '', html = ''; - curlev = parlev + curlev.substr(curlev.length-3); - - for (i in (names = node.n.split("_"))) - if (nn = names[i]) { KWDS_ARRAY.push(nn); kwn += ', ' + nn; } - - for (j in node.c) html += traverseKwObj(node.c[j], curlev, Math.abs(j)); - - return (parlev == '') ? html : - '
    ' + CRLF + - '' : - 'lfn" value=" "/>') + ' ' + CRLF + - '' : '>') + - kwn.substr(2) + '' + CRLF + - (node.cm ? '' + node.cm + '' : '') + - html + - '
    ' + CRLF; - } - - -// The End \ No newline at end of file diff --git a/main/metadata/md_styles.css b/main/metadata/md_styles.css deleted file mode 100755 index 84fada5e2e..0000000000 --- a/main/metadata/md_styles.css +++ /dev/null @@ -1,25 +0,0 @@ -/* 2005/01/04 - - Copyright (C) 2005 rene.haentjens@UGent.be - see metadata/md_funcs.php */ - -.bg1 {background-color: #4171B5; font-size: 2pt} -.bg2 {background-color: #666666; font-size: 2pt} -.bg3 {background-color: #E6E6E6; width: 100%} - -.kwl {width: 92%} -.w23 {width: 66%} -.wd1 {width: 15ex} -.wd2 {width: 32ex} -.mda {width: 100%; display: none} -.lgr {background-color: #F0F0F0} - -.dvc {display: none; margin-left: 3ex} -.dvo {display: block; margin-left: 3ex} -.btm {height: 3.5ex; width: 5ex; font-family: monospace; font-size: xx-small} -.btn {height: 3.5ex; width: 3ex; font-family: monospace; font-size: xx-small} -.lfn {height: 3.5ex; width: 3ex; font-family: monospace; font-size: xx-small; visibility: hidden} -.lbl {background-color: #C0C0C0; cursor: pointer} -.lbs {background-color: #B0C4DE; cursor: pointer; border-style: solid; border-width: 1px} -.pup {position:absolute; visibility:hidden; width: 50%; border: 1px solid black; overflow:auto; background-color: #C0C0C0} -.pul {background-color: #FFFFFF} -.wide {width: 99%} \ No newline at end of file diff --git a/main/metadata/mds_mix.htt b/main/metadata/mds_mix.htt deleted file mode 100755 index e734183510..0000000000 --- a/main/metadata/mds_mix.htt +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - -

    Metadata {-L Search-}

    - -{-P traceinfo-} - -
    - - - - -{-R item C RESULTROW-} - - - - -
         
         
    - -
    -{-R item C RESULTTHUMB-} -
    - -
    - -
    - -
    - - - {-L SearchCrit-}
    - - - - - - - - - - -
    - -{-T keywordscache != empty - -
    - - - -  {-L ClickKw-} - {-P keywordscache-} -
    - -
    - {-L KwHelp-} -
    - -} - -{-T keywordscache == empty -
     
    - -} - -
    - - - - - - -{-D info {-X metadata/lom/lifeCycle/contribute[1]/entity-}-} -{-T info != empty D info {-P info-}, {-X parent/@identifier-}-} -{-T info == empty D info X parent/@identifier-} - - {-P info-}: {-X metadata/lom/general/title-} - Open - MD - {-X @eid-} - - - - - -{-D thumb {-X resource/file[1]/@href-}-}{-E check_is_thumb xxx-} -{-T thumb != empty -{-D info {-X metadata/lom/lifeCycle/contribute[1]/entity-}-} -{-T info != empty D info {-P info-}, {-X parent/@identifier-}-} -{-T info == empty D info X parent/@identifier-} - - -} - - - - - - - - - - - -Expires: Mon, 26 Jul 1997 05:00:00 GMT - - - - - - - - \ No newline at end of file diff --git a/main/metadata/openobject.php b/main/metadata/openobject.php deleted file mode 100755 index 0cf8b0c71e..0000000000 --- a/main/metadata/openobject.php +++ /dev/null @@ -1,32 +0,0 @@ -mdo_url); - -exit; -?> diff --git a/main/metadata/phpdig/CourseKwds_example.js b/main/metadata/phpdig/CourseKwds_example.js deleted file mode 100755 index 051d9cfc4a..0000000000 --- a/main/metadata/phpdig/CourseKwds_example.js +++ /dev/null @@ -1,79 +0,0 @@ -KWTREE_OBJECT = {n:"", ti:"Aquaculture Keywords" -, c:[{n:"organisms", cm:"(more or less in systematical order)" -, c:[{n:"bacteria"}, {n:"yeast", cm:"he<la", pt:"HoHo"}, {n:"alga" -, c:[{n:"seaweed_macroalga" -, c:[{n:"gracilaria"}, {n:"hijikia"}, {n:"laminaria"}, {n:"porphyra_nori"}, {n:"undaria_wakame"}, {n:"macroalgae-nei"}]}, {n:"microalga" -, c:[{n:"chlorella"}, {n:"dunaliella"}, {n:"isochrysis"}, {n:"nannochloropsis"}, {n:"tetraselmis"}, {n:"diatom-nei"}, {n:"microalga-nei"}]}]}, {n:"rotifer" -, c:[{n:"brachionus-plicatilis"}, {n:"rotifer-nei"}]}, {n:"mollusc" -, c:[{n:"abalone_winkle_conch" -, c:[{n:"abalone_haliotis"}, {n:"other-gastropod"}]}, {n:"clam_cockle" -, c:[{n:"hard-clam_mercenaria-mercenaria"}]}, {n:"mussel" -, c:[{n:"mussel_mytilus-edulis"}]}, {n:"oyster" -, c:[{n:"oyster_ostrea-edulis"}, {n:"oyster_crassostrea-gigas"}]}, {n:"scallop_pecten" -, c:[{n:"scallop_argopecten-irradians"}, {n:"scallop_pecten-maximus"}]}, {n:"squid_cuttlefish_octopus" -, c:[{n:"octopus"}, {n:"sepia"}]}, {n:"mollusc-nei" -, c:[{n:"tapes-philippinarum"}]}]}, {n:"crustacean" -, c:[{n:"brine-shrimp_artemia"}, {n:"freshwater-crustacean" -, c:[{n:"crayfish_astacus_cherax"}, {n:"freshwater-prawn_macrobrachium-rosenbergii"}, {n:"freshwater-crustacean-nei"}]}, {n:"crab" -, c:[{n:"mudcrab_scylla"}, {n:"mitten-crab_eriocheir"}, {n:"crab-nei"}]}, {n:"lobster" -, c:[{n:"lobster_homarus"}, {n:"spiny-lobster_panilurus"}, {n:"lobster-nei"}]}, {n:"penaeid-shrimp_scampi" -, c:[{n:"fenneropenaeus-sinensis"}, {n:"penaeus-indicus"}, {n:"kuruma-shrimp_penaeus-japonicus"}, {n:"tiger-prawn_penaeus-monodon"}, {n:"penaeus-semisulcatus"}, {n:"penaeus-stylirostris"}, {n:"litopenaeus-vannamei"}, {n:"penaeid-nei"}]}, {n:"krill_planktonic-crustacean" -, c:[{n:"moina"}, {n:"copepod-nei"}, {n:"daphnia"}]}, {n:"crustacean-nei" -, c:[{n:"mysidopsis-bahia"}]}]}, {n:"fish" -, c:[{n:"carp_cyprinid" -, c:[{n:"common-carp_cyprinus-carpio"}, {n:"grass-carp_ctenopharyngodon-idella"}, {n:"koi-carp"}]}, {n:"eel" -, c:[{n:"european-eel_anguilla-anguilla"}, {n:"japanese-eel_anguilla-japonica"}]}, {n:"flatfish" -, c:[{n:"flounder_paralichthys-olivaceus"}, {n:"halibut_hippoglossus-hippoglossus"}, {n:"sole_pleuronectes"}, {n:"plaice_pleuronectes-platessa"}, {n:"turbot_scophthalmus-maximus"}, {n:"flatfish-nei"}]}, {n:"herring_sardine_anchovy" -, c:[{n:"herring_clupea-harengus"}]}, {n:"salmon_trout_smelt" -, c:[{n:"atlantic-salmon_salmo-salar"}, {n:"pacific-salmon_oncorhynchus-mykiss"}, {n:"rainbow-trout_salmo-gairdneri"}]}, {n:"shark_ray"}, {n:"tuna_bonito_billfish"}, {n:"tilapia_cichlid" -, c:[{n:"nile-tilapia_oreochromis-niloticus"}]}, {n:"freshwater-fish-nei" -, c:[{n:"african-catfish_clarias-gariepinus"}, {n:"catfish-nei"}, {n:"guppy_poecilia-reticulata"}, {n:"heterobranchus-longifilis"}, {n:"pike_esox-lucius"}, {n:"pike-perch_stizostedion-lucioperca"}, {n:"sturgeon_acipenser"}]}, {n:"marine-fish-nei" -, c:[{n:"arctic-charr_salvelinus-alpinus"}, {n:"asian-seabass_lates-calcarifer"}, {n:"atlantic-cod_gadus-morhua"}, {n:"capelin_mallotus-villosus"}, {n:"dentex_dentex-dentex"}, {n:"dolphin-fish_mahimahi_coryphaena-hippurus"}, {n:"grouper_epinephelus"}, {n:"ictalurus"}, {n:"lumpsucker_cyclopterus-lumpus"}, {n:"milkfish_chanos-chanos"}, {n:"mullet_mugil-cephalus"}, {n:"rabbitfish_siganus"}, {n:"red-drum_sciaenops"}, {n:"red-seabream_pagrus-major"}, {n:"rockfish_sebastes"}, {n:"seabass_dicentrarchus-labrax"}, {n:"seabream_sparus-aurata"}, {n:"snapper_lutjanus"}, {n:"yellowtail_seriola"}]}, {n:"ornamental-fish"}, {n:"fish-nei"}]}, {n:"other-aquatic-organism" -, c:[{n:"sponge"}, {n:"coral"}, {n:"aquatic-plants"}, {n:"aquatic-insects"}, {n:"various-worms"}, {n:"pearl_mother-of-pearl"}, {n:"sea-urchin_echinoderm"}, {n:"zooplankton_phytoplankton"}, {n:"aquatic-invertebrate-nei"}, {n:"frog_amphibian"}, {n:"turtle"}, {n:"crocodile_alligator"}, {n:"aquatic-mammal"}, {n:"aquatic-organism-nei"}]}, {n:"non-aquatic-organism", cm:"(such as birds, cattle, ...)"}]}, {n:"culture-aspects" -, c:[{n:"life-stage" -, c:[{n:"cyst"}, {n:"diapause"}, {n:"seed"}, {n:"egg"}, {n:"larva" -, c:[{n:"spat"}, {n:"umbrella"}, {n:"zoea"}, {n:"nauplius"}, {n:"mysis"}, {n:"megalopa"}, {n:"larval-stage-nei"}]}, {n:"post-larva"}, {n:"juvenile_fingerling"}, {n:"adult"}, {n:"broodstock"}, {n:"biomass"}, {n:"life-cycle"}, {n:"other-life-stage"}]}, {n:"nutrition" -, c:[{n:"diet" -, c:[{n:"dry-diet_formulated-diet"}, {n:"microbound-diet_mbd"}, {n:"wet-diet"}, {n:"live-food"}, {n:"diet-type-nei"}]}, {n:"feed-ingredient" -, c:[{n:"nutrient-requirement"}, {n:"protein"}, {n:"lipids_fat"}, {n:"hufa"}, {n:"carbohydrate"}, {n:"mineral"}, {n:"vitamin"}, {n:"fishmeal"}, {n:"energy"}, {n:"feed-additives_enrichment-product"}, {n:"feed-ingredient-nei"}]}, {n:"feed-production" -, c:[{n:"ingredient"}, {n:"formulation"}, {n:"extrusion"}]}, {n:"feeding-biology" -, c:[{n:"feed-intake"}, {n:"feeding-ratio"}, {n:"feed-conversion"}, {n:"digestion"}, {n:"excretion"}]}, {n:"nutritional-aspect-nei"}]}, {n:"culture-system" -, c:[{n:"pond_pond-culture"}, {n:"tank-culture"}, {n:"experimental-installation"}, {n:"batch-culture"}, {n:"flow-through"}, {n:"raceway-system"}, {n:"recirculation-system"}, {n:"pen-culture"}, {n:"floating-cage"}, {n:"raft_long-line"}, {n:"rack-culture_pole-culture"}, {n:"saltwork_salt-pond"}, {n:"backyard-culture"}, {n:"hydroponic-culture"}, {n:"x-----", cm:"main culture principles:"}, {n:"extensive-culture"}, {n:"semi-intensive-culture"}, {n:"intensive-culture"}, {n:"polyculture_integrated-culture"}, {n:"sea-ranching"}, {n:"culture-system-nei"}]}, {n:"culture-step_culture-activity", cm:"(more or less in chronological order)" -, c:[{n:"x-----", cm:"general culture steps:"}, {n:"reproduction_maturation"}, {n:"spawning"}, {n:"hatchery"}, {n:"larviculture"}, {n:"weaning"}, {n:"nursery"}, {n:"grow-out_farming"}, {n:"x-----", cm:"specific culture steps:"}, {n:"pond-construction"}, {n:"pond-preparation_liming_fertilisation"}, {n:"stocking_inoculation"}, {n:"acclimatisation"}, {n:"hatching"}, {n:"decapsulation"}, {n:"enrichment"}, {n:"cold-storage"}, {n:"feeding"}, {n:"sampling"}, {n:"counting"}, {n:"tagging"}, {n:"grading"}, {n:"cleaning_rinsing"}, {n:"harvesting"}, {n:"processing"}, {n:"quality-control"}, {n:"storage_packing_transport"}, {n:"culture-step-nei"}]}, {n:"equipment_infrastructure" -, c:[{n:"tank"}, {n:"bottle_tube"}, {n:"aquarium"}, {n:"substrate_holder"}, {n:"filter_sieve"}, {n:"incubator"}, {n:"hapa"}, {n:"heater"}, {n:"pump"}, {n:"aerator"}, {n:"air-water-lift"}, {n:"feeder"}, {n:"grader"}, {n:"equipment-nei", cm:"(see also 'water treatment' for more equipment)"}]}, {n:"health_disease" -, c:[{n:"treatment_health-management"}, {n:"disinfection_infection"}, {n:"stress"}, {n:"parasitose"}, {n:"bacteria"}, {n:"virus_phage"}, {n:"fungi"}, {n:"nutritional-disease"}, {n:"water-quality-disease"}, {n:"deformity"}, {n:"pesticide"}, {n:"antibiotics"}, {n:"vaccin"}, {n:"probiont"}, {n:"disease-nei"}]}, {n:"water-quality" -, c:[{n:"water-quality-parameter" -, c:[{n:"temperature"}, {n:"oxygen"}, {n:"ph_acidity"}, {n:"salinity"}, {n:"hardness"}, {n:"organic-matter"}, {n:"nitrogen-compound"}, {n:"harmful-substance"}, {n:"pathogen"}, {n:"heavy-metal"}, {n:"water-quality-parameter-nei"}]}, {n:"water-treatment" -, c:[{n:"water-analysis"}, {n:"water-sampling"}, {n:"aerator_oxygenation"}, {n:"filtering"}, {n:"suspended-solids-removal"}, {n:"protein-skimmer"}, {n:"biofilter"}, {n:"nitrification_denitrification"}, {n:"ozonisation_ozonisator"}, {n:"uv-installation"}, {n:"disinfection"}, {n:"degassing"}, {n:"liming"}, {n:"sedimentation"}, {n:"water-treatment-nei"}]}, {n:"water-usage" -, c:[{n:"water-supply"}, {n:"water-discharge"}, {n:"water-reuse_recirculation"}, {n:"green-water"}, {n:"hydrodynamics_circulation"}]}, {n:"water-quality-aspect-nei"}]}, {n:"culture-aspect-nei"}]}, {n:"life-sciences" -, c:[{n:"morphology"}, {n:"biology" -, c:[{n:"life-cycle"}, {n:"growth"}, {n:"survival"}, {n:"dose-response"}]}, {n:"taxonomy_systematics"}, {n:"ecology" -, c:[{n:"ecosystem_food-chain"}, {n:"predator_prey"}, {n:"biodiversity"}, {n:"zoogeography_natural-distribution"}, {n:"environmental-impact"}, {n:"eutrophication"}, {n:"pollution"}, {n:"toxicant_contaminant"}, {n:"ecological-footprint"}, {n:"biotope"}, {n:"indogeneous-species"}, {n:"exogeneous-species"}]}, {n:"chemistry" -, c:[{n:"analysis_chemical-composition"}, {n:"chemical_molecule"}, {n:"hormone"}, {n:"reaction"}]}, {n:"microbiology" -, c:[{n:"microflora"}, {n:"plating_plate-count_cfu"}, {n:"medium_agar"}, {n:"bacteria"}, {n:"virus"}, {n:"pathogen"}, {n:"probiont"}, {n:"opportunistic-bacteria"}, {n:"microbial-technique-nei"}]}, {n:"genetics" -, c:[{n:"qualitative-genetic-technique"}, {n:"quantative-genetic-technique"}, {n:"gene"}, {n:"dna"}, {n:"chromosome"}, {n:"selection_evolution"}, {n:"heritability"}, {n:"inbreeding"}, {n:"domestication"}, {n:"hybridization"}, {n:"ploidy"}, {n:"gynogenesis"}, {n:"androgenesis"}, {n:"population-genetics"}, {n:"gene-mapping"}, {n:"sex-determination-system"}, {n:"genetics-nei"}]}, {n:"immunology"}, {n:"microscopy" -, c:[{n:"dissection"}, {n:"length-measurement"}, {n:"counting"}, {n:"microscopy-nei"}]}]}, {n:"geography" -, c:[{n:"world" -, c:[{n:"europe" -, c:[{n:"belgium"}, {n:"the-netherlands"}, {n:"france"}, {n:"italy"}, {n:"spain_portugal"}, {n:"greece"}, {n:"uk_ireland"}, {n:"norway_sweden_denmark_iceland"}, {n:"european-country-nei"}]}, {n:"former-USSR"}, {n:"africa" -, c:[{n:"egypt"}, {n:"north-africa-nei"}, {n:"kenia"}, {n:"central-africa-nei"}, {n:"south-africa"}]}, {n:"north-and-central-america" -, c:[{n:"canada"}, {n:"usa"}, {n:"utah"}, {n:"mexico"}, {n:"central-american-state-nei"}, {n:"caribbean"}]}, {n:"south-america" -, c:[{n:"brazil"}, {n:"chile"}, {n:"colombia"}, {n:"ecuador"}, {n:"south-america-nei"}]}, {n:"asia" -, c:[{n:"middle-east"}, {n:"india"}, {n:"china"}, {n:"japan"}, {n:"vietnam"}, {n:"thailand"}, {n:"philippines"}, {n:"asian-country-nei"}]}, {n:"oceania" -, c:[{n:"australia"}, {n:"new-zealand"}]}, {n:"arctic_antarctic"}]}, {n:"biotope" -, c:[{n:"ocean_sea"}, {n:"river"}, {n:"bay_lagoon_fjord"}, {n:"coastline_estuary"}, {n:"mangrove"}, {n:"lake"}, {n:"salt-lake_salina"}, {n:"reef"}, {n:"tundra_prairie_savanna"}, {n:"mountain"}, {n:"forest_jungle"}, {n:"cultured-land"}, {n:"biotope-nei"}]}]}, {n:"other-aspects" -, c:[{n:"sectors" -, c:[{n:"education" -, c:[{n:"university_school"}, {n:"students"}, {n:"lecture_course"}, {n:"practical-exercise"}, {n:"training"}, {n:"study-trip"}, {n:"course-material"}, {n:"examination"}, {n:"scholarship_grant"}, {n:"education-nei"}]}, {n:"research" -, c:[{n:"laboratory"}, {n:"institute_university"}, {n:"scientist_researcher"}, {n:"experiment"}, {n:"project"}, {n:"publication"}, {n:"meeting_conference"}, {n:"research-nei"}]}, {n:"trade_business" -, c:[{n:"company"}, {n:"market_shop"}, {n:"trend_prospect"}, {n:"commercial-product"}, {n:"office"}, {n:"retail_distribution"}, {n:"price_money"}, {n:"marketing_publicity"}, {n:"transport"}, {n:"trade-nei"}]}, {n:"production" -, c:[{n:"farm"}, {n:"factory_industry"}, {n:"building_warehouse"}, {n:"machine"}, {n:"production-nei"}]}, {n:"other-sector" -, c:[{n:"organisation_network"}, {n:"government"}, {n:"ngo"}, {n:"development-aid"}, {n:"cooperation"}, {n:"sponsor_funding-agency"}, {n:"insurance"}, {n:"consultancy"}]}, {n:"aquaculture"}, {n:"agriculture"}, {n:"fishery" -, c:[{n:"harvest_catch"}, {n:"fishing-gear"}, {n:"vessel"}, {n:"restocking"}, {n:"by-catch"}, {n:"overfishing"}, {n:"fishery-aspect-nei"}]}]}, {n:"people" -, c:[{n:"researcher"}, {n:"farmer"}, {n:"fisherman"}, {n:"diver"}, {n:"student_teacher"}, {n:"portrait-of-specific-person_group-picture"}]}, {n:"presentation" -, c:[{n:"title"}, {n:"content_overview"}, {n:"introduction_background"}, {n:"methodology"}, {n:"results"}, {n:"advantages_disadvantages"}, {n:"discussion"}, {n:"conclusion"}, {n:"references"}, {n:"aknowledgement_thanks"}, {n:"the-end"}]}, {n:"apparatus" -, c:[{n:"hufa-analysis"}, {n:"balance"}, {n:"blender"}, {n:"kjeldahl"}, {n:"chromatograph"}, {n:"gel-electrophoresis"}, {n:"centrifuge"}, {n:"lyophilisator"}, {n:"refrigerator"}, {n:"oven"}, {n:"pipette"}, {n:"microscope"}, {n:"apparatus-nei"}]}, {n:"information_media" -, c:[{n:"literature"}, {n:"book"}, {n:"journal"}, {n:"publication"}, {n:"news"}, {n:"internet_www"}, {n:"site_links"}, {n:"discussion-list"}, {n:"computer"}, {n:"software"}, {n:"slide"}, {n:"video_dvd_cd-rom"}, {n:"telephone_fax"}, {n:"e-mail"}]}]}, {n:"slide-content" -, c:[{n:"scheme_drawing"}, {n:"graph_chart"}, {n:"table"}, {n:"map"}, {n:"just-text"}, {n:"combination", cm:"(picture combined with map or table or ...)"}, {n:"skip-this-slide", cm:"(Do not copy to SCORM output)"}]}]}; - -document.write(traverseKwObj(KWTREE_OBJECT, '', 0)); KWDS_ARRAY.sort(); \ No newline at end of file diff --git a/main/metadata/phpdig/CourseKwds_example.jsc b/main/metadata/phpdig/CourseKwds_example.jsc deleted file mode 100755 index f755769fa3..0000000000 --- a/main/metadata/phpdig/CourseKwds_example.jsc +++ /dev/null @@ -1,11 +0,0 @@ -<>Search for anything
    -Slide with scheme -Slide with graph -Slide with table -Slide with map
    -Only complete presentations
    -Only literature references - -exclude literature references -Only useful links - -exclude useful links -Exclude references and links \ No newline at end of file diff --git a/main/metadata/phpdig/config.php b/main/metadata/phpdig/config.php deleted file mode 100755 index 821417490a..0000000000 --- a/main/metadata/phpdig/config.php +++ /dev/null @@ -1,450 +0,0 @@ - 'and operator', 'w_whole' => 'exact phrase', 'w_part' => 'or operator' - -define('SEARCH_DEFAULT_LIMIT',10); //results per page - -define('SPIDER_MAX_LIMIT',20); //max recurse levels in spider -define('RESPIDER_LIMIT',5); //recurse respider limit for update -define('LINKS_MAX_LIMIT',20); //max links per each level -define('RELINKS_LIMIT',5); //recurse links limit for an update - -//for limit to directory, URL format must either have file at end or ending slash at end -//e.g., http://www.domain.com/dirs/ (WITH ending slash) or http://www.domain.com/dirs/dirs/index.php -define('LIMIT_TO_DIRECTORY',true); //limit index to given (sub)directory, no sub dirs of dirs are indexed - -define('LIMIT_DAYS',0); //default days before reindex a page -define('SMALL_WORDS_SIZE',2); //words to not index - must be 2 or more -define('MAX_WORDS_SIZE',50); // RH: was 30 //max word size - -define('PHPDIG_EXCLUDE_COMMENT',''); //comment to exclude a page part -define('PHPDIG_INCLUDE_COMMENT',''); //comment to include a page part - // must be on own lines in HTML source - // text within comments not indexed - // links within comments still indexed - -define('PHPDIG_DEFAULT_INDEX',false); //phpDig considers /index or /default - //html, htm, php, asp, phtml as the - //same as '/' - -define('ALLOW_RSS_FEED',false); // Do RSS and display link - if true, set rss dir to 777 -$theenc = PHPDIG_ENCODING; // needs to be same encoding used in index -$theurl = "http://www.phpdig.net/"; // site offering the RSS feed -$thetitle = "PhpDig.net"; // title for site offering the RSS feed -$thedesc = "PhpDig :: Web Spider and Search Engine"; // description of site offering the RSS feed -$thedir = "./rss"; // the rss directory name, no ending slash -$thefile = "search.rss"; // used in rss filenames - -define('PHPDIG_SESSID_REMOVE',true); // remove SIDS or vars from indexed URLS -define('PHPDIG_SESSID_VAR','PHPSESSID,s'); // name of SID or variable to remove - // can be 's' or comma delimited 's,id,var,foo,etc' - -define('APPEND_TITLE_META',false); //append title and meta information to results -define('TITLE_WEIGHT',3); //relative title weight: APPEND_TITLE_META needs to be true - -define('CHUNK_SIZE',1024); //chunk size for regex processing - -define('SUMMARY_LENGTH',500); //length of results summary - -define('TEXT_CONTENT_PATH','text_content/'); //Text content files path -define('CONTENT_TEXT',0); // RH: was 1 //Activates/deactivates the - //storage of text content. -define('PHPDIG_IN_DOMAIN',false); //allows phpdig jump hosts in the same - //domain. If the host is "www.mydomain.tld", - //domain is "mydomain.tld" - -define('PHPDIG_LOGS',true); //write logs -define('SILENCE_404S',true); //silence 404 output - -define('TEMP_FILENAME_LENGTH',8); //filename length of temp files -// if using external tools with extension, use 4 for filename of length 8 - -define('NUMBER_OF_RESULTS_PER_SITE',-1); //max number of results per site - // use -1 to display all results - -define('USE_RENICE_COMMAND','1'); //use renice for process priority - -//---------EXTERNAL TOOLS SETUP -// if set to true is_executable used - set to '0' if is_executable is undefined -define('USE_IS_EXECUTABLE_COMMAND','0'); // RH: was 1 //use is_executable for external binaries - -// if set to true, full path to external binary required -define('PHPDIG_INDEX_MSWORD',false); -define('PHPDIG_PARSE_MSWORD','/usr/local/bin/catdoc'); -define('PHPDIG_OPTION_MSWORD','-s 8859-1'); - -define('PHPDIG_INDEX_PDF',false); -define('PHPDIG_PARSE_PDF','/usr/local/bin/pstotext'); -define('PHPDIG_OPTION_PDF','-cork'); - -define('PHPDIG_INDEX_MSEXCEL',false); -define('PHPDIG_PARSE_MSEXCEL','/usr/local/bin/xls2csv'); -define('PHPDIG_OPTION_MSEXCEL',''); - -define('PHPDIG_INDEX_MSPOWERPOINT',false); -define('PHPDIG_PARSE_MSPOWERPOINT','/usr/local/bin/ppt2text'); -define('PHPDIG_OPTION_MSPOWERPOINT',''); - -//---------EXTERNAL TOOLS EXTENSIONS -// if external binary is not STDOUT or different extension is needed -// for example, use '.txt' if external binary writes to filename.txt -define('PHPDIG_MSWORD_EXTENSION',''); -define('PHPDIG_PDF_EXTENSION',''); -define('PHPDIG_MSEXCEL_EXTENSION',''); -define('PHPDIG_MSPOWERPOINT_EXTENSION',''); - -//---------FTP SETTINGS -define('FTP_ENABLE',0);//enable ftp content for distant PhpDig -define('FTP_HOST',''); //if distant PhpDig, ftp host; -define('FTP_PORT',21); //ftp port -define('FTP_PASV',1); //passive mode -define('FTP_PATH',''); //distant path from the ftp root -define('FTP_TEXT_PATH','text_content');//ftp path to text-content directory -define('FTP_USER',''); -define('FTP_PASS',''); - -//--------CRON SETTINGS -define('CRON_ENABLE',false); -define('CRON_EXEC_FILE','/usr/bin/crontab'); -define('CRON_CONFIG_FILE',ABSOLUTE_SCRIPT_PATH.'/admin/temp/cronfile.txt'); -define('PHPEXEC','/usr/local/bin/php'); -// NOTE: make sure ABSOLUTE_SCRIPT_PATH is the full path up to but not including the admin dir, no ending slash -// NOTE: CRON_ENABLE set to true writes a file at CRON_CONFIG_FILE containing the cron job information -// The CRON_CONFIG_FILE must be 777 permissions if applicable to your OS/setup -// You still need to call the CRON_CONFIG_FILE to run the cron job!!! -// From shell: crontab CRON_CONFIG_FILE to set the cron job: replace CRON_CONFIG_FILE with actual file -// From shell: crontab -l to list and crontab -d to delete - -// regular expression to ban useless external links in index -define('BANNED','^ad\.|banner|doubleclick'); - -// regexp forbidden extensions - return sometimes text/html mime-type !!! -define('FORBIDDEN_EXTENSIONS','\.(rm|ico|cab|swf|css|gz|z|tar|zip|tgz|msi|arj|zoo|rar|r[0-9]+|exe|bin|pkg|rpm|deb|bz2)$'); - -//----------HTML ENTITIES -$spec = array( "&" => "&", - "à" => "�", - "è" => "�", - "ù" => "�", - "ó" => "�", - "é" => "�", - "î" => "�", - "ô" => "�", - "û" => "�", - "ê" => "�", - "ç" => "�", - "œ" => "oe", - ">" => " ", - "<" => " ", - "°" => " ", - "&apos" => "'", - """ => " ", - "â" => "�", - "ï" => "�", - "ë" => "�", - "ä" => "�", - "Ä" => "�", - "Ë" => "�", - "Ï" => "�", - "Ü" => "�", - "ö" => "�", - "ü" => "�", - " " => " ", - "ß" => "�", - "í" => "�", - "®" => " ", - "©" => " ", - "á" => "�", - "Á" => "�", - "ð" => "�", - "Ð" => "�", - "É" => "�", - "Í" => "�", - "Ó" => "�", - "ú" => "�", - "Ú" => "�", - "Þ" => "�", - "þ" => "�", - "Ö" => "�", - "æ" => "�", - "&AELIG" => "�", - "å" => "�", - "Å" => "�", - "ø" => "�", - "Ø" => "�" - ); - -//month names in iso dates -$month_names = array ('jan'=>1, - 'feb'=>2, - 'mar'=>3, - 'apr'=>4, - 'may'=>5, - 'jun'=>6, - 'jul'=>7, - 'aug'=>8, - 'sep'=>9, - 'oct'=>10, - 'nov'=>11, - 'dec'=>12 - ); - -//apache multi indexes parameters -$apache_indexes = array ( "?N=A" => 1, - "?N=D" => 1, - "?M=A" => 1, - "?M=D" => 1, - "?S=A" => 1, - "?S=D" => 1, - "?D=A" => 1, - "?D=D" => 1, - "?C=N&O=A" => 1, - "?C=M&O=A" => 1, - "?C=S&O=A" => 1, - "?C=D&O=A" => 1, - "?C=N&O=D" => 1, - "?C=M&O=D" => 1, - "?C=S&O=D" => 1, - "?C=D&O=D" => 1); - -//includes language file -define('PHPDIG_LANG_CONSTANT',$phpdig_language); // this line for classic -if (is_file("$relative_script_path/locales/$phpdig_language-language.php")) { - include "$relative_script_path/locales/$phpdig_language-language.php"; -} -elseif (is_file("$relative_script_path/locales/en-language.php")) { - include "$relative_script_path/locales/en-language.php"; -} -else { - die("Unable to select language pack.\n"); -} - -//connection to database -if ((!isset($no_connect)) || ($no_connect != 1)) { - if (is_file("$relative_script_path/includes/connect.php")) { - include "$relative_script_path/includes/connect.php"; - } - else { - die("Unable to find connect.php file.\n"); - } -} - -//includes of libraries -if (is_file("$relative_script_path/libs/phpdig_functions.php")) { - include "$relative_script_path/libs/phpdig_functions.php"; -} -else { - die ("Unable to find phpdig_functions.php file.\n"); -} -if (is_file("$relative_script_path/libs/function_phpdig_form.php")) { - include "$relative_script_path/libs/function_phpdig_form.php"; -} -else { - die ("Unable to find function_phpdig_form.php file.\n"); -} -if (is_file("$relative_script_path/libs/mysql_functions.php")) { - include "$relative_script_path/libs/mysql_functions.php"; -} -else { - die ("Unable to find mysql_functions.php file.\n"); -} -if ((!isset($template)) || ((!is_file($template)) && ($template != "array") && ($template != "classic"))) { - die ("Unable to render template file.\n"); -} - -if (!defined('CONFIG_CHECK')) { - exit(); -} - -// parse encodings (create global $phpdigEncode); -phpdigCreateSubstArrays($phpdig_string_subst); -// send encoding if needed -if (!headers_sent()) { - header('Content-type:text/html; Charset='.PHPDIG_ENCODING); -} -// turn off magic_quotes_runtime for escaping purposes -@ini_set('magic_quotes_runtime',false); -// turn off magic_quotes_sybase for escaping purposes -@ini_set('magic_quotes_sybase',false); -if ((!isset($no_connect)) || ($no_connect != 1)) { - phpdigCheckTables($id_connect,array('engine', - 'excludes', - 'keywords', - 'sites', - 'spider', - 'tempspider', - 'logs', - 'clicks', - 'site_page', - 'includes')); -} -?> diff --git a/main/metadata/phpdig/en-language.php b/main/metadata/phpdig/en-language.php deleted file mode 100755 index 508f1505f0..0000000000 --- a/main/metadata/phpdig/en-language.php +++ /dev/null @@ -1,199 +0,0 @@ - 'translation' -$phpdig_mess = array ( -'one_per_line' =>'Enter one link per line', - -'StopSpider' =>'Stop spider', -'id' =>'ID', -'url' =>'URL', -'days' =>'Days', -'links' =>'Links', -'depth' =>'Depth', -'viewRSS' =>'View RSS for this Page', -'powered_by' =>'Powered by PhpDig', -'searchall' =>'Search All', -'wait' =>'Wait... ', -'done' =>'Done!', -'limit' =>'Limit', -'manage' =>'Here you can manage:', -'dayscron' =>'- the number of days crontab waits to reindex (0 = ignore)', -'links_mean' =>'- the max number of links per depth per site (0 = unlimited)', -'depth_mean' =>'- the max search depth per site (0 = none, depth trumps links)', -'max_found' =>'Maximum links found is ((links * depth) + 1) when links is greater than zero.', -'default_vals' =>'Default values', -'use_vals_from' =>'Use values from', -'table_present' =>'table if present and use
    default values if values absent from table?', -'admin_msg_1' =>'- To empty tempspider table click delete button without selecting a site', -'admin_msg_2' =>'- Search depth of zero tries to crawl just that page regardless of links per', -'admin_msg_3' =>'- Set links per depth to the max number of links to check at each depth', -'admin_msg_4' =>'- Links per depth of zero means to check for all links at each seach depth', -'admin_msg_5' =>'- Clean dashes removes \'-\' index pages from blue arrow listings of pages', -'admin_panel' =>'Admin Panel', - -'choose_temp' =>'Choose a template', -'select_site' =>'Select a site to search', -'restart' =>'Restart', -'narrow_path' =>'Narrow Path to Search', -'upd_sites' =>'Update sites', -'upd2' =>'Update Done', -'links_per' =>'Links per', -'yes' =>'yes', -'no' =>'no', -'delete' =>'delete', -'reindex' =>'Re-index', -'back' =>'Back', -'files' =>'files', -'admin' =>'Administration', -'warning' =>'Warning !', -'index_uri' =>'Which URI would you index?', -'spider_depth' =>'Search depth', -'spider_warn' =>'Please ensure that no one else is updating the same site. -A locking mechanism will be included in a later version.', -'site_update' =>'Update a site or one of its branch', -'clean' =>'Clean', -'t_index' =>'index', -'t_dic' =>'dictionary', -'t_stopw' =>'common words', -'t_dash' =>'dashes', - -'update' =>'Update', -'exclude' =>'Delete and exclude branch', -'excludes' =>'Exclude paths', -'tree_found' =>'Found tree', -'update_mess' =>'Re-index or delete a tree ', -'update_warn' =>'Exclude will delete indexed entries', -'update_help' =>'Click on the cross to delete the branch -Click on the green sign to update it -Click on the noway sign to exclude from future indexings', -'branch_start' =>'Select the folder to display on the left side', -'branch_help1' =>'Select there documents to update individually', -'branch_help2' =>'Click on the cross to delete a document -Click on the green sign to reindex it', -'redepth' =>'levels depth', -'branch_warn' =>'Erase is permanent', -'to_admin' =>'to admin interface', -'to_update' =>'to update interface', - -'search' =>'Search', -'results' =>'results', -'display' =>'display', -'w_begin' =>'and operator', -'w_whole' =>'exact phrase', -'w_part' =>'or operator', -'alt_try' =>'Did you mean', - -'limit_to' =>'limit to', -'this_path' =>'this path', -'total' =>'total', -'seconds' =>'seconds', -'w_common_sing' =>'is a very common word and was ignored.', -'w_short_sing' =>'is too short a word and was ignored.', -'w_common_plur' =>'are very common words and were ignored.', -'w_short_plur' =>'are too short of words and were ignored.', -'s_results' =>'search results', -'previous' =>'Previous', -'next' =>'Next', -'on' =>'on', - -'id_start' =>'Site indexing', -'id_end' =>'Indexing complete !', -'id_recent' =>'Was recently indexed', -'num_words' =>'Num words', -'time' =>'time', -'error' =>'Error', -'no_spider' =>'Spider not launched', -'no_site' =>'No such site in database', -'no_temp' =>'No link in temporary table', -'no_toindex' =>'No content indexed', -'double' =>'Duplicate of an existing document', - -'spidering' =>'Spidering in progress...', -'links_more' =>'more new links', -'level' =>'level', -'links_found' =>'links found', -'define_ex' =>'Define exclusions', -'index_all' =>'index all', - -'end' =>'end', -'no_query' =>'Select predefined keywords (recommended) by opening the tree with the [+] button below, or type descriptive words in the inputzone, separated by a comma, or type the first letters of a keyword and use autocomplete. Empty the inputzone to re-use autocomplete', -'pwait' =>'Please wait', -'statistics' =>'Statistics', - -// INSTALL -'slogan' =>'The smallest search engine in the universe : version', -'installation' =>'Installation', -'instructions' =>'Type here the MySql parameters. Specify a valid existing user who can create databases if you choose create or update.', -'hostname' =>'Hostname :', -'port' =>'Port (none = default) :', -'sock' =>'Sock (none = default) :', -'user' =>'User :', -'password' =>'Password :', -'phpdigdatabase' =>'PhpDig database :', -'tablesprefix' =>'Tables prefix :', -'instructions2' =>'* optional. Use lowercase characters, 16 characters max.', -'installdatabase' =>'Install phpdig database', -'error1' =>'Can\'t find connexion template. ', -'error2' =>'Can\'t write connexion template. ', -'error3' =>'Can\'t find init_db.sql file. ', -'error4' =>'Can\'t create tables. ', -'error5' =>'Can\'t find all config database files. ', -'error6' =>'Can\'t create database.
    Verify user\'s rights. ', -'error7' =>'Can\'t connect to database
    Verify connection datas. ', -'createdb' =>'Create database', -'createtables' =>'Create tables only', -'updatedb' =>'Update existing database', -'existingdb' =>'Write only connection parameters', -// CLEANUP_ENGINE -'cleaningindex' =>'Cleaning index', -'enginenotok' =>' index references targeted an inexistent keyword.', -'engineok' =>'Engine is coherent.', -// CLEANUP_KEYWORDS -'cleaningdictionnary' =>'Cleaning dictionary', -'keywordsok' =>'All keywords are in one or more page.', -'keywordsnotok' =>' keywords where not in one page at least.', -// CLEANUP_COMMON -'cleanupcommon' =>'Cleanup common words', -'cleanuptotal' =>'Total ', -'cleaned' =>' cleaned.', -'deletedfor' =>' deleted for ', -// INDEX ADMIN -'digthis' =>'Dig this !', -'databasestatus' =>'DataBase status', -'entries' =>' Entries ', -'updateform' =>'Update form', -'deletesite' =>'Delete site', -// SPIDER -'spiderresults' =>'Spider results', -// STATISTICS -'mostkeywords' =>'Most keywords', -'richestpages' =>'Richest pages', -'mostterms' =>'Most search terms', -'largestresults'=>'Largest results', -'mostempty' =>'Most searchs giving empty results', -'lastqueries' =>'Last search queries', -'lastclicks' =>'Last search clicks', -'responsebyhour'=>'Response time by hour', -// UPDATE -'userpasschanged' =>'User/Password changed !', -'uri' =>'URI : ', -'change' =>'Change', -'root' =>'Root', -'pages' =>' pages', -'locked' => 'Locked', -'unlock' => 'Unlock site', -'onelock' => 'A site is locked, because of spidering. You can\'t do this for now', -// PHPDIG_FORM -'go' =>'Go ...', -// SEARCH_FUNCTION -'noresults' =>'No results' -); -?> diff --git a/main/metadata/phpdig/phpdig_functions.php b/main/metadata/phpdig/phpdig_functions.php deleted file mode 100755 index 515ec7d384..0000000000 --- a/main/metadata/phpdig/phpdig_functions.php +++ /dev/null @@ -1,279 +0,0 @@ - vartype -// Useful for error_reporting E_ALL too, init variables -// usage in script : extract(phpdigHttpVars(array('foobar'=>'string'))); -function phpdigHttpVars($varray=array()) { -$parse_orders = array('_POST','_GET','HTTP_POST_VARS','HTTP_GET_VARS'); -$httpvars = array(); -// extract the right array -if (is_array($varray)) { - foreach($parse_orders as $globname) { - global $$globname; - if (!count($httpvars) && isset($$globname) && is_array($$globname)) { - $httpvars = $$globname; - } - } - // extract or create requested vars - foreach($varray as $varname => $vartype) { - if (in_array($vartype,array('integer','bool','double','float','string','array')) ) { - if (!isset($httpvars[$varname])) { - if (!isset($GLOBALS[$varname])) { - $httpvars[$varname] = false; - } - else { - $httpvars[$varname] = $GLOBALS[$varname]; - } - } - settype($httpvars[$varname],$vartype); - } - } -return $httpvars; -} -} - -/** - * timer for profiling - * @package chamilo.metadata - */ -class phpdigTimer { - var $time = 0; - var $mode = ''; - var $marks = array(); - var $template = ''; - - function phpdigTimer($mode='html') { - $this->time = $this->getTime(); - if ($mode == 'cli') { - $this->template = "%s:\t%0.9f s. \n"; - } - else { - $this->template = "%s%0.9f s. \n"; - } - } - function start($name) { - if (!isset($this->marks[$name])) { - $this->marks[$name]['time'] = $this->getTime(); - $this->marks[$name]['stat'] = 'r'; - } - else if ($this->marks[$name]['stat'] == 's') { - $this->marks[$name]['time'] = $this->getTime()-$this->marks[$name]['time']; - $this->marks[$name]['stat'] = 'r'; - } - } - function stop($name) { - if (isset($this->marks[$name]) && $this->marks[$name]['stat'] == 'r') { - $this->marks[$name]['time'] = $this->getTime()-$this->marks[$name]['time']; - } - else { - $this->marks[$name]['time'] = 0; - } - $this->marks[$name]['stat'] = 's'; - } - function display() { - if ($this->mode != 'cli') { - print "\n"; - } - foreach($this->marks as $name => $value) { - printf($this->template,ucwords($name),$value['time']); - } - if ($this->mode != 'cli') { - print "
    MarkValue
    \n"; - } - } - // increase precision with deltime - function getTime() { - return array_sum(explode(' ',microtime()))-$this->time; - } -} - -//-------------STRING FUNCTIONS - -//================================================= -//returns a localized string -function phpdigMsg($string='') { -global $phpdig_mess; -if (isset($phpdig_mess[$string])) { - return nl2br($phpdig_mess[$string]); -} -else { - return ucfirst($string); -} -} - -//================================================= -//print a localized string -function phpdigPrnMsg($string='') { -global $phpdig_mess; -if (isset($phpdig_mess[$string])) { - print nl2br($phpdig_mess[$string]); -} -else { - print ucfirst($string); -} -} - -//================================================= -//load the common words in an array -function phpdigComWords($file='') -{ -$lines = @file($file); -if (is_array($lines)) - { - while (list($id,$word) = each($lines)) - $common[trim($word)] = 1; - } -else - $common['aaaa'] = 1; -return $common; -} - -//================================================= -//highlight a string part -function phpdigHighlight($ereg='',$string='') -{ -if ($ereg) { - $string = @eregi_replace($ereg,"\\1<^#_>\\2\\3",@eregi_replace($ereg,"\\1<^#_>\\2\\3",$string)); - $string = str_replace("^#_","span class=\"phpdigHighlight\"",str_replace("_#^","span",$string)); - return $string; -} -else { - return null; -} -} - -//================================================= -//replace all characters with an accent -function phpdigStripAccents($chaine,$encoding=PHPDIG_ENCODING) { -global $phpdigEncode; -if (!isset($phpdigEncode[$encoding])) { - $encoding = PHPDIG_ENCODING; -} -// exceptions -if ($encoding == 'iso-8859-1') { - $chaine = str_replace('�','ae',str_replace('�','ae',$chaine)); -} -return( strtr( $chaine,$phpdigEncode[$encoding]['str'],$phpdigEncode[$encoding]['tr']) ); -} - -//========================================== -//Create a ereg for highlighting -function phpdigPregQuotes($chaine,$encoding=PHPDIG_ENCODING) { -global $phpdigEncode; -if (!isset($phpdigEncode[$encoding])) { - $encoding = PHPDIG_ENCODING; -} -$chaine = preg_quote(strtolower(phpdigStripAccents($chaine,$encoding))); -return str_replace($phpdigEncode[$encoding]['char'],$phpdigEncode[$encoding]['ereg'],$chaine); -} - -//================================================= -// Create Useful arrays for different encodings -function phpdigCreateSubstArrays($subststrings) { -$phpdigEncode = array(); -global $phpdigEncode; - -foreach($subststrings as $encoding => $subststring) { - $tempArray = explode(',',$subststring); - if (!isset($phpdigEncode[$encoding])) { - $phpdigEncode[$encoding] = array(); - } - $phpdigEncode[$encoding]['str'] = ''; - $phpdigEncode[$encoding]['tr'] = ''; - $phpdigEncode[$encoding]['char'] = array(); - $phpdigEncode[$encoding]['ereg'] = array(); - foreach ($tempArray as $tempSubstitution) { - $chrs = explode(':',$tempSubstitution); - $phpdigEncode[$encoding]['char'][strtolower($chrs[0])] = strtolower($chrs[0]); - settype($phpdigEncode[$encoding]['ereg'][strtolower($chrs[0])],'string'); - $phpdigEncode[$encoding]['ereg'][strtolower($chrs[0])] .= $chrs[0].$chrs[1]; - for($i=0; $i < strlen($chrs[1]); $i++) { - $phpdigEncode[$encoding]['str'] .= $chrs[1][$i]; - $phpdigEncode[$encoding]['tr'] .= $chrs[0]; - } - } - foreach($phpdigEncode[$encoding]['ereg'] as $id => $ereg) { - $phpdigEncode[$encoding]['ereg'][$id] = '['.$ereg.']'; - } -} -} - -//================================================= -//epure a string from all non alnum words (words can contain &__&��� character) -function phpdigEpureText($text,$min_word_length=2,$encoding=PHPDIG_ENCODING) { -global $phpdig_words_chars; - -$text = phpdigStripAccents(strtolower ($text)); -//no-latin upper to lowercase - now islandic -switch (PHPDIG_ENCODING) { - case 'iso-8859-1': - $text = strtr( $text,'��','��'); - break; -} - -// RH ereg_replace('[^'.$phpdig_words_chars[$encoding].' \'._~@#$:&%/;,=-]+',' ',$text); -$text = ereg_replace('[^'.$phpdig_words_chars[$encoding].' \'._~@#$&%/=-]+',' ',$text); - -// RH ereg_replace('(['.$phpdig_words_chars[$encoding].'])[\'._~@#$:&%/;,=-]+($|[[:space:]]$|[[:space:]]['.$phpdig_words_chars[$encoding].'])','\1 \2',$text); -$text = ereg_replace('(['.$phpdig_words_chars[$encoding].'])[\'._~@#$&%/=-]+($|[[:space:]]$|[[:space:]]['.$phpdig_words_chars[$encoding].'])','\1 \2',$text); - -// the next two repeated lines needed -if ($min_word_length >= 1) { - $text = ereg_replace('[[:space:]][^ ]{1,'.$min_word_length.'}[[:space:]]',' ',' '.$text.' '); - $text = ereg_replace('[[:space:]][^ ]{1,'.$min_word_length.'}[[:space:]]',' ',' '.$text.' '); -} - -$text = ereg_replace('\.{2,}',' ',$text); -$text = ereg_replace('^[[:space:]]*\.+',' ',$text); - -return trim(ereg_replace("[[:space:]]+"," ",$text)); -} - -//-------------SQL FUNCTIONS - -//================================================= -//insert an entry in logs -function phpdigAddLog ($id_connect,$option='start',$includes=array(),$excludes=array(),$num_results=0,$time=0) { - if (!is_array($excludes)) { - $excludes = array(); - } - sort($excludes); - if (!is_array($includes)) { - $includes = array(); - } - sort($includes); - $now = api_get_utc_datetime(); - $query = 'INSERT INTO '.PHPDIG_DB_PREFIX.'logs (l_num,l_mode,l_ts,l_includes,l_excludes,l_time) ' - .'VALUES ('.$num_results.',\''.substr($option,0,1).'\',"' . $now . '",' - .'\''.implode(' ',$includes).'\',\''.implode(' ',$excludes).'\','.(double)$time.')'; - mysql_query($query,$id_connect); - return mysql_insert_id($id_connect); -} - -?> diff --git a/main/metadata/phpdig/search.php b/main/metadata/phpdig/search.php deleted file mode 100755 index 50b4623b24..0000000000 --- a/main/metadata/phpdig/search.php +++ /dev/null @@ -1,295 +0,0 @@ -'string', - 'mdsc'=>'string', 'kwdswere_string'=>'string', // Dokeos - 'refine'=>'integer', - 'refine_url'=>'string', - 'site'=>'string', // set to integer later - 'limite'=>'integer', - 'option'=>'string', - 'lim_start'=>'integer', - 'browse'=>'integer', - 'path'=>'string' - ) - ),EXTR_SKIP); - - $adlog_flag = 0; - $rssdf = ""; -// end of part copied (with some changes) from standard PhpDig search.php - - -// Course keywords - -$_course = api_get_course_info(); $ckw = $_course['path'] . '/CourseKwds.js'; -define('KEYWORDS_CACHE', api_get_path(SYS_COURSE_PATH) . $ckw); - -if (file_exists(KEYWORDS_CACHE)) $kcdt = - htmlspecialchars(date('Y/m/d H:i:s', filemtime(KEYWORDS_CACHE))); - -$keywordscache = $kcdt ? - '' . - '
    (CourseKwds cache: ' . $kcdt . ')' : ''; - - -// Dokeos header - -$nameTools = get_lang('Search'); -$htmlHeadXtra[] = ''; -$htmlHeadXtra[] = ''; -$htmlHeadXtra[] = ' - '; - -Display::display_header($nameTools); echo "\n"; - -echo '', - '

    ', get_lang('Search'), '

    '; - - -// Store new extra criteria (course manager only, see below), or execute -// PhpDig Search and echo result message + table with results + pages bar - -if (!$query_string) $query_string = trim($mdsc); - -$ckwcdt = file_exists($ckwc = KEYWORDS_CACHE . 'c') ? - date('Y/m/d H:i:s', filemtime($ckwc)) : '?'; $pkwc = ''; - -if (substr($query_string, 0, 2) == '<>' && api_is_allowed_to_edit()) -{ - if ($ckwcdt{0} != '?') - { - $fckwc = fopen($ckwc, 'rb'); $pkwc = fread($fckwc, filesize($ckwc)); - fclose($fckwc); unset($fckwc); - } - - if(($fckwc = fopen($ckwc, 'wb'))) - { - fwrite($fckwc, $query_string); fclose($fckwc); unset($fckwc); - $ckwcdt = file_exists($ckwc) ? - date('Y/m/d H:i:s', filemtime($ckwc)) : '? Write Error'; - } - else $ckwcdt = '? Open Error'; - - $phpdigSearchResults = array('result_message' => $ckw . 'c: ' . $ckwcdt, - 'pages_bar' => '', 'results' => array()); -} -else -{ - $phpdigSearchResults = phpdigSearch($id_connect, $query_string, $option, - $refine, $refine_url, $lim_start, $limite, $browse, $site, $path, - $relative_script_path, $template, $adlog_flag, $rssdf, $template_demo); -} - -$result_message = ''; $hits = 11; - -if ($result_message = $phpdigSearchResults['result_message']) - if (($cspos = strpos($result_message, ', ')) !== FALSE) - if (($sppos = strpos($result_message, ' ', $cspos += 2)) !== FALSE) - if (is_numeric($total = substr($result_message, $cspos, $sppos-$cspos))) - $hits = (int) $total; - -if (!($pages_bar = $phpdigSearchResults['pages_bar'])) $hits = 0; - -if ($result_message == phpdigMsg('noresults')) $result_message .= ' '.phpdigMsg('on').' "'.htmlspecialchars($query_string,ENT_QUOTES).'"'; - -echo $result_message, '

    ', "\n"; - -if ($phpdigSearchResults['results']) foreach ($phpdigSearchResults['results'] as $searchResult) -{ - $url = $searchResult['complete_path']; - - if (ereg("/[^?/]*\\?.*thumb=", $url)) - { - // direct URL: $thumburl = ereg_replace("/[^?/]*\\?.*thumb=", "/", $url); - $thumburl = ereg_replace("\\?.*thumb=", "?th=", $url); // via index.php - } - else - { - $thumburl = "tpl_img/link.gif"; - } - - echo '', "\n"; -} - -echo '
    ', $searchResult['link_title'], - '
    ', $searchResult['text'], '

    '; - -if ($result_message && ($hits > 10)) - echo "Results page ", str_replace('?template_demo=', - '?kwdswere_string=' . urlencode($kwdswere_string), $pages_bar), '

    '; - -/* Extra criteria: A course manager can define and edit them in the TEXTAREA. - If he types in something as in the example below, and clicks 'Go', the new - criteria are stored and the old ones are displayed. So it is easy to - restore the old ones. To confirm the new ones, empty the TEXTAREA. - -<>This selection empties extra criteria -Label -Descriptive text - -*/ - -$tdhtm = ''; - -function tdhtm($xc) -{ - $eol = '
    '; if ($xc{0} == '<') $xc = substr($xc, 1); - - if (($eov = strpos($xc, '>')) === FALSE) - $value = $label = $xc; - else - { - $value = substr($xc, 0, $eov); $label = substr($xc, $eov+1); - - if (($eot = strpos($label, '<')) !== FALSE) - { - $eol = substr($label, $eot); $label = substr($label, 0, $eot); - } - } - - return '' . - htmlspecialchars($label) . '' . $eol; -} - -if ($ckwcdt{0} != '?') // there is a file with extra criteria -{ - $fckwc = fopen($ckwc, 'rb'); - foreach (explode("\n", fread($fckwc, filesize($ckwc))) as $xc) - $tdhtm .= "\n" . tdhtm($xc); - fclose($fckwc); unset($fckwc); -} - -// Search criteria form and keywords tree -?> - -
    - - - -
    - - - - - - -
    - - ', htmlspecialchars($pkwc), ''; - else echo ''; - ?> - - - -
    - - - -
    - -
    -
    - -
    -   - Keywords-restrictive search
    - - - -   -
    - -
    - -
    - -
    - - diff --git a/main/metadata/phpdig/search_function.php b/main/metadata/phpdig/search_function.php deleted file mode 100755 index 43f9540ae5..0000000000 --- a/main/metadata/phpdig/search_function.php +++ /dev/null @@ -1,785 +0,0 @@ -start('All'); - -// init variables -global $phpdig_words_chars,$maxweight; -settype($maxweight,'integer'); -$ignore = ''; -$ignore_common = ''; -$ignore_message = ''; -$ignore_commess = ''; -$wheresite = ''; -$wherepath = ''; -$table_results = ''; -$final_result = ''; -$search_time = 0; -$strings = ''; -$num_tot = 0; -$leven_final = ""; -$exclude = array(); -$nav_bar = ''; -$pages_bar = ''; - -$mtime = explode(' ',microtime()); -$start_time = $mtime[0]+$mtime[1]; - -$timer->start('All backend'); -$timer->start('parsing strings'); - -if (!$option) { - $option = SEARCH_DEFAULT_MODE; -} -if (!in_array($option,array('start','any','exact'))) { - return 0; -} -// the query was filled -if ($query_string) { - -$common_words = phpdigComWords("$relative_script_path/includes/common_words.txt"); - -$like_start = array( "start" => "", // is empty - "any" => "", // was a percent - "exact" => "" // is empty - ); -$like_end = array( "start" => "%", // is a percent - "any" => "%", // is a percent - "exact" => "%" // was empty - ); -$like_operator = array( "start" => "like", // is a like - "any" => "like", // is a like - "exact" => "like" // was an = - ); - -if ($refine) { - $wheresite = "AND spider.site_id = $site "; - if (($path) && (strlen($path) > 0)) { - $wherepath = "AND spider.path like '$my_path' "; - } - $refine_url = "&refine=1&site=$site&path=".urlencode($path); -} -else { - $refine_url = ""; -} - -settype ($lim_start,"integer"); -if ($lim_start < 0) { - $lim_start = 0; -} - -$n_words = count(explode(" ",$query_string)); - -$ncrit = 0; -$tin = "0"; - -if (!get_magic_quotes_gpc()) { - $query_to_parse = addslashes($query_string); -} -else { - $query_to_parse = $query_string; -} -$my_query_string_link = stripslashes($query_to_parse); - -$query_to_parse = str_replace('_','\_',$query_to_parse); // avoid '_' in the query -$query_to_parse = str_replace('%','\%',$query_to_parse); // avoid '%' in the query -$query_to_parse = str_replace('\"',' ',$query_to_parse); // avoid '"' in the query - -$query_to_parse = phpdigStripAccents(strtolower($query_to_parse)); //made all lowercase - -// RH query_chars = "[^".$phpdig_words_chars[PHPDIG_ENCODING]." \'.\_~@#$:&\%/;,=-]+"; // epure chars \'._~@#$:&%/;,=- -$what_query_chars = "[^".$phpdig_words_chars[PHPDIG_ENCODING]." \'._~@#$&%/=-]+"; // epure chars \'._~@#$&%/=- - -if (eregi($what_query_chars,$query_to_parse)) { - $query_to_parse = eregi_replace($what_query_chars," ",$query_to_parse); -} - -$query_to_parse = ereg_replace('(['.$phpdig_words_chars[PHPDIG_ENCODING].'])[\'.\_~@#$:&\%/;,=-]+($|[[:space:]]$|[[:space:]]['.$phpdig_words_chars[PHPDIG_ENCODING].'])','\1 \2',$query_to_parse); - -$query_to_parse = trim(ereg_replace(" +"," ",$query_to_parse)); // no more than 1 blank - -$query_for_strings = $query_to_parse; -$query_for_phrase = $query_to_parse; -$test_short = $query_to_parse; -$query_to_parse2 = explode(" ",$query_to_parse); -usort($query_to_parse2, "phpdigByLength"); -$query_to_parse = implode(" ",$query_to_parse2); -if (isset($query_to_parse2)) { unset($query_to_parse2); } - -if (SMALL_WORDS_SIZE >= 1) { -$ignore_short_flag = 0; -$test_short_counter = 0; -$test_short2 = explode(" ",$test_short); -for ($i=0; $i 0)) { - $test_short2[$i].=" "; - $test_short_counter++; - $test_short3[] = $test_short2[$i]; - } -} -$test_short = implode(" ",$test_short3); -if (isset($test_short2)) { unset($test_short2); } -if (isset($test_short3)) { unset($test_short3); } - - $regs = array(); // for use with ereg() - while (ereg('( [^ ]{1,'.SMALL_WORDS_SIZE.'} )|( [^ ]{1,'.SMALL_WORDS_SIZE.'})$|^([^ ]{1,'.SMALL_WORDS_SIZE.'} )',$test_short,$regs)) { - for ($n=1; $n<=3; $n++) { - if (($regs[$n]) || ($regs[$n] == 0)) { - $ignore_short_flag++; - if (!eregi("\"".trim(stripslashes($regs[$n]))."\", ",$ignore)) { - $ignore .= "\"".trim(stripslashes($regs[$n]))."\", "; - } - $test_short = trim(str_replace($regs[$n],"",$test_short)); - } - } - } - if (strlen($test_short) <= SMALL_WORDS_SIZE) { - if (!eregi("\"".$test_short."\", ",$ignore)) { - $ignore_short_flag++; - $ignore .= "\"".stripslashes($test_short)."\", "; - } - $test_short = trim(str_replace($test_short,"",$test_short)); - } -} - -$ignore = str_replace("\"\", ","",$ignore); - -if ($option != "exact") { - if (($ignore) && ($ignore_short_flag > 1) && ($test_short_counter > 1)) { - $ignore_message = $ignore.' '.phpdigMsg('w_short_plur'); - } - elseif ($ignore) { - $ignore_message = $ignore.' '.phpdigMsg('w_short_sing'); - } -} - -$ignore_common_flag = 0; -while (ereg("(-)?([^ ]{".(SMALL_WORDS_SIZE+1).",}).*",$query_for_strings,$regs)) { - $query_for_strings = trim(str_replace($regs[2],"",$query_for_strings)); - if (!isset($common_words[stripslashes($regs[2])])) { - if ($regs[1] == '-') { - $exclude[$ncrit] = $regs[2]; - $query_for_phrase = trim(str_replace("-".$regs[2],"",$query_for_phrase)); - } - else { - $strings[$ncrit] = $regs[2]; - } - $kconds[$ncrit] = ''; - if ($option != 'any') { - $kconds[$ncrit] .= " AND k.twoletters = '".addslashes(substr(str_replace('\\','',$regs[2]),0,2))."' "; - } - $kconds[$ncrit] .= " AND k.keyword ".$like_operator[$option]." '".$like_start[$option].$regs[2].$like_end[$option]."' "; - $ncrit++; - } - else { - $ignore_common_flag++; - $ignore_common .= "\"".stripslashes($regs[2])."\", "; - } -} - -if ($option != "exact") { - if (($ignore_common) && ($ignore_common_flag > 1)) { - $ignore_commess = $ignore_common.' '.phpdigMsg('w_common_plur'); - } - elseif ($ignore_common) { - $ignore_commess = $ignore_common.' '.phpdigMsg('w_common_sing'); - } -} - -$timer->stop('parsing strings'); - -if ($ncrit && is_array($strings)) { - $query = "SET OPTION SQL_BIG_SELECTS = 1"; - mysql_query($query,$id_connect); - - $my_spider2site_array = array(); - $my_sitecount_array = array(); - - for ($n = 0; $n < $ncrit; $n++) { - $timer->start('spider queries'); - - $query = "SELECT spider.spider_id,sum(weight) as weight, spider.site_id - FROM ".PHPDIG_DB_PREFIX."keywords as k,".PHPDIG_DB_PREFIX."engine as engine, ".PHPDIG_DB_PREFIX."spider as spider - WHERE engine.key_id = k.key_id - ".$kconds[$n]." - AND engine.spider_id = spider.spider_id $wheresite $wherepath - GROUP BY spider.spider_id,spider.site_id "; - - $result = mysql_query($query,$id_connect); - $num_res_temp = mysql_num_rows($result); - - $timer->stop('spider queries'); - $timer->start('spider fills'); - - if ($num_res_temp > 0) { - if (!isset($exclude[$n])) { - $num_res[$n] = $num_res_temp; - while (list($spider_id,$weight,$site_id) = mysql_fetch_array($result)) { - $s_weight[$n][$spider_id] = $weight; - $my_spider2site_array[$spider_id] = $site_id; - $my_sitecount_array[$site_id] = 0; - } - } - else { - $num_exclude[$n] = $num_res_temp; - while (list($spider_id,$weight) = mysql_fetch_array($result)) { - $s_exclude[$n][$spider_id] = 1; - } - mysql_free_result($result); - } - } - elseif (!isset($exclude[$n])) { - $num_res[$n] = 0; - $s_weight[$n][0] = 0; - } - $timer->stop('spider fills'); - } - - $timer->start('reorder results'); - - if ($option != "any") { - if (is_array($num_res)) { - asort ($num_res); - list($id_most) = each($num_res); - reset ($s_weight[$id_most]); - while (list($spider_id,$weight) = each($s_weight[$id_most])) { - $weight_tot = 1; - reset ($num_res); - while(list($n) = each($num_res)) { - settype($s_weight[$n][$spider_id],'integer'); - $weight_tot *= sqrt($s_weight[$n][$spider_id]); - } - if ($weight_tot > 0) { - $final_result[$spider_id]=$weight_tot; - } - } - } - } - else { - if (is_array($num_res)) { - asort ($num_res); - while (list($spider_id,$site_id) = each($my_spider2site_array)) { - $weight_tot = 0; - reset ($num_res); - while(list($n) = each($num_res)) { - settype($s_weight[$n][$spider_id],'integer'); - $weight_tot += sqrt($s_weight[$n][$spider_id]); - } - if ($weight_tot > 0) { - $final_result[$spider_id]=$weight_tot; - } - } - } - } - - if (isset($num_exclude) && is_array($num_exclude)) { - while (list($id) = each($num_exclude)) { - while(list($spider_id) = each($s_exclude[$id])) { - if (isset($final_result[$spider_id])) { unset($final_result[$spider_id]); } - } - } - } - - if ($option == "exact") { - if ((is_array($final_result)) && (count($final_result) > 0)) { - $exact_phrase_flag = 0; - arsort($final_result); - reset($final_result); - $query_for_phrase_array = explode(" ",$query_for_phrase); - $reg_strings = str_replace('@#@',' ',phpdigPregQuotes(str_replace('\\','',implode('@#@',$query_for_phrase_array)))); - $stop_regs = "[][(){}[:blank:]=&?!&#%\$�*@+%:;,/\.'\"]"; - $reg_strings = "($stop_regs{1}|^)($reg_strings)($stop_regs{1}|\$)"; - while (list($spider_id,$weight) = each($final_result)) { - $content_file = $relative_script_path.'/'.TEXT_CONTENT_PATH.$spider_id.'.txt'; - if (is_file($content_file)) { - $f_handler = fopen($content_file,'r'); - $extract_content = preg_replace("/([ ]{2,}|\n|\r|\r\n)/"," ",fread($f_handler,filesize($content_file))); - if(!eregi($reg_strings,$extract_content)) { - $exact_phrase_flag = 1; - } - fclose($f_handler); - } - if ($exact_phrase_flag == 1) { - if (isset($final_result[$spider_id])) { unset($final_result[$spider_id]); } - $exact_phrase_flag = 0; - } - } - } - } - - if((!$refine) && (NUMBER_OF_RESULTS_PER_SITE != -1)) { - if ((is_array($final_result)) && (count($final_result) > 0)) { - arsort($final_result); - reset($final_result); - while (list($spider_id,$weight) = each($final_result)) { - $site_id = $my_spider2site_array[$spider_id]; - $current_site_counter = $my_sitecount_array[$site_id]; - if ($current_site_counter < NUMBER_OF_RESULTS_PER_SITE) { - $my_sitecount_array[$site_id]++; - } - else { - if (isset($final_result[$spider_id])) { unset($final_result[$spider_id]); } - } - } - } - } - - $timer->stop('reorder results'); -} - -$timer->stop('All backend'); -$timer->start('All display'); - -if ((is_array($final_result)) && (count($final_result) > 0)) { - arsort($final_result); - $lim_start = max(0, $lim_start-($lim_start % $limite)); - $n_start = $lim_start+1; - $num_tot = count($final_result); - - if ($n_start+$limite-1 < $num_tot) { - $n_end = ($lim_start+$limite); - $more_results = 1; - } - else { - $n_end = $num_tot; - $more_results = 0; - } - - if ($n_start > $n_end) { - $n_start = 1; - $n_end = min($num_tot,$limite); - $lim_start = 0; - if ($n_end < $num_tot) { - $more_results = 1; - } - } - - // ereg for text snippets and highlighting - if ($option == "exact") { - $reg_strings = str_replace('@#@',' ',phpdigPregQuotes(str_replace('\\','',implode('@#@',$query_for_phrase_array)))); - } - else { - $reg_strings = str_replace('@#@','|',phpdigPregQuotes(str_replace('\\','',implode('@#@',$strings)))); - } - $stop_regs = "[][(){}[:blank:]=&?!&#%\$�*@+%:;,/\.'\"]"; - - switch($option) { - case 'any': - $reg_strings = "($stop_regs{1}|^)($reg_strings)()"; - break; - case 'exact': - $reg_strings = "($stop_regs{1}|^)($reg_strings)($stop_regs{1}|\$)"; - break; - default: - $reg_strings = "($stop_regs{1}|^)($reg_strings)()"; - } - - $timer->start('Result table'); - - //fill the results table - reset($final_result); - for ($n = 1; $n <= $n_end; $n++) { - list($spider_id,$s_weight) = each($final_result); - if (!$maxweight) { - $maxweight = $s_weight; - } - if ($n >= $n_start) { - $timer->start('Display queries'); - - $query = "SELECT sites.site_url, sites.port, spider.path,spider.file,spider.first_words,sites.site_id,spider.spider_id,spider.last_modified,spider.md5 " - ."FROM ".PHPDIG_DB_PREFIX."spider AS spider, ".PHPDIG_DB_PREFIX."sites AS sites " - ."WHERE spider.spider_id=$spider_id AND sites.site_id = spider.site_id"; - $result = mysql_query($query,$id_connect); - $content = mysql_fetch_array($result,MYSQL_ASSOC); - mysql_free_result($result); - if ($content['port']) { - $content['site_url'] = ereg_replace('/$',':'.$content['port'].'/',$content['site_url']); - } - $weight = sprintf ("%01.2f", (100*$s_weight)/$maxweight); - $url = eregi_replace("([".$phpdig_words_chars[PHPDIG_ENCODING]."])[/]{2,}","\\1/",urldecode($content['site_url'].$content['path'].$content['file'])); - - $js_url = urlencode(eregi_replace("^[a-z]{3,5}://","",$url)); - - $url = str_replace("\"","%22",str_replace("'","%27",str_replace(" ","%20",trim($url)))); - - $l_site = "".htmlspecialchars(urldecode($content['site_url']),ENT_QUOTES).""; - if ($content['path']) { - $content['path'] = urlencode(urldecode($content['path'])); - $content2['path'] = htmlspecialchars(urldecode($content['path']),ENT_QUOTES); - $l_path = ", ".phpdigMsg('this_path')." : ".$content2['path'].""; - } - else { - $content2['path'] = ""; - $l_path=""; - } - - $first_words = ereg_replace('txt-sep +txt-end', 'txt-end', ereg_replace('txt-sep +txt-sep', 'txt-sep', $content['first_words'])); // RH was just: $content['first_words']; - $first_words = str_replace('-kw ', ' ', str_replace('txt-end', "\n", str_replace('txt-sep', '
    ', $first_words))); // RH this line added - - $timer->stop('Display queries'); - $timer->start('Extracts'); - - $extract = ""; - //Try to retrieve matching lines if the content-text is set to 1 - if (CONTENT_TEXT == 1 && DISPLAY_SNIPPETS) { - $content_file = $relative_script_path.'/'.TEXT_CONTENT_PATH.$content['spider_id'].'.txt'; - if (is_file($content_file)) { - $num_extracts = 0; - $my_extract_size = 200; - - $my_filesize_for_while = filesize($content_file); - while (($num_extracts == 0) && ($my_extract_size <= $my_filesize_for_while)) { // *** - - $f_handler = fopen($content_file,'r'); - while($num_extracts < DISPLAY_SNIPPETS_NUM && $extract_content = preg_replace("/([ ]{2,}|\n|\r|\r\n)/"," ",fread($f_handler,$my_extract_size))) { - if(eregi($reg_strings,$extract_content)) { - $match_this_spot = eregi_replace($reg_strings,"\\1<\\2>\\3",$extract_content); - $first_bold_spot = strpos($match_this_spot,"<"); - $first_bold_spot = max($first_bold_spot - round((SNIPPET_DISPLAY_LENGTH / 2),0), 0); - $extract_content = substr($extract_content,$first_bold_spot,max(SNIPPET_DISPLAY_LENGTH, 2 * strlen($query_string))); - $extract .= ' ...'.phpdigHighlight($reg_strings,$extract_content).'... '; - $num_extracts++; - } - } - fclose($f_handler); - - if ($my_extract_size < $my_filesize_for_while) { - $my_extract_size *= 100; - if ($my_extract_size > $my_filesize_for_while) { - $my_extract_size = $my_filesize_for_while; - } - } - else { - $my_extract_size++; - } - - } // ends *** - } - } - - list($title,$text) = explode("\n",$first_words); - - $title = htmlspecialchars(phpdigHighlight($reg_strings,urldecode($title)),ENT_QUOTES); - $title = phpdigSpanReplace($title); - - $timer->stop('Extracts'); - - $table_results[$n] = array ( - 'weight' => $weight, - 'img_tag' => '', - 'page_link' => "".$title."", - 'limit_links' => phpdigMsg('limit_to')." ".$l_site.$l_path, - 'filesize' => sprintf('%.1f',(ereg_replace('.*_([0-9]+)$','\1',$content['md5']))/1024), - 'update_date' => ereg_replace('^([0-9]{4})([0-9]{2})([0-9]{2}).*',PHPDIG_DATE_FORMAT,$content['last_modified']), - 'complete_path' => $url, - 'link_title' => $title - ); - - $table_results[$n]['text'] = ''; - if (DISPLAY_SUMMARY) { - $table_results[$n]['text'] = htmlspecialchars(phpdigHighlight($reg_strings,preg_replace("/([ ]{2,}|\n|\r|\r\n)/"," ",ereg_replace('(@@@.*)','',wordwrap($text, SUMMARY_DISPLAY_LENGTH, '@@@')))),ENT_QUOTES); - $table_results[$n]['text'] = phpdigSpanReplace($table_results[$n]['text']); - } - if (DISPLAY_SUMMARY && DISPLAY_SNIPPETS) { - $table_results[$n]['text'] .= "\n

    \n"; - } - if (DISPLAY_SNIPPETS) { - if ($extract) { - $extract = htmlspecialchars($extract,ENT_QUOTES); - $extract = phpdigSpanReplace($extract); - $table_results[$n]['text'] .= $extract; - } - else if (!$table_results[$n]['text']){ - $table_results[$n]['text'] = htmlspecialchars(phpdigHighlight($reg_strings,preg_replace("/([ ]{2,}|\n|\r|\r\n)/"," ",ereg_replace('(@@@.*)','',wordwrap($text, SUMMARY_DISPLAY_LENGTH, '@@@')))),ENT_QUOTES); - $table_results[$n]['text'] = phpdigSpanReplace($table_results[$n]['text']); - } - } - } - } - - $timer->stop('Result table'); - $timer->start('Final strings'); - - $url_bar = SEARCH_PAGE."?template_demo=$template_demo&browse=1&query_string=".urlencode($my_query_string_link)."$refine_url&limite=$limite&option=$option&lim_start="; - - if ($lim_start > 0) { - $previous_link = $url_bar.($lim_start-$limite); - $nav_bar .= "<<".phpdigMsg('previous')."    \n"; - } - $tot_pages = ceil($num_tot/$limite); - $actual_page = $lim_start/$limite + 1; - $page_inf = max(1,$actual_page - 5); - $page_sup = min($tot_pages,max($actual_page+5,10)); - for ($page = $page_inf; $page <= $page_sup; $page++) { - if ($page == $actual_page) { - $nav_bar .= " $page \n"; - $pages_bar .= " $page \n"; - $link_actual = $url_bar.(($page-1)*$limite); - } - else { - $nav_bar .= " $page \n"; - $pages_bar .= " $page \n"; - } - } - - if ($more_results == 1) { - $next_link = $url_bar.($lim_start+$limite); - $nav_bar .= "    ".phpdigMsg('next').">>\n"; - } - - $mtime = explode(' ',microtime()); - $search_time = sprintf('%01.2f',$mtime[0]+$mtime[1]-$start_time); - $result_message = stripslashes(ucfirst(phpdigMsg('results'))." $n_start-$n_end, $num_tot ".phpdigMsg('total').", ".phpdigMsg('on')." \"".htmlspecialchars($query_string,ENT_QUOTES)."\" ($search_time ".phpdigMsg('seconds').")"); - - $timer->stop('Final strings'); -} -else { - if (is_array($strings)) { - $strings = array_values($strings); - $num_in_strings_arr = count($strings); - } - else { $num_in_strings_arr = 0; } - $leven_final = ""; - $leven_sum = 0; - if (($num_in_strings_arr > 0) && (strlen($path) == 0)) { - for ($i=0; $i<$num_in_strings_arr; $i++) { - $soundex_query = "SELECT keyword FROM ".PHPDIG_DB_PREFIX."keywords WHERE SOUNDEX(CONCAT('Q',keyword)) = SOUNDEX(CONCAT('Q','".$strings[$i]."')) LIMIT 500"; - $soundex_results = mysql_query($soundex_query,$id_connect); - if (mysql_num_rows($soundex_results) > 0) { - $leven_ind = 0; - $leven_amt1 = 256; - $leven_keyword = array(); - while (list($soundex_keyword) = mysql_fetch_array($soundex_results)) { - $leven_amt2 = min(levenshtein(stripslashes($strings[$i]),$soundex_keyword),$leven_amt1); - if (($leven_amt2 < $leven_amt1) && ($leven_amt2 >= 0) && ($leven_amt2 <= 5)) { - $leven_keyword[$leven_ind] = stripslashes($soundex_keyword); - $leven_ind++; - } - $leven_amt1 = $leven_amt2; - } - $leven_count = count($leven_keyword); - $leven_sum = $leven_sum + $leven_amt1; - if ($leven_count > 0) { - $leven_final .= $leven_keyword[$leven_count-1] . " "; - } - if (isset($leven_keyword)) { unset($leven_keyword); } - } - } - } - $num_tot = 0; - $result_message = phpdigMsg('noresults'); - if ((strlen(trim($leven_final)) > 0) && ($leven_sum > 0)) { - $leven_query = trim($leven_final); - $result_message .= ". " . phpdigMsg('alt_try') ." ".htmlspecialchars($leven_query,ENT_QUOTES)."?"; - } -} - -if (isset($tempresult)) { - mysql_free_result($tempresult); -} - -$title_message = phpdigMsg('s_results'); -} -else { - $title_message = 'PhpDig '.PHPDIG_VERSION; - $result_message = phpdigMsg('no_query').'.'; -} - -$timer->start('Logs'); -if (PHPDIG_LOGS && !$browse && !$refine && $adlog_flag == 0) { - if (is_array($final_result)) { - phpdigAddLog ($id_connect,$option,$strings,$exclude,count($final_result),$search_time); - } - else { - phpdigAddLog ($id_connect,$option,$strings,$exclude,0,$search_time); - } -} -$timer->stop('Logs'); - -$timer->start('Template parsing'); - -$powered_by_link = ""; -if (ALLOW_RSS_FEED) { - $powered_by_link .= "".phpdigMsg('viewRSS')."
    "; -} -$powered_by_link .= "".phpdigMsg('powered_by')."
    "; - -if (is_array($strings)) { - $js_string = implode(" ",$strings); -} else { - $js_string = ""; -} -$js_for_clicks = " - -"; - -if ($template == 'array' || is_file($template)) { - $phpdig_version = PHPDIG_VERSION; - $t_mstrings = compact('js_for_clicks','powered_by_link','title_message','phpdig_version','result_message','nav_bar','ignore_message','ignore_commess','pages_bar','previous_link','next_link'); - $t_fstrings = phpdigMakeForm($query_string,$option,$limite,SEARCH_PAGE,$site,$path,'template',$template_demo,$num_tot,$refine); - if ($template == 'array') { - return array_merge($t_mstrings,$t_fstrings,array('results'=>$table_results)); - } - else { - $t_strings = array_merge($t_mstrings,$t_fstrings); - phpdigParseTemplate($template,$t_strings,$table_results); - } -} -else { -?> - - -<?php print $title_message ?> - - - - - -
    -phpdig <?php print PHPDIG_VERSION ?> -
    - -

    -
    -
    -

    -
    -\n"; - print "$n. [".$t_result['weight']." %]  ".$t_result['page_link']."\n
    \n"; - print "".$t_result['limit_links']."\n
    \n"; - print "

    \n"; - print "
    \n"; - print $t_result['text']; - print "
    \n"; - } -} -print "

    \n"; -print $nav_bar; -print "

    \n"; -?> -
    -
    - -
    -
    -Powered by PhpDig   -
    - - -stop('Template parsing'); -$timer->stop('All display'); -$timer->stop('All'); -//$timer->display(); -} - -function phpdigSpanReplace($text) { -$text = str_replace("<br>","
    ",$text); // RH -$text = str_replace("</span>","",$text); -$text = str_replace("<span class="phpdigHighlight">","",$text); -return $text; -} - -function phpdigByLength($a, $b) { -$len_a = strlen($a); -$len_b = strlen($b); -if ($len_a == $len_b) { return 0; } -return ($len_a < $len_b) ? 1 : -1; -} -?> diff --git a/main/metadata/phpdig/update_db_to_1_8_6_from_1_8_3.sql b/main/metadata/phpdig/update_db_to_1_8_6_from_1_8_3.sql deleted file mode 100755 index ee6c2ba7cd..0000000000 --- a/main/metadata/phpdig/update_db_to_1_8_6_from_1_8_3.sql +++ /dev/null @@ -1,35 +0,0 @@ -# Update from the 1.8.3 version to the 1.8.6 version -# Add the table prefix if needed -# --------------------------------- -ALTER TABLE sites ADD COLUMN stopped TINYINT(1) NOT NULL DEFAULT 0; -ALTER TABLE site_page ADD COLUMN days INT(4) NOT NULL DEFAULT 0; -ALTER TABLE site_page ADD COLUMN depth INT(4) NOT NULL DEFAULT 5; -ALTER TABLE site_page CHANGE num_page links INT(4) NOT NULL DEFAULT 5; -DROP TABLE sites_days_upd; -ALTER TABLE spider CHANGE first_words first_words mediumtext NOT NULL; -ALTER TABLE excludes DROP INDEX ex_id; -ALTER TABLE includes DROP INDEX in_id; -ALTER TABLE keywords DROP INDEX key_id; -ALTER TABLE logs DROP INDEX l_id; -ALTER TABLE sites DROP INDEX site_id; -ALTER TABLE spider DROP INDEX spider_id; -ALTER TABLE tempspider DROP INDEX id; - -# Upgrading PhpDig from 1.8.3 to 1.8.6 for VELODLA: -# -# - save a copy of includes/connect.php, config.php -# - make the VELODLA/183phpdig directory inaccessible -# -# - restore the 1.8.6 backup to new directory VELODLA/phpdig-1.8.6 -# - replace phpdig-1.8.6/sql/update_db.sql by this file -# - run VELODLA/phpdig-1.8.6/admin/install.php, select "Update existing database", -# (provide the parameters from the old connect.php) -# - adapt config.php (cfr. old config.php) -# -# - re-apply customizations: search.php, cprgo.gif, simpleplus.html -# function_phpdig_form.php, phpdig_functions.php, search_function.php -# -# - edit md_phpdig.php, line 37 -# - edit VELODLA homepage links (PhpDig admin, Search with PhpDig) - -# - change Metadata_for_Dokeos.html diff --git a/main/metadata/playscormmdset.inc.php b/main/metadata/playscormmdset.inc.php deleted file mode 100755 index 497e6e8841..0000000000 --- a/main/metadata/playscormmdset.inc.php +++ /dev/null @@ -1,215 +0,0 @@ - - -if (!isset($scormid)) exit(); - -define('EID_TYPE', 'Scorm'); -define('BID', EID_TYPE . '.' . $scormid); -getpar('SID', 'Scorm sub-id', '*'); -define('EID_ID', (SID == '*') ? $scormid : $scormid . '.' . SID); -define('EID', EID_TYPE . '.' . EID_ID); -getpar('LFN', 'LanguageFileName', 'md_' . strtolower(EID_TYPE)); -getpar('HTT', 'HTML Template Text filename', 'mdp_' . strtolower(EID_TYPE)); -getpar('WHF', 'With Header and Footer', '0'); -define('DBG', 0); // for template debug info, set to e.g. 10000 -getpar('RNG', 'Slide range', '*'); - -if (RNG == '*' || ($dotdot = strpos(RNG, '..')) === FALSE) - $id_range_first = $id_range_last = ''; -else -{ - $id_range_first = trim(substr(RNG, 0, $dotdot)); - $id_range_last = trim(substr(RNG, $dotdot + 2)); -} - -$urlp = '?dbg=' . urlencode(DBG); -if (LFN != 'md_' . strtolower(EID_TYPE)) $urlp .= '&lfn=' . urlencode(LFN); -if (HTT != 'mdp_' . strtolower(EID_TYPE)) $urlp .= '&lfn=' . urlencode(HTT); -if (WHF != '0') $urlp .= '&whf=' . urlencode(WHF); -if (RNG != '*') $urlp .= '&rng=' . urlencode(RNG); - -// name of the language file that needs to be included -$language_file = LFN; -require('../inc/global.inc.php'); -$nameTools = get_lang('Tool'); - -require(api_get_path(SYS_CODE_PATH) . 'metadata/md_funcs.php'); - -($nameTools && get_lang('Sorry')) - or give_up('Language file ' . LFN . " doesn't define 'Tool' and 'Sorry'"); - -$_course = api_get_course_info(); isset($_course) or give_up(get_lang('Sorry')); - -require(api_get_path(LIBRARY_PATH) . 'xmd.lib.php'); -require(api_get_path(LIBRARY_PATH) . 'xht.lib.php'); - -require(api_get_path(SYS_CODE_PATH) . 'metadata/md_' . strtolower(EID_TYPE) . '.php'); -$mdObj = new mdobject($_course, EID_ID); - -define('DR', $_SERVER['DOCUMENT_ROOT']); -define('SELF', api_get_self()); -define('DIRECTORY', DR . $self = substr(SELF, 0, strrpos(SELF, '/'))); -if (!file_exists(DIRECTORY)) give_up('No such directory: ' . DIRECTORY); - - -// TEMPLATES FILE -------------------------------------------------------------> - -$topdir = strtolower(realpath(DR)); // to stop search for .htt file - -if (strpos(strtolower(realpath(DIRECTORY)), $topdir) !== 0) - give_up('Invalid directory: ' . DIRECTORY); - -chdir(DIRECTORY); - -for ($i = 0; $i < 10; $i++) - if(!file_exists(HTT . '.htt')) - if (strtolower(realpath(getcwd())) == $topdir) {break;} - else chdir('..'); - - -// XML and DB STUFF -----------------------------------------------------------> - -$is_allowed_to_edit = isset($_user['user_id']) && $is_courseMember && api_is_allowed_to_edit(); - -$mdStore = new mdstore($is_allowed_to_edit); - -if (($mdt_rec = $mdStore->mds_get(EID)) === FALSE) // no record, default XML - $mdt = $mdObj->mdo_generate_default_xml_metadata(); -else $mdt = $mdt_rec; - -$xhtxmldoc = new xmddoc(explode("\n", $mdt)); - -(!$xhtxmldoc->error) or give_up($xhtxmldoc->error); - -if (SID == $id_range_first && - ($prv = $xhtxmldoc->xmd_select_single_element('previous')) != -1) - $xhtxmldoc->xmd_remove_element($prv); - -if (SID == $id_range_last && - ($nxt = $xhtxmldoc->xmd_select_single_element('next')) != -1) - $xhtxmldoc->xmd_remove_element($nxt); - -$before_first = $id_range_first ? TRUE : FALSE; $after_last = FALSE; - -foreach ($xhtxmldoc->xmd_select_elements('child') as $chEl) -{ - $chId = $xhtxmldoc->attributes[$chEl]['identifier']; // no get_att yet... - - if ($after_last || - ($before_first = $before_first && $chId != $id_range_first)) - { - $xhtxmldoc->xmd_remove_element($chEl); continue; - } - - if (($mdt_rec = $mdStore->mds_get(BID . '.' . $chId)) === FALSE) - $mdt = $mdObj->mdo_generate_default_xml_metadata(); - else $mdt = $mdt_rec; - - $xhtxmldocchild = new xmddoc(explode("\n", $mdt)); - - (!$xhtxmldocchild->error) or give_up($chId . ': ' . $xhtxmldocchild->error); - - // make stuff below a parameter? copy some already in importmanifest? - $xhtxmldoc->xmd_copy_foreign_child($xhtxmldocchild, - $xhtxmldocchild->xmd_select_single_element('title'), $chEl); - $xhtxmldoc->xmd_copy_foreign_child($xhtxmldocchild, - $xhtxmldocchild->xmd_select_single_element('resource'), $chEl); - - $after_last = $after_last || $chId == $id_range_last; -} - -$xhtDoc = define_htt(HTT . '.htt', $urlp, $_course['path']); -$xhtDoc->xht_xmldoc = $xhtxmldoc; - -$xhtDoc->xht_param['mdt'] = $xhtxmldoc->xmd_xml(); - - -// GENERATE OUTPUT ------------------------------------------------------------> - -foreach (explode("\n", $xhtDoc->htt_array['HTTP']) as $httpXtra) - if ($httpXtra) $httpHeadXtra[] = $httpXtra; - -$xhtDoc->xht_get_lang = 'get_lang'; - -function resource_for($e) {return $e;} // dummy, '=/' not used here -$xhtDoc->xht_resource = 'resource_for'; - -$htmlHeadXtra[] = $xhtDoc->xht_fill_template('HEAD'); - -// $mdObj->mdo_add_breadcrump_nav(); // see 'md_' . EID_TYPE . '.php' -$noPHP_SELF = TRUE; // in breadcrumps - -if (WHF != '0') Display::display_header($nameTools); -else -{ - header('Content-Type: text/html; charset='. $charset); $document_language = 'en'; - if ( isset($httpHeadXtra) && $httpHeadXtra ) - { - foreach($httpHeadXtra as $thisHttpHead) - { - header($thisHttpHead); - } - } - ?> - - - - Scorm package - - - - - - - - -
    - xht_dbgn = DBG; // for template debug info, set to e.g. 10000 -if (($ti = $xhtDoc->xht_param['traceinfo'])) $xhtDoc->xht_param['traceinfo'] = - '
    Trace information
    ' . htmlspecialchars($ti, ENT_QUOTES, $charset); - -echo $xhtDoc->xht_fill_template('METADATA'), "\n"; - -if ($xhtDoc->xht_dbgn) echo $xhtDoc->xht_dbgo; - -if (WHF != '0') -{ - Display::display_footer(); - exit; -} - -?> -
     
    -
    - - diff --git a/main/metadata/search.php b/main/metadata/search.php deleted file mode 100755 index c8416eb1f6..0000000000 --- a/main/metadata/search.php +++ /dev/null @@ -1,149 +0,0 @@ - -require("md_funcs.php"); -getpar('TYPE', 'e.g. Mix', 'Mix'); // note: only 'Mix' is currently working -require('md_' . strtolower(TYPE) . '.php'); -getpar('LFN', 'LanguageFileName', 'md_' . strtolower(TYPE)); -getpar('HTT', 'HTML Template Text filename', 'mds_' . strtolower(TYPE)); -getpar('DBG', 'Debug number', '0'); // set to e.g. 10000 for debuginfo -$urlp = '?type='. urlencode(TYPE); -if (LFN != 'md_' . strtolower(TYPE)) $urlp .= '&lfn=' . urlencode(LFN); -if (HTT != 'mds_' . strtolower(TYPE)) $urlp .= '&htt=' . urlencode(HTT); -if (DBG) $urlp .= '&dbg=' . urlencode(DBG); - -// name of the language file that needs to be included -$language_file = LFN; require("../inc/global.inc.php"); -$this_section=SECTION_COURSES; - -$nameTools = get_lang('Tool'); - -($nameTools && get_lang('Sorry')) - or give_up('Language file ' . LFN . " doesn't define 'Tool' and 'Sorry'"); - -$_course = api_get_course_info(); isset($_course) or give_up(get_lang('Sorry')); - -require(api_get_path(LIBRARY_PATH) . 'xmd.lib.php'); -require(api_get_path(LIBRARY_PATH) . 'xht.lib.php'); - -$xhtDoc = define_htt(HTT . '.htt', $urlp, $_course['path']); - -$xhtDoc->xht_param['type'] = TYPE; - -$xhtDoc->xht_param['index'] = - str_replace('/search.php', '/index.php', api_get_self()); - - -// XML and DB STUFF -----------------------------------------------------------> - -$mdStore = new mdstore(FALSE); // no create DB table from search - -$xhtDoc->xht_get_lang = 'get_lang'; $xhtDoc->xht_xmldoc = new xmddoc(''); -if ($xhtDoc->xht_xmldoc->error) give_up($xhtDoc->xht_xmldoc->error); - -($mdt = $xhtDoc->xht_fill_template('DEFAULT'.TYPE)) - or give_up('No template DEFAULT' . TYPE); - -$xhtDoc->xht_xmldoc = new xmddoc(explode("\n", $mdt)); -if ($xhtDoc->xht_xmldoc->error) give_up($xhtDoc->xht_xmldoc->error); - -$xmlDoc = new xmddoc(''); if ($xmlDoc->error) give_up($xmlDoc->error); - -if (isset($_POST['mdsc'])) // Search criteria -{ - $mdsc = str_replace("\r", "\n", str_replace("\r\n", "\n", - get_magic_quotes_gpc() ? stripslashes($_POST['mdsc']) : $_POST['mdsc'])); - - foreach (explode("\n", $mdsc) as $word) if (($word = trim($word))) - { - $words .= ", " . $word; - - $where .= " AND indexabletext " . ($word{0} != '-' ? - ("LIKE '%".addslashes($word)."%'") : - ("NOT LIKE '%".addslashes(substr($word, 1))."%'")); - } - - if ($where) - { - $whereclause = substr($where, 5); // remove first " AND " - - $xhtDoc->xht_xmldoc->xmd_add_text_element('query', $whereclause); - $xhtDoc->xht_param['traceinfo'] = substr($words, 2); - - $result = $mdStore->mds_get_many('eid,mdxmltext', $whereclause); - - while (($myrow = @Database::fetch_array($result))) - { - // not quite a real manifest, but very much like one... - - $eid = $myrow['eid']; $xmlDoc = new xmddoc($myrow['mdxmltext']); - if ($xmlDoc->error) give_up('Entry '.$eid . ': ' . $xmlDoc->error); - - $mdObj = new mdobject($_course, $eid); // md_mix.php - - $xhtDoc->xht_xmldoc->xmd_copy_foreign_child($xmlDoc); - $newItem = $xhtDoc->xht_xmldoc-> - xmd_select_single_element('item[-1]'); - $xhtDoc->xht_xmldoc->xmd_set_attribute($newItem, 'eid', $eid); - $xhtDoc->xht_xmldoc->xmd_set_attribute($newItem, 'url', - $mdObj->mdo_url); - - if ($mdObj->mdo_type == 'Scorm') - $xhtDoc->xht_xmldoc->xmd_set_attribute($newItem, 'brl', - $mdObj->mdo_base_url); - } - } -} - - -function check_is_thumb($p) // escape function, see mds_mix.htt -{ - global $xhtDoc; if ($p !== FALSE) return ''; // should not happen - - if (!ereg('^pptsl[0-9]+_t\.jpg$', $xhtDoc->xht_param['thumb'])) - $xhtDoc->xht_param['thumb'] = ''; - - return ''; -} - - -// GENERATE OUTPUT ------------------------------------------------------------> - -foreach (explode("\n", $xhtDoc->htt_array['HTTP']) as $httpXtra) - if ($httpXtra) $httpHeadXtra[] = $httpXtra; - -$xhtDoc->xht_get_lang = 'get_lang'; - -function resource_for($e) {return $e;} // dummy, '=/' not used here -$xhtDoc->xht_resource = 'resource_for'; - -$xhtDoc->xht_param['kwdswere_string'] = $_POST['kwdswere_string']; -$htmlHeadXtra[] = $xhtDoc->xht_fill_template('HEAD'); - -// $noPHP_SELF = TRUE; // in breadcrumps - -Display::display_header($nameTools); - -$xhtDoc->xht_dbgn = DBG; // for template debug info, set to e.g. 10000 -if (($ti = $xhtDoc->xht_param['traceinfo'])) $xhtDoc->xht_param['traceinfo'] = - '' . get_lang('Search') . ': ' . htmlspecialchars($ti, ENT_QUOTES, $charset); - -echo $xhtDoc->xht_fill_template('MDSEARCH'), "\n"; - -if ($xhtDoc->xht_dbgn) echo $xhtDoc->xht_dbgo; - -Display::display_footer(); -?> diff --git a/main/metadata/statistics.php b/main/metadata/statistics.php deleted file mode 100755 index f11b13f450..0000000000 --- a/main/metadata/statistics.php +++ /dev/null @@ -1,133 +0,0 @@ - - -require('md_funcs.php'); - -define('EID_TYPE', 'Mix'); -require('md_' . strtolower(EID_TYPE) . '.php'); - -include('../inc/global.inc.php'); -$this_section=SECTION_COURSES; - -$nameTools = get_lang('Tool'); - -($nameTools && get_lang('Sorry')) or give_up( - 'Language file ' . $language_file . " doesn't define 'Tool' and 'Sorry'"); - -$_course = api_get_course_info(); isset($_course) or give_up(get_lang('Sorry')); - -$is_allowed_to_edit = isset($_user['user_id']) && $is_courseMember && api_is_allowed_to_edit(); -if (!$is_allowed_to_edit) give_up(get_lang('Denied')); - -$mdStore = new mdstore(FALSE); // no create from statistics - -require(api_get_path(LIBRARY_PATH) . 'xmd.lib.php'); -require(api_get_path(LIBRARY_PATH) . 'xht.lib.php'); - -$htmldecode = array_flip(get_html_translation_table(HTML_SPECIALCHARS)); - - -// STATISTICS -----------------------------------------------------------------> - -$noPHP_SELF = TRUE; // in breadcrumps -Display::display_header($nameTools); - -echo '

    ', get_lang('Statistics'), '

    ', "\n"; - -$ckw = $_course['path'] . '/CourseKwds.js'; -define('KEYWORDS_CACHE', get_course_path() . $ckw); - -if (!file_exists(KEYWORDS_CACHE)) -{ - echo get_lang('NoKeywords'); - Display::display_footer(); - exit(); -} - -if (!($myFile = @fopen(KEYWORDS_CACHE, 'r'))) -{ - echo get_lang('KwCacheProblem'); - Display::display_footer(); - exit(); -} - -$kwds = array(); $kwcnt = array(); $kwrefs = array(); - -while (($kwline = fgets($myFile))) -{ - if (ereg('�>(.+)<�', $kwline, $regs) || ereg('">(.+)<�', $kwline, $regs)) - foreach (explode(',', $regs[1]) as $kw) - if (!in_array($kw = strtr(trim($kw), $htmldecode), $kwds)) - $kwds []= $kw; -} -fclose($myFile); - -$result = $mdStore->mds_get_many('eid,mdxmltext', '1 = 1'); -echo get_lang('TotalMDEs'), Database::num_rows($result), "
    \n"; - -echo count($kwds), ' ', get_lang('CourseKwds'), '
    ', "\n"; - -while ($row = Database::fetch_array($result)) -{ - $eid = $row['eid']; $curr = ''; $xmltext = $row['mdxmltext']; $offset = 0; - - if (substr($eid, 0, 6) == 'Scorm.') - if (($dotpos = strpos($eid, '.', 6)) && $dotpos + 1 < strlen($eid)) - $curr = substr($eid, 0, $dotpos); - - while (($start = strpos($xmltext, '', $offset))) - if (($start = strpos($xmltext, '">', $start + 9))) - { - if (($stop = strpos($xmltext, ' $start) - { - $kw = strtr(substr($xmltext, $start, $stop-$start), $htmldecode); - if (!in_array($kw, $kwds)) - { - if (!in_array($kw = '!' . $kw, $kwds)) $kwds []= $kw; - $kwrefs[$kw] .= ' ' . ($curr ? - (strpos($kwrefs[$kw], $curr) ? - substr($eid, $dotpos+1) : $eid) : $eid); - } - $kwcnt[$kw] ++; // = $kwcnt[$kw] ? $kwcnt[$kw] + 1 : 1; - $offset = $stop + 19; - } - else $offset = $start + 2; - // lecture - } - else $offset = $start + 9; - - // xmd would be nicer but this is faster... -} - -echo count($kwds), ' ', get_lang('KwdsInMD'), '
    '; sort($kwds); - -$total = 0; foreach ($kwcnt as $kw => $cnt) $total += $cnt; -echo $total, ' ', get_lang('KwdRefs'), "\n"; - -echo '

    ', get_lang('NonCourseKwds'), '

    ', "\n"; - -foreach ($kwds as $kw) - if ($kw{0} == '!') - echo '', htmlspecialchars(api_substr($kw, 1), ENT_QUOTES, $charset), ': ', $kwcnt[$kw], - ': ', htmlspecialchars($kwrefs[$kw], ENT_QUOTES, $charset), "; \n"; - else break; - -echo '

    ', get_lang('KwdsUse'), '

    ', "\n"; - -foreach ($kwds as $kw) - if ($kw{0} != '!') - if (!$kwcnt[$kw]) - echo '', htmlspecialchars($kw, ENT_QUOTES, $charset), "; \n"; - else echo htmlspecialchars($kw, ENT_QUOTES, $charset), ': ', $kwcnt[$kw], "; \n"; - -Display::display_footer(); -?> diff --git a/main/metadata/update_indexabletext.php b/main/metadata/update_indexabletext.php deleted file mode 100755 index 0a90243757..0000000000 --- a/main/metadata/update_indexabletext.php +++ /dev/null @@ -1,67 +0,0 @@ - - -require('md_funcs.php'); - -getpar('EID_TYPE', 'Entry Type'); // e.g. 'Document' or 'Scorm' -define('TPLEN', strlen(EID_TYPE) + 1); - -require('md_' . strtolower(EID_TYPE) . '.php'); - -include('../inc/global.inc.php'); -$this_section=SECTION_COURSES; - -$nameTools = get_lang('Tool'); - -($nameTools && get_lang('Sorry')) or give_up( - 'Language file ' . $language_file . " doesn't define 'Tool' and 'Sorry'"); - -$_course = api_get_course_info(); isset($_course) or give_up(get_lang('Sorry')); - -$is_allowed_to_edit = isset($_user['user_id']) && $is_courseMember && api_is_allowed_to_edit(); -if (!$is_allowed_to_edit) give_up(get_lang('Denied')); - -$mdStore = new mdstore($is_allowed_to_edit); // create table if needed -$mdObj = new mdobject($_course, 0); - -require(api_get_path(LIBRARY_PATH) . 'xmd.lib.php'); -require(api_get_path(LIBRARY_PATH) . 'xht.lib.php'); - -$xhtDoc = $mdObj->mdo_define_htt(); - -$mdObj->mdo_add_breadcrump_nav(); // see 'md_' . EID_TYPE . '.php' -Display::display_header($nameTools); - -// OPERATIONS -----------------------------------------------------------------> - -echo '

    ', htmlspecialchars(EID_TYPE, ENT_QUOTES, $charset), '

    ', "\n"; - -$result = $mdStore->mds_get_many('eid,mdxmltext', "eid LIKE '" . EID_TYPE . ".%'"); -echo get_lang('TotalMDEs'), $total = Database::num_rows($result), "

    \n"; - -if ($total > 100) set_time_limit((int) ($total / 10)); - -while ($row = Database::fetch_array($result)) -{ - $eid = $row['eid']; $xmltext = $row['mdxmltext']; - $xhtDoc->xht_xmldoc = new xmddoc(explode("\n", $xmltext)); - - $mdStore->mds_put($eid, - $xhtDoc->xht_fill_template('INDEXABLETEXT'), 'indexabletext'); - - echo htmlspecialchars($eid, ENT_QUOTES, $charset), ' '; -} - -echo '
    ', htmlspecialchars(EID_TYPE, ENT_QUOTES, $charset), '
    ', "\n"; - -Display::display_footer(); -?> diff --git a/main/mySpace/coaches.php b/main/mySpace/coaches.php index daffeabc71..321b2ab860 100755 --- a/main/mySpace/coaches.php +++ b/main/mySpace/coaches.php @@ -49,19 +49,32 @@ if (isset($_POST['export'])) { if (isset($_GET["id_student"])) { $id_student = intval($_GET["id_student"]); - $sql_coachs = "SELECT DISTINCT srcru.id_user as id_coach" . - "FROM $tbl_session_rel_course_rel_user as srcru " . - "WHERE srcru.id_user='$id_student' AND srcru.status=2"; + $sql_coachs = "SELECT DISTINCT srcru.user_id as id_coach + FROM $tbl_session_rel_course_rel_user as srcru + WHERE srcru.user_id='$id_student' AND srcru.status=2"; } else { if (api_is_platform_admin()) { - $sql_coachs = "SELECT DISTINCT srcru.id_user as id_coach, user_id, lastname, firstname + $sql_coachs = "SELECT DISTINCT + srcru.user_id as id_coach, user_id, lastname, firstname FROM $tbl_user, $tbl_session_rel_course_rel_user srcru - WHERE srcru.id_user=user_id AND srcru.status=2 ".$order_clause; + WHERE + srcru.user_id=user_id AND + srcru.status=2 ".$order_clause; } else { - $sql_coachs = "SELECT DISTINCT id_user as id_coach, $tbl_user.user_id, lastname, firstname - FROM $tbl_user as user, $tbl_session_rel_course_user as srcu, $tbl_course_user as course_rel_user - WHERE course_rel_user.course_code=srcu.course_code AND course_rel_user.status='1' AND course_rel_user.user_id='".intval($_SESSION["_uid"])."' - AND srcu.id_user=user.user_id AND srcu.status=2 ".$order_clause; + $sql_coachs = "SELECT DISTINCT user_id as id_coach, $tbl_user.user_id, lastname, firstname + FROM + $tbl_user as user, + $tbl_session_rel_course_user as srcu, + $tbl_course_user as course_rel_user, + $tbl_course as c + WHERE + c.id = course_rel_user.c_id AND + c.code = srcu.course_code AND + course_rel_user.status='1' AND + course_rel_user.user_id='".api_get_user_id()."' AND + srcu.user_id = user.user_id AND + srcu.status = 2 + ".$order_clause; } } diff --git a/main/mySpace/current_courses.php b/main/mySpace/current_courses.php index ed89a3f78d..fa177f6049 100755 --- a/main/mySpace/current_courses.php +++ b/main/mySpace/current_courses.php @@ -28,9 +28,9 @@ $session_id = 0; if (!empty($my_courses)) { foreach ($my_courses as $course) { - $course_code = $course['course_code']; - $course_id = $course['real_id']; - $course_info = api_get_course_info($course_code); + $course_code = $course['code']; + $course_id = $course['real_id']; + $course_info = api_get_course_info($course_code); //Only show open courses if ($course_info['visibility'] == 0) { diff --git a/main/mySpace/index.php b/main/mySpace/index.php index b0e323c3f7..7e39e1e8cd 100755 --- a/main/mySpace/index.php +++ b/main/mySpace/index.php @@ -397,7 +397,7 @@ if ($export_csv) { // Send the csv file if asked if ($export_csv) { ob_end_clean(); - Export :: export_table_csv($csv_content, 'reporting_index'); + Export :: arrayToCsv($csv_content, 'reporting_index'); exit; } diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index 6a577fd526..878965d3ca 100755 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -45,7 +45,7 @@ if (isset ($_GET['from']) && $_GET['from'] == 'myspace') { $nameTools = get_lang('StudentDetails'); -$get_course_code = Security :: remove_XSS($_GET['course']); +$get_course_code = isset($_GET['course']) ? Security :: remove_XSS($_GET['course']) : ''; if (isset($_GET['details'])) { if (!empty ($_GET['origin']) && $_GET['origin'] == 'user_course') { @@ -157,7 +157,7 @@ if (isset($_GET['user_id']) && $_GET['user_id'] != "") { $user_id = api_get_user_id(); } -$session_id = intval($_GET['id_session']); +$session_id = isset($_GET['id_session']) ? intval($_GET['id_session']) : 0; if (empty($session_id)) { $session_id = api_get_session_id(); } @@ -186,7 +186,8 @@ if ($check) { $session_id ); - //@todo delete the stats.track_e_exercises records. First implement this http://support.chamilo.org/issues/1334 + // @todo delete the stats.track_e_exercises records. + // First implement this http://support.chamilo.org/issues/1334 $message = Display::return_message( get_lang('LPWasReset'), 'success' @@ -237,7 +238,7 @@ if (!empty($sessions_coached_by_user)) { } } -$sql = "SELECT course_code +$sql = "SELECT c_id FROM $tbl_course_user WHERE relation_type <> ".COURSE_RELATION_TYPE_RRHH." AND @@ -246,30 +247,30 @@ $rs = Database::query($sql); while ($row = Database :: fetch_array($rs)) { if ($drh_can_access_all_courses) { - $courses_in_session[0][] = $row['course_code']; + $courses_in_session[0][] = $row['c_id']; } else { - if (isset($courses[$row['course_code']])) { - $courses_in_session[0][] = $row['course_code']; + if (isset($courses[$row['c_id']])) { + $courses_in_session[0][] = $row['c_id']; } } } // Get the list of sessions where the user is subscribed as student -$sql = 'SELECT id_session, course_code +$sql = 'SELECT session_id, c_id FROM '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).' - WHERE id_user=' . intval($user_info['user_id']); + WHERE user_id=' . intval($user_info['user_id']); $rs = Database::query($sql); $tmp_sessions = array(); while ($row = Database :: fetch_array($rs)) { - $tmp_sessions[] = $row['id_session']; + $tmp_sessions[] = $row['session_id']; if ($drh_can_access_all_courses) { - if (in_array($row['id_session'], $tmp_sessions)) { - $courses_in_session[$row['id_session']][] = $row['course_code']; + if (in_array($row['session_id'], $tmp_sessions)) { + $courses_in_session[$row['session_id']][] = $row['c_id']; } } else { - if (isset($courses_in_session_by_coach[$row['id_session']])) { - if (in_array($row['id_session'], $tmp_sessions)) { - $courses_in_session[$row['id_session']][] = $row['course_code']; + if (isset($courses_in_session_by_coach[$row['session_id']])) { + if (in_array($row['session_id'], $tmp_sessions)) { + $courses_in_session[$row['session_id']][] = $row['c_id']; } } } @@ -345,10 +346,12 @@ if (!empty($student_id)) { // get average of score and average of progress by student $avg_student_progress = $avg_student_score = 0; - $course_code = Security :: remove_XSS($_GET['course']); + $course_code = isset($_GET['course']) ? Security :: remove_XSS($_GET['course']) : ''; if (!CourseManager :: is_user_subscribed_in_course($user_info['user_id'], $course_code, true)) { - unset($courses[$key]); + if (isset($courses[$key])) { + unset($courses[$key]); + } } else { $avg_student_progress = Tracking::get_avg_student_progress( @@ -372,13 +375,16 @@ if (!empty($student_id)) { // time spent on the course $courseInfo = api_get_course_info($course_code); - $time_spent_on_the_course = api_time_to_hms( - Tracking:: get_time_spent_on_the_course( - $user_info['user_id'], - $courseInfo['real_id'], - $session_id - ) - ); + $time_spent_on_the_course = 0; + if (!empty($courseInfo)) { + $time_spent_on_the_course = api_time_to_hms( + Tracking:: get_time_spent_on_the_course( + $user_info['user_id'], + $courseInfo['real_id'], + $session_id + ) + ); + } // get information about connections on the platform by student $first_connection_date = Tracking :: get_first_connection_date($user_info['user_id']); @@ -436,7 +442,7 @@ if (!empty($student_id)) { if ($session_id > 0) { $session_info = api_get_session_info($session_id); - $course_coachs = api_get_coachs_from_course($session_id, $course_code); + $course_coachs = api_get_coachs_from_course($session_id, $info_course['real_id']); $nb_login = ''; if (!empty($course_coachs)) { $info_tutor_name = array(); @@ -622,9 +628,12 @@ if (!empty($student_id)) { $attendance = new Attendance(); foreach ($courses_in_session as $key => $courses) { - $session_id = $key; + $session_id = $key; $session_info = api_get_session_info($session_id); - $session_name = $session_info['name']; + $session_name = ''; + if ($session_info) { + $session_name = $session_info['name']; + } $date_start = ''; if (!empty($session_info['date_start']) && $session_info['date_start'] != '0000-00-00') { @@ -659,9 +668,10 @@ if (!empty($student_id)) { '; if (!empty($courses)) { - foreach ($courses as $course_code) { - $courseInfo = api_get_course_info($course_code); + foreach ($courses as $courseId) { + $courseInfo = api_get_course_info_by_id($courseId); $courseId = $courseInfo['real_id']; + $course_code = $courseInfo['code']; if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) { $course_info = CourseManager :: get_course_information($course_code); @@ -720,10 +730,12 @@ if (!empty($student_id)) { '.$attendances_faults_avg.' '.$scoretotal_display.''; - if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) { - echo ''; + if (isset($_GET['id_coach']) && intval($_GET['id_coach']) != 0) { + echo ' + '; } else { - echo ''; + echo ' + '; } echo ''; } @@ -1040,11 +1052,11 @@ if (!empty($student_id)) { //@when using sessions we do not show the survey list if (empty($session_id)) { - $survey_list = survey_manager::get_surveys($course_code, $session_id); + $survey_list = SurveyManager::get_surveys($course_code, $session_id); $survey_data = array(); foreach($survey_list as $survey) { - $user_list = survey_manager::get_people_who_filled_survey($survey['survey_id'], false, $info_course['real_id']); + $user_list = SurveyManager::get_people_who_filled_survey($survey['survey_id'], false, $info_course['real_id']); $survey_done = Display::return_icon("accept_na.png", get_lang('NoAnswer'), array(), ICON_SIZE_SMALL); if (in_array($student_id, $user_list)) { $survey_done = Display::return_icon("accept.png", get_lang('Answered'), array(), ICON_SIZE_SMALL); @@ -1157,7 +1169,7 @@ if (!empty($student_id)) { } if ($export_csv) { ob_end_clean(); - Export :: export_table_csv($csv_content, 'reporting_student'); + Export :: arrayToCsv($csv_content, 'reporting_student'); exit; } diff --git a/main/mySpace/reussite.php b/main/mySpace/reussite.php index 392a98f9cb..a930999bca 100755 --- a/main/mySpace/reussite.php +++ b/main/mySpace/reussite.php @@ -48,7 +48,7 @@ if (!empty($_GET['session'])) { FROM $tbl_course as course INNER JOIN $tbl_session_course AS rel_course ON course.code = rel_course.course_code - AND rel_course.id_session = ".$session['id']." + AND rel_course.session_id = ".$session['id']." ORDER BY title ASC"; $result_course = Database::query($sql_course); diff --git a/main/mySpace/student.php b/main/mySpace/student.php index 5661e207e1..408c00faa5 100755 --- a/main/mySpace/student.php +++ b/main/mySpace/student.php @@ -292,7 +292,7 @@ if ($export_csv) { } $csv_content = array_merge($csv_header, $content); ob_end_clean(); - Export :: export_table_csv($csv_content, 'reporting_student_list'); + Export :: arrayToCsv($csv_content, 'reporting_student_list'); exit; } else { Display::display_header($nameTools); diff --git a/main/mySpace/teachers.php b/main/mySpace/teachers.php index 9c83992fcd..b82ee6be22 100755 --- a/main/mySpace/teachers.php +++ b/main/mySpace/teachers.php @@ -260,7 +260,7 @@ if ($export_csv) { } $csv_content = array_merge($csv_header, $content); ob_end_clean(); - Export :: export_table_csv($csv_content, 'reporting_teacher_list'); + Export :: arrayToCsv($csv_content, 'reporting_teacher_list'); exit; } else { Display::display_header($nameTools); diff --git a/main/mySpace/user_add.php b/main/mySpace/user_add.php index a7ac5de175..a5c67e33bf 100755 --- a/main/mySpace/user_add.php +++ b/main/mySpace/user_add.php @@ -48,7 +48,6 @@ api_block_anonymous_users(); // Database table definitions $table_admin = Database :: get_main_table(TABLE_MAIN_ADMIN); $table_user = Database :: get_main_table(TABLE_MAIN_USER); -$database = Database::get_main_database(); $htmlHeadXtra[] = ' "; + $htmlHeadXtra[] = ""; } if ((!$is_allowed_to_edit) || ($isStudentView)) { //error_log('New LP - User not authorized in lp_add.php'); header('location:lp_controller.php?action=view&lp_id='.$learnpath_id); + exit; } // From here on, we are admin because of the previous condition, so don't check anymore. @@ -68,7 +69,7 @@ if ((!$is_allowed_to_edit) || ($isStudentView)) { - all the functions not available for students - always available in this case (page only shown to admin) */ if (isset($_SESSION['gradebook'])){ - $gradebook = $_SESSION['gradebook']; + $gradebook = $_SESSION['gradebook']; } if (!empty($gradebook) && $gradebook=='view') { @@ -83,7 +84,8 @@ $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => g Display::display_header(get_lang('LearnpathAddLearnpath'), 'Path'); echo ''; Display::display_normal_message(get_lang('AddLpIntro'), false); @@ -95,7 +97,7 @@ if ($_POST AND empty($_REQUEST['lp_name'])) { $form = new FormValidator('lp_add', 'post', 'lp_controller.php'); // Form title -$form->addElement('header', null, get_lang('AddLpToStart')); +$form->addElement('header', get_lang('AddLpToStart')); // Title $form->addElement('text', 'lp_name', api_ucfirst(get_lang('LPName')), array('autofocus' => 'autofocus')); @@ -124,8 +126,8 @@ $form->addElement('html','
    '); $defaults['activate_start_date_check'] = 1; -$defaults['publicated_on'] = date('Y-m-d 08:00:00'); -$defaults['expired_on'] = date('Y-m-d 08:00:00',time()+86400); +$defaults['publicated_on'] = date('Y-m-d 08:00:00'); +$defaults['expired_on'] = date('Y-m-d 08:00:00',time()+86400); $form->setDefaults($defaults); $form->addButtonCreate(get_lang('CreateLearningPath')); diff --git a/main/newscorm/lp_add_item.php b/main/newscorm/lp_add_item.php index d9be65a53d..e349e346dc 100755 --- a/main/newscorm/lp_add_item.php +++ b/main/newscorm/lp_add_item.php @@ -48,9 +48,6 @@ $(function() { load_cbo($(\'#idParent\').val()); } } - //Loads LP item tabs - - $("#resource_tab").tabs(); $(\'.lp_resource_element\').click(function() { window.location.href = $(\'a\', this).attr(\'href\'); }); @@ -99,14 +96,14 @@ $interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpa switch ($type) { case 'chapter': - $interbreadcrumb[]= array ('url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id(), 'name' => get_lang('NewStep')); - $interbreadcrumb[]= array ('url' => '#', 'name' => get_lang('NewChapter')); + $interbreadcrumb[]= array('url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id(), 'name' => get_lang('NewStep')); + $interbreadcrumb[]= array('url' => '#', 'name' => get_lang('NewChapter')); break; case 'document': - $interbreadcrumb[]= array ('url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id(), 'name' => get_lang('NewStep')); + $interbreadcrumb[]= array('url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id(), 'name' => get_lang('NewStep')); break; default: - $interbreadcrumb[]= array ('url' => '#', 'name' => get_lang('NewStep')); + $interbreadcrumb[]= array('url' => '#', 'name' => get_lang('NewStep')); break; } @@ -194,7 +191,6 @@ if (in_array($message, array('ItemUpdated'))) { } if (isset($new_item_id) && is_numeric($new_item_id)) { - switch ($type) { case 'chapter': echo $learnPath->display_manipulate($new_item_id, $_POST['type']); diff --git a/main/newscorm/lp_controller.php b/main/newscorm/lp_controller.php index 320d732a76..defea9baa2 100755 --- a/main/newscorm/lp_controller.php +++ b/main/newscorm/lp_controller.php @@ -298,6 +298,7 @@ if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $ $sel = "SELECT lp_type FROM $lp_table WHERE c_id = $course_id AND id = $lp_id"; if ($debug > 0) error_log('New LP - querying '.$sel, 0); $res = Database::query($sel); + if (Database::num_rows($res)) { $row = Database::fetch_array($res); $type = $row['lp_type']; @@ -497,16 +498,15 @@ switch ($action) { $_SESSION['post_time'] = $_REQUEST['post_time']; if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) { - $publicated_on = $_REQUEST['publicated_on']; + $publicated_on = $_REQUEST['publicated_on']; } else { $publicated_on = null; } if (isset($_REQUEST['activate_end_date_check']) && $_REQUEST['activate_end_date_check'] == 1) { - $expired_on = $_REQUEST['expired_on']; - $expired_on = $expired_on['Y'].'-'.$expired_on['F'].'-'.$expired_on['d'].' '.$expired_on['H'].':'.$expired_on['i'].':00'; + $expired_on = $_REQUEST['expired_on']; } else { - $expired_on = null; + $expired_on = null; } $new_lp_id = learnpath::add_lp( diff --git a/main/newscorm/lp_edit.php b/main/newscorm/lp_edit.php index 1c48a591e6..e6f457dc96 100755 --- a/main/newscorm/lp_edit.php +++ b/main/newscorm/lp_edit.php @@ -63,22 +63,6 @@ $form->addElement('text', 'lp_name', api_ucfirst(get_lang('LearnpathTitle')), ar $form->applyFilter('lp_name', 'html_filter'); $form->addRule('lp_name', get_lang('ThisFieldIsRequired'), 'required'); -// Metadata -//$clean_scorm_id=Security::remove_XSS($_GET['lp_id']); -//$metadata_link = ''.get_lang('AddMetadata').''; -//$form->addElement('static', null, get_lang('Metadata'), $metadata_link); - -// Encoding -/* // Chamilo 1.8.8: Deprecated code. -$encoding_select = $form->addElement('select', 'lp_encoding', get_lang('Charset')); -$encodings = array('UTF-8','ISO-8859-1','ISO-8859-15','cp1251','cp1252','KOI8-R','BIG5','GB2312','Shift_JIS','EUC-JP'); -foreach ($encodings as $encoding) { - if (api_equal_encodings($encoding, $_SESSION['oLP']->encoding)) { - $s_selected_encoding = $encoding; - } - $encoding_select->addOption($encoding,$encoding); -} -*/ $form->addElement('hidden', 'lp_encoding'); // Origin @@ -204,8 +188,7 @@ if ($enableLpExtraFields) { $extra = $extraField->addElements($form, $_SESSION['oLP']->get_id()); } -//Submit button -//$form->addElement('style_submit_button', 'Submit',get_lang('SaveLPSettings'),'class="save"'); +// Submit button $form->addButtonSave(get_lang('SaveLPSettings')); // Hidden fields diff --git a/main/newscorm/scorm.class.php b/main/newscorm/scorm.class.php index 8ca90fdc44..fa7d62bd5c 100755 --- a/main/newscorm/scorm.class.php +++ b/main/newscorm/scorm.class.php @@ -398,7 +398,7 @@ class scorm extends learnpath VALUES ($course_id, $lp_id, '$type', '$identifier', '$title', '$path' , 0, $max_score, $value_add $parent, $previous, 0, '$prereq', ".$item['rel_order'] .", '".$item['datafromlms']."', '".$item['parameters']."' )"; Database::query($sql); - if ($this->debug > 1) { error_log('New LP - In import_manifest(), inserting item : '.$sql.' : '.Database::error(), 0); } + if ($this->debug > 1) { error_log('New LP - In import_manifest(), inserting item : '.$sql, 0); } $item_id = Database::insert_id(); // Now update previous item to change next_item_id. $upd = "UPDATE $new_lp_item SET next_item_id = $item_id WHERE c_id = $course_id AND id = $previous"; diff --git a/main/newscorm/scormMetadata.class.php b/main/newscorm/scormMetadata.class.php index 3309e86e7e..969f4ee454 100755 --- a/main/newscorm/scormMetadata.class.php +++ b/main/newscorm/scormMetadata.class.php @@ -27,11 +27,10 @@ class scormMetadata * @param mixed Depending on the type, can be the DB ID of the learnpath item or the pointer to the element in the imsmanifest.xml file * @return boolean True on success, false on failure */ - public function __construct($type = 'manifest', &$element) { + public function __construct($type = 'manifest', &$element) + { if (isset($element)) { - // Parsing using PHP5 DOMXML methods. - switch ($type) { case 'db': // TODO: Implement this way of metadata object creation. diff --git a/main/notebook/index.php b/main/notebook/index.php index e595143b10..6b2b8398de 100755 --- a/main/notebook/index.php +++ b/main/notebook/index.php @@ -5,9 +5,6 @@ * @author Christian Fasanando, initial version * @author Patrick Cool , Ghent University, Belgium, refactoring and tighter integration */ -/** - * Code - */ // Including the global initialization file require_once '../inc/global.inc.php'; diff --git a/main/notebook/resources/js/proxy.js b/main/notebook/resources/js/proxy.js deleted file mode 100755 index ceff94b0ab..0000000000 --- a/main/notebook/resources/js/proxy.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Define a client proxy for ajax calls. - */ - - -function Proxy() {}; - -Proxy.prototype.root = function(){ - return context.ajax; -} - -Proxy.prototype.post = function(data, f){ - if(typeof(context)!=='undefined' && typeof(context.sec_token)!=='undefined'){ - data.sec_token = context.sec_token; - } - $.post(this.root(), data, f, 'json'); -} - - -var notebook = new Proxy(); - -notebook.remove = function(c_id, id, f) -{ - var data = { - c_id: c_id, - id: id, - action: 'remove' - }; - this.post(data, f); -}; - -notebook.remove_by_course = function(c_id, session_id, f) -{ - var data = { - c_id: c_id, - session_id: session_id, - action: 'remove_by_course' - }; - this.post(data, f); -}; diff --git a/main/notebook/resources/js/ui.js b/main/notebook/resources/js/ui.js deleted file mode 100755 index 69a61fbbd2..0000000000 --- a/main/notebook/resources/js/ui.js +++ /dev/null @@ -1,104 +0,0 @@ -/** - * User interface objects. - */ - -var message = {}; - -message.update = function(data){ - var text = typeof(data)=='string' ? data : data.message; - $('#messages').html(text); -} - -message.error = function(data){ - text = typeof(data)=='string' ? data : data.message; - if(! text){ - return; - } - $('#messages').html('
    ' + text + '
    '); -} - -message.info = function(data){ - text = typeof(data)=='string' ? data : data.message; - if(! text){ - return; - } - $('#messages').html('
    ' + text + '
    '); -} - -message.confirmation = function(data){ - text = typeof(data)=='string' ? data : data.message; - if(! text){ - return; - } - $('#messages').html('
    ' + text + '
    '); -} - -message.warning = function(data){ - text = typeof(data)=='string' ? data : data.message; - if(! text){ - return; - } - $('#messages').html('
    ' + text + '
    '); -} - - -var ui = {}; - -ui.message = message; - -ui.loading = function(btn){ - $(btn).addClass("loading"); -}; - -ui.done = function(btn){ - $(btn).removeClass("loading"); -}; - -ui.confirm = function(){ - if(!window.confirm(lang.ConfirmYourChoice)){ - return false; - } else { - return true; - } -}; - -ui.remove = function(name, btn){ - if(!this.confirm()){ - return false; - } - - var item = $('#'+name); - var id = item.attr('data-id'); - var c_id = item.attr('data-c_id'); - - var f = function(data){ - if(data.success){ - item.remove(); - } - message.update(data); - ui.done(btn); - }; - ui.loading(btn); - ui.proxy.remove(c_id, id, f); -}; - -ui.remove_by_course = function(name, btn){ - if(!this.confirm()){ - return false; - } - - var item = $('#'+name); - var c_id = item.attr('data-c_id'); - var session_id = item.attr('data-session_id'); - - var f = function(data){ - if(data.success){ - item.remove(); - } - message.update(data); - ui.done(btn); - }; - ui.loading(btn); - ui.proxy.remove_by_course(c_id, session_id, f); - -}; \ No newline at end of file diff --git a/main/permissions/blog_permissions.inc.php b/main/permissions/blog_permissions.inc.php index a311f32b6b..8a4ec5e48a 100755 --- a/main/permissions/blog_permissions.inc.php +++ b/main/permissions/blog_permissions.inc.php @@ -22,7 +22,9 @@ $course_id = api_get_course_int_id(); // Remove the blog creater because he has all the rights automatically // and we want to keep it that way. $tbl_course_rel_user = $table=Database::get_main_table(TABLE_MAIN_COURSE_USER); -$sql = "SELECT user_id FROM $tbl_course_rel_user WHERE status = '1' AND course_code = '".$_SESSION['_cid']."'"; +$sql = "SELECT user_id + FROM $tbl_course_rel_user + WHERE status = '1' AND c_id = '".api_get_course_int_id()."'"; $result = Database::query($sql); while ($user = Database::fetch_assoc($result)) { unset($blog_users[$user['user_id']]); @@ -170,4 +172,4 @@ echo "
    "; echo ''.get_lang('Legend').'
    '; echo ' '.get_lang('UserHasPermissionNot').'
    '; echo ' '.get_lang('UserHasPermission').'
    '; -echo ' '.get_lang('UserHasPermissionByRoleGroup').'
    '; \ No newline at end of file +echo ' '.get_lang('UserHasPermissionByRoleGroup').'
    '; diff --git a/main/reports/reports.cli.php b/main/reports/reports.cli.php index 8cbff96fd6..5ee9644d28 100755 --- a/main/reports/reports.cli.php +++ b/main/reports/reports.cli.php @@ -1,4 +1,6 @@ diff --git a/main/reports/reports.cron.php b/main/reports/reports.cron.php index 6c9a121cb2..8feb34e600 100755 --- a/main/reports/reports.cron.php +++ b/main/reports/reports.cron.php @@ -1,10 +1,8 @@ diff --git a/main/session/index.php b/main/session/index.php index 62ce60568c..540e492dc4 100755 --- a/main/session/index.php +++ b/main/session/index.php @@ -54,11 +54,16 @@ foreach ($new_session_list as $session_item) { $user_course_list[] = $session_item['code']; }*/ +$userIsGeneralCoach = SessionManager::user_is_general_coach($userId, $session_id); $user_course_list = array(); foreach ($course_list as $course) { - $status = SessionManager::get_user_status_in_course_session($userId, $course['code'], $session_id); - if ($status || api_is_platform_admin()) { + $status = SessionManager::get_user_status_in_course_session( + $userId, + $course['real_id'], + $session_id + ); + if ($status !== false || api_is_platform_admin() || $userIsGeneralCoach) { $user_course_list[] = $course['code']; } } @@ -562,9 +567,6 @@ $(function() { echo Display::grid_js('exercises', '', $column_exercise, $column_exercise_model, $extra_params_exercise, $my_real_array); } ?> - // Generate tabs with jquery-ui - $('#tabs').tabs(); - $( "#sub_tab" ).tabs(); }); diff --git a/main/social/group_invitation.php b/main/social/group_invitation.php index e2bbaac7a5..4d21ecaac2 100755 --- a/main/social/group_invitation.php +++ b/main/social/group_invitation.php @@ -79,7 +79,8 @@ function search_users($needle, $type) if (!empty($id_session)) { $group_id = intval($group_id); // check id_user from session_rel_user table - $sql = 'SELECT id_user FROM ' . $tbl_group_rel_user . ' WHERE group_id ="' . (int)$group_id . '"'; + $sql = 'SELECT user_id FROM ' . $tbl_group_rel_user . ' + WHERE group_id ="' . (int)$group_id . '"'; $res = Database::query($sql); $user_ids = array(); if (Database::num_rows($res) > 0) { @@ -88,25 +89,27 @@ function search_users($needle, $type) } } if (count($user_ids) > 0) { - $cond_user_id = ' AND user_id NOT IN(' . implode( - ",", - $user_ids - ) . ')'; + $cond_user_id = ' AND user_id NOT IN(' . implode(",", $user_ids ) . ')'; } } if ($type == 'single') { // search users where username or firstname or lastname begins likes $needle - $sql = 'SELECT user_id, username, lastname, firstname FROM ' . $tbl_user . ' user - WHERE (username LIKE "' . $needle . '%" - OR firstname LIKE "' . $needle . '%" - OR lastname LIKE "' . $needle . '%") AND user_id<>"' . $user_anonymous . '"' . - $order_clause . - ' LIMIT 11'; + $sql = 'SELECT user_id, username, lastname, firstname + FROM ' . $tbl_user . ' user + WHERE + ( + username LIKE "' . $needle . '%" OR + firstname LIKE "' . $needle . '%" OR + lastname LIKE "' . $needle . '%" + ) AND user_id <>"' . $user_anonymous . '"' . + $order_clause . + ' LIMIT 11'; } else { $sql = 'SELECT user_id, username, lastname, firstname FROM ' . $tbl_user . ' user - WHERE ' . (api_sort_by_first_name( - ) ? 'firstname' : 'lastname') . ' LIKE "' . $needle . '%" AND user_id<>"' . $user_anonymous . '"' . $cond_user_id . + WHERE + ' . (api_sort_by_first_name() ? 'firstname' : 'lastname') . ' LIKE "' . $needle . '%" AND + user_id<>"' . $user_anonymous . '"' . $cond_user_id . $order_clause; } @@ -117,20 +120,27 @@ function search_users($needle, $type) $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { if ($type == 'single') { - $sql = 'SELECT user.user_id, username, lastname, firstname FROM ' . $tbl_user . ' user - INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.user_id) - WHERE access_url_id = ' . $access_url_id . ' AND (username LIKE "' . $needle . '%" - OR firstname LIKE "' . $needle . '%" - OR lastname LIKE "' . $needle . '%") AND user.user_id<>"' . $user_anonymous . '"' . + $sql = 'SELECT user.user_id, username, lastname, firstname + FROM ' . $tbl_user . ' user + INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.user_id) + WHERE + access_url_id = ' . $access_url_id . ' AND + ( + username LIKE "' . $needle . '%" OR + firstname LIKE "' . $needle . '%" OR + lastname LIKE "' . $needle . '%" + ) AND user.user_id<>"' . $user_anonymous . '"' . $order_clause . ' LIMIT 11'; } else { - $sql = 'SELECT user.user_id, username, lastname, firstname FROM ' . $tbl_user . ' user - INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.user_id) - WHERE access_url_id = ' . $access_url_id . ' - AND ' . (api_sort_by_first_name( - ) ? 'firstname' : 'lastname') . ' LIKE "' . $needle . '%" AND user.user_id<>"' . $user_anonymous . '"' . $cond_user_id . - $order_clause; + $sql = 'SELECT user.user_id, username, lastname, firstname + FROM ' . $tbl_user . ' user + INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.user_id) + WHERE + access_url_id = ' . $access_url_id . ' AND + ' . (api_sort_by_first_name() ? 'firstname' : 'lastname') . ' LIKE "' . $needle . '%" AND + user.user_id<>"' . $user_anonymous . '"' . $cond_user_id . + $order_clause; } } } @@ -266,12 +276,13 @@ if ($ajax_search) { ); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { - $sql = "SELECT u.user_id, lastname, firstname, username, id_session + $sql = "SELECT u.user_id, lastname, firstname, username, session_id FROM $tbl_user u INNER JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id - AND $tbl_session_rel_user.id_session = " . intval($id_session) . " - INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id) + ON $tbl_session_rel_user.user_id = u.user_id + AND $tbl_session_rel_user.session_id = " . intval($id_session) . " + INNER JOIN $tbl_user_rel_access_url url_user + ON (url_user.user_id=u.user_id) WHERE access_url_id = $access_url_id $order_clause"; } diff --git a/main/social/search.php b/main/social/search.php index d9b510bd4d..42331d58f1 100755 --- a/main/social/search.php +++ b/main/social/search.php @@ -68,24 +68,25 @@ if ($query != '' || ($query_vars['search_type']=='1' && count($query_vars)>2) ) $social_right_content .= get_lang('SorryNoResults'); } - $results = '
    '; + $results = '
    '; if (is_array($users) && count($users) > 0) { $results .= Display::page_subheader(get_lang('Users')); - $results .= '
      '; + $results .= '
      '; + $buttonClass = 'btn btn-default btn-sm'; foreach ($users as $user) { - $send_inv = '

      '; + $send_inv = ''; $relation_type = intval(SocialManager::get_relation_between_contacts(api_get_user_id(), $user['user_id'])); $user_info = api_get_user_info($user['user_id'], true); - $url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$user['user_id']; + $url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$user['user_id']; // Show send invitation icon if they are not friends yet if ($relation_type != 3 && $relation_type != 4 && $user['user_id'] != api_get_user_id()) { - $send_inv = ' -

      '; + $send_inv = ' + '.get_lang('SendInvitation').''; } - $send_msg = ' - '; + $send_msg = ' + '.get_lang('SendMessage').''; if (empty($user['picture_uri'])) { $picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg'; $img = ''; @@ -109,25 +110,24 @@ if ($query != '' || ($query_vars['search_type']=='1' && count($query_vars)>2) ) $user_info['complete_name'] = Display::url($status_icon.$user_info['complete_name'], $url); $invitations = $user['tag'].$send_inv.$send_msg; - $results .= '
    • -
      -
      - '.$user_info['complete_name'].' -
      -
      -
      - '.$img.' -
      + $results .= '
      +
      + +
      + '.$img.'
      -
      -
      +
      + '.$user_info['complete_name'].' +
      '.$invitations.'
      -
    • '; +
      '; + + } - $results .= '
    '; + $results .= '
    '; $social_right_content .= $results; } diff --git a/main/survey/ch_yesno.php b/main/survey/ch_yesno.php index 69d21d71ce..889b50925b 100644 --- a/main/survey/ch_yesno.php +++ b/main/survey/ch_yesno.php @@ -83,13 +83,17 @@ class ch_yesno extends survey_question } else { $class = 'inline'; } - + $name = 'question' . $questionData['question_id']; $form->addRadio( - 'question' . $questionData['question_id'], + $name , null, $questionData['options'], array('label-class' => $class) ); + + if (!empty($answers)) { + $form->setDefaults([$name => current($answers)]); + } } } } diff --git a/main/survey/copy_survey.php b/main/survey/copy_survey.php index a3585ee72c..a7ba0a19aa 100644 --- a/main/survey/copy_survey.php +++ b/main/survey/copy_survey.php @@ -34,14 +34,14 @@ if (Security::check_token('post')) { Security::clear_token(); $surveyId = intval($_POST['surveys']); $courseId = Security::remove_XSS($_POST['destination_course']); - $surveyCopyId = survey_manager::copy_survey($surveyId, null, $courseId); + $surveyCopyId = SurveyManager::copy_survey($surveyId, null, $courseId); // Copy the survey to the target course - survey_manager::empty_survey($surveyCopyId, $courseId); + SurveyManager::empty_survey($surveyCopyId, $courseId); // Empty the copied survey Display::display_confirmation_message(get_lang('SurveyCopied')); } -$surveys = survey_manager::get_surveys(api_get_course_id(), api_get_session_id()); +$surveys = SurveyManager::get_surveys(api_get_course_id(), api_get_session_id()); $courses = CourseManager::get_courses_list(); $form = new FormValidator('copy_survey', 'post', 'copy_survey.php?'.api_get_cidreq()); if (!$surveys) { diff --git a/main/survey/create_new_survey.php b/main/survey/create_new_survey.php index 6997161864..4e426f3790 100755 --- a/main/survey/create_new_survey.php +++ b/main/survey/create_new_survey.php @@ -37,7 +37,7 @@ if (!api_is_allowed_to_edit()) { // Getting the survey information $survey_id = isset($_GET['survey_id']) ? intval($_GET['survey_id']) : null; -$survey_data = survey_manager::get_survey($survey_id); +$survey_data = SurveyManager::get_survey($survey_id); // Additional information $course_id = api_get_course_id(); @@ -91,7 +91,11 @@ if ($_GET['action'] == 'edit' && isset($survey_id) && is_numeric($survey_id)) { } // Initialize the object -$form = new FormValidator('survey', 'post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&survey_id='.$survey_id); +$form = new FormValidator( + 'survey', + 'post', + api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&survey_id='.$survey_id +); $form->addElement('header', '', $tool_name); @@ -229,15 +233,15 @@ if ($form->validate()) { // Exporting the values $values = $form->exportValues(); // Storing the survey - $return = survey_manager::store_survey($values); + $return = SurveyManager::store_survey($values); /* // Deleting the shared survey if the survey is getting unshared (this only happens when editing) if (is_numeric($survey_data['survey_share']) && $values['survey_share']['survey_share'] == 0 && $values['survey_id'] != '') { - survey_manager::delete_survey($survey_data['survey_share'], true); + SurveyManager::delete_survey($survey_data['survey_share'], true); } // Storing the already existing questions and options of a survey that gets shared (this only happens when editing) if ($survey_data['survey_share'] == 0 && $values['survey_share']['survey_share'] !== 0 && $values['survey_id'] != '') { - survey_manager::get_complete_survey_structure($return['id']); + SurveyManager::get_complete_survey_structure($return['id']); } */ if ($return['type'] == 'error') { diff --git a/main/survey/fillsurvey.php b/main/survey/fillsurvey.php index 6f501974fd..fbecf9dfd0 100755 --- a/main/survey/fillsurvey.php +++ b/main/survey/fillsurvey.php @@ -106,7 +106,7 @@ if ($invitationcode == 'auto' && isset($_GET['scode'])) { if (Database :: num_rows($result) > 0) { // Ok // Check availability $row = Database :: fetch_array($result, 'ASSOC'); - $tempdata = survey_manager :: get_survey($row['survey_id']); + $tempdata = SurveyManager :: get_survey($row['survey_id']); //exit if survey not available anymore check_time_availability($tempdata); // Check for double invitation records (insert should be done once) @@ -181,7 +181,7 @@ if (Database::num_rows($result) > 1) { } // Getting the survey information -$survey_data = survey_manager::get_survey($survey_invitation['survey_id']); +$survey_data = SurveyManager::get_survey($survey_invitation['survey_id']); $survey_data['survey_id'] = $survey_invitation['survey_id']; // Storing the answers @@ -552,7 +552,7 @@ if (isset($_POST['finish_survey'])) { Display::display_confirmation_message(get_lang('SurveyFinished')); echo $survey_data['survey_thanks']; - survey_manager::update_survey_answered( + SurveyManager::update_survey_answered( $survey_data, $survey_invitation['user'], $survey_invitation['survey_code'] @@ -1157,6 +1157,7 @@ if (isset($questions) && is_array($questions)) { foreach ($questions as $key => & $question) { $ch_type = 'ch_'.$question['type']; $display = new $ch_type; + // @todo move this in a function. $form->addHtml('
    '); $form->addHtml($question['survey_question']); $display->render($form, $question); diff --git a/main/survey/generate_link.php b/main/survey/generate_link.php index 7cde63fcaa..1be4139c19 100755 --- a/main/survey/generate_link.php +++ b/main/survey/generate_link.php @@ -12,18 +12,18 @@ if (empty($survey_id)) { api_not_allowed(true); } -$survey_data = survey_manager::get_survey($survey_id); +$survey_data = SurveyManager::get_survey($survey_id); $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', 'name' => get_lang('SurveyList')); $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id, 'name' => strip_tags($survey_data['title'])); Display::display_header(get_lang('Survey'), 'Survey'); -if (!survey_manager::survey_generation_hash_available()) { +if (!SurveyManager::survey_generation_hash_available()) { api_not_allowed(true); } -$link = survey_manager::generate_survey_link($survey_id, api_get_course_int_id(), api_get_session_id(), api_get_group_id()); +$link = SurveyManager::generate_survey_link($survey_id, api_get_course_int_id(), api_get_session_id(), api_get_group_id()); echo '
    '; echo '
    '; echo Display::url(get_lang('GenerateSurveyAccessLink'), $link, array('class' => 'btn btn-primary btn-large')); diff --git a/main/survey/link.php b/main/survey/link.php index 5563018f69..015c685feb 100755 --- a/main/survey/link.php +++ b/main/survey/link.php @@ -8,14 +8,14 @@ $survey_id = isset($_REQUEST['i']) ? intval($_REQUEST['i']) : null; if (empty($survey_id)) { api_not_allowed(true); } -if (!survey_manager::survey_generation_hash_available()) { +if (!SurveyManager::survey_generation_hash_available()) { api_not_allowed(true); } $course_info = api_get_course_info_by_id($_REQUEST['c']); -$hash_is_valid = survey_manager::validate_survey_hash($survey_id, $_REQUEST['c'], $_REQUEST['s'], $_REQUEST['g'], $_REQUEST['h']); +$hash_is_valid = SurveyManager::validate_survey_hash($survey_id, $_REQUEST['c'], $_REQUEST['s'], $_REQUEST['g'], $_REQUEST['h']); if ($hash_is_valid && $course_info) { - $survey_data = survey_manager::get_survey($survey_id, null, $course_info['code']); + $survey_data = SurveyManager::get_survey($survey_id, null, $course_info['code']); $invitation_code = api_get_unique_id(); diff --git a/main/survey/preview.php b/main/survey/preview.php index 2db0c72bb1..73ed91ba73 100755 --- a/main/survey/preview.php +++ b/main/survey/preview.php @@ -52,7 +52,7 @@ if (!isset($_GET['survey_id']) || !is_numeric($_GET['survey_id'])){ // Getting the survey information $survey_id = intval($_GET['survey_id']); -$survey_data = survey_manager::get_survey($survey_id); +$survey_data = SurveyManager::get_survey($survey_id); if (empty($survey_data)) { Display::display_header(get_lang('SurveyPreview')); @@ -68,7 +68,7 @@ if (api_is_allowed_to_edit()) { $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id, 'name' => $urlname); } $courseCode = isset($_GET['cidReq']) ? $_GET['cidReq'] : null; -$surveyAnonymous = survey_manager::get_survey($survey_id, 0, $courseCode); +$surveyAnonymous = SurveyManager::get_survey($survey_id, 0, $courseCode); $surveyAnonymous = $surveyAnonymous['anonymous']; if ($surveyAnonymous == 0 && api_is_anonymous()) { api_not_allowed(true); @@ -206,7 +206,6 @@ if (api_is_course_admin() || $url = api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show; $form = new FormValidator('question', 'post', $url); - if (is_array($questions) && count($questions) > 0) { foreach ($questions as $key => & $question) { $ch_type = 'ch_'.$question['type']; diff --git a/main/survey/question.php b/main/survey/question.php index 80d35ca9a8..5a6cfcc953 100755 --- a/main/survey/question.php +++ b/main/survey/question.php @@ -48,7 +48,7 @@ $table_user = Database:: get_main_table(TABLE_MAIN_USER); $course_id = api_get_course_int_id(); // Getting the survey information -$surveyData = survey_manager::get_survey($_GET['survey_id']); +$surveyData = SurveyManager::get_survey($_GET['survey_id']); if (empty($surveyData)) { Display :: display_header(get_lang('ToolSurvey')); @@ -146,7 +146,7 @@ if ($_GET['type'] == 'personality') { // We are editing a question if (isset($_GET['question_id']) && !empty($_GET['question_id'])) { - $formData = survey_manager::get_question($_GET['question_id']); + $formData = SurveyManager::get_question($_GET['question_id']); } $formData = $surveyQuestion->preSave($formData); diff --git a/main/survey/reporting.php b/main/survey/reporting.php index 9c6a6e635e..e060bac14d 100755 --- a/main/survey/reporting.php +++ b/main/survey/reporting.php @@ -9,13 +9,14 @@ * * @todo The question has to be more clearly indicated (same style as when filling the survey) */ + // Including the global initialization file require_once '../inc/global.inc.php'; $this_section = SECTION_COURSES; $cidReq = api_get_cidreq(); $survey_id = intval($_GET['survey_id']); -$survey_data = survey_manager::get_survey($survey_id); +$survey_data = SurveyManager::get_survey($survey_id); // Export /** @@ -66,7 +67,7 @@ if ($survey_data['anonymous'] == 0) { } else { $people_filled_full_data = false; } -$people_filled = survey_manager::get_people_who_filled_survey( +$people_filled = SurveyManager::get_people_who_filled_survey( $_GET['survey_id'], $people_filled_full_data ); @@ -74,12 +75,13 @@ $people_filled = survey_manager::get_people_who_filled_survey( // Checking the parameters SurveyUtil::check_parameters($people_filled); -$survey_data = survey_manager::get_survey($survey_id); +$survey_data = SurveyManager::get_survey($survey_id); $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh( api_get_user_id(), api_get_course_info() ); + /** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/ if (!api_is_allowed_to_edit(false, true) || $isDrhOfCourse) { Display :: display_header(get_lang('ToolSurvey')); @@ -99,7 +101,6 @@ $table_user = Database:: get_main_table(TABLE_MAIN_USER); // Getting the survey information -//$survey_data = survey_manager::get_survey($survey_id); if (empty($survey_data)) { Display :: display_header(get_lang('ToolSurvey')); Display :: display_error_message(get_lang('InvallidSurvey'), false); diff --git a/main/survey/survey.lib.php b/main/survey/survey.lib.php index 19e005e901..e3e356855e 100755 --- a/main/survey/survey.lib.php +++ b/main/survey/survey.lib.php @@ -2,7 +2,7 @@ /* For licensing terms, see /license.txt */ /** - * Class survey_manager + * Class SurveyManager * @package chamilo.survey * @author Patrick Cool , Ghent University: * cleanup, refactoring and rewriting large parts (if not all) of the code @@ -12,7 +12,7 @@ * @todo move this file to inc/lib * @todo use consistent naming for the functions (save vs store for instance) */ -class survey_manager +class SurveyManager { /** * @param $code @@ -339,12 +339,22 @@ class survey_manager Database::query($sql); $survey_id = Database::insert_id(); if ($survey_id > 0) { + + $sql = "UPDATE $table_survey SET survey_id = $survey_id WHERE iid = $survey_id"; + Database::query($sql); + // Insert into item_property - api_item_property_update(api_get_course_info(), TOOL_SURVEY, $survey_id, 'SurveyAdded', api_get_user_id()); + 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); + SurveyManager::copy_survey($values['parent_id'], $survey_id); } $return['message'] = 'SurveyCreatedSuccesfully'; @@ -464,6 +474,10 @@ class survey_manager '".$_course['id']."')"; Database::query($sql); $return = Database::insert_id(); + + $sql = "UPDATE $table_survey SET survey_id = $return WHERE iid = $return"; + Database::query($sql); + } else { $sql = "UPDATE $table_survey SET code = '".Database::escape_string($values['survey_code'])."', @@ -524,7 +538,7 @@ class survey_manager Database::query($sql); // Deleting the questions of the survey - survey_manager::delete_all_survey_questions($survey_id, $shared); + SurveyManager::delete_all_survey_questions($survey_id, $shared); // Update into item_property (delete) api_item_property_update($course_info, TOOL_SURVEY, $survey_id, 'SurveyDeleted', api_get_user_id()); @@ -568,8 +582,17 @@ class survey_manager Database::insert($table_survey, $params); $new_survey_id = Database::insert_id(); + $sql = "UPDATE $table_survey SET survey_id = $new_survey_id WHERE iid = $new_survey_id"; + Database::query($sql); + // Insert into item_property - api_item_property_update(api_get_course_info(), TOOL_SURVEY, $new_survey_id, 'SurveyAdded', api_get_user_id()); + api_item_property_update( + api_get_course_info(), + TOOL_SURVEY, + $new_survey_id, + 'SurveyAdded', + api_get_user_id() + ); } else { $new_survey_id = intval($new_survey_id); } @@ -586,6 +609,9 @@ class survey_manager ); $insertId = Database::insert($table_survey_question_group, $params); + $sql = "UPDATE $table_survey_question_group SET id = iid WHERE iid = $insertId"; + Database::query($sql); + $group_id[$row['id']] = $insertId; } @@ -609,6 +635,10 @@ class survey_manager 'survey_group_sec2' => $row['survey_group_sec2'] ); $insertId = Database::insert($table_survey_question, $params); + + $sql = "UPDATE $table_survey_question SET id = iid WHERE iid = $insertId"; + Database::query($sql); + $question_id[$row['question_id']] = $insertId; } @@ -626,7 +656,10 @@ class survey_manager 'sort' => $row['sort'], 'value' => $row['value'] ); - Database::insert($table_survey_options, $params); + $insertId = Database::insert($table_survey_options, $params); + + $sql = "UPDATE $table_survey_options SET question_option_id = $insertId WHERE iid = $insertId"; + Database::query($sql); } return $new_survey_id; @@ -651,7 +684,7 @@ class survey_manager $course_id = $courseId ? $courseId : api_get_course_int_id(); - $datas = survey_manager::get_survey($survey_id); + $datas = SurveyManager::get_survey($survey_id); $session_where = ''; if (api_get_session_id() != 0) { $session_where = ' AND session_id = "'.api_get_session_id().'" '; @@ -692,7 +725,7 @@ class survey_manager $session_id = $survey_data['session_id']; // Getting a list with all the people who have filled the survey - $people_filled = survey_manager::get_people_who_filled_survey($survey_id, false, $course_id); + $people_filled = SurveyManager::get_people_who_filled_survey($survey_id, false, $course_id); $number = intval(count($people_filled)); @@ -729,8 +762,8 @@ class survey_manager */ public static function get_complete_survey_structure($survey_id, $shared = 0) { - $structure = survey_manager::get_survey($survey_id, $shared); - $structure['questions'] = survey_manager::get_questions($survey_id); + $structure = SurveyManager::get_survey($survey_id, $shared); + $structure['questions'] = SurveyManager::get_questions($survey_id); } /*** @@ -946,11 +979,11 @@ class survey_manager $tbl_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); // Getting all the information of the survey - $survey_data = survey_manager::get_survey($form_content['survey_id']); + $survey_data = SurveyManager::get_survey($form_content['survey_id']); // Storing the question in the shared database if (is_numeric($survey_data['survey_share']) && $survey_data['survey_share'] != 0) { - $shared_question_id = survey_manager::save_shared_question($form_content, $survey_data); + $shared_question_id = SurveyManager::save_shared_question($form_content, $survey_data); $form_content['shared_question_id'] = $shared_question_id; } @@ -998,6 +1031,11 @@ class survey_manager )"; Database::query($sql); $question_id = Database::insert_id(); + + $sql = "UPDATE $tbl_survey_question SET question_id = $question_id + WHERE iid = $question_id"; + Database::query($sql); + $form_content['question_id'] = $question_id; $return_message = 'QuestionAdded'; @@ -1027,7 +1065,9 @@ class survey_manager display = '".Database::escape_string($form_content['horizontalvertical'])."', max_value = '".Database::escape_string($maxScore)."' $additionalsets - WHERE c_id = $course_id AND question_id = ".intval($form_content['question_id'])." + WHERE + c_id = $course_id AND + question_id = ".intval($form_content['question_id'])." "; Database::query($sql); $return_message = 'QuestionUpdated'; @@ -1045,7 +1085,7 @@ class survey_manager } // Storing the options of the question - survey_manager::save_question_options($form_content, $survey_data); + SurveyManager::save_question_options($form_content, $survey_data); } else { $return_message = 'PleasFillAllAnswer'; } @@ -1192,10 +1232,10 @@ class survey_manager Database::query($sql); // Deleting all the options of the questions of the survey - survey_manager::delete_all_survey_questions_options($survey_id, $shared); + SurveyManager::delete_all_survey_questions_options($survey_id, $shared); // Deleting all the answers on this survey - survey_manager::delete_all_survey_answers($survey_id); + SurveyManager::delete_all_survey_answers($survey_id); } /** @@ -1216,7 +1256,7 @@ class survey_manager // Table definitions $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); if ($shared) { - survey_manager::delete_shared_survey_question($survey_id, $question_id); + SurveyManager::delete_shared_survey_question($survey_id, $question_id); } // Deleting the survey questions @@ -1228,7 +1268,7 @@ class survey_manager Database::query($sql); // Deleting the options of the question of the survey - survey_manager::delete_survey_question_option($survey_id, $question_id, $shared); + SurveyManager::delete_survey_question_option($survey_id, $question_id, $shared); } /** @@ -1249,7 +1289,7 @@ class survey_manager $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION); // First we have to get the shared_question_id - $question_data = survey_manager::get_question($question_id); + $question_data = SurveyManager::get_question($question_id); // Deleting the survey questions $sql = "DELETE FROM $table_survey_question @@ -1282,11 +1322,11 @@ class survey_manager } if (is_numeric($survey_data['survey_share']) && $survey_data['survey_share'] != 0) { - survey_manager::save_shared_question_options($form_content, $survey_data); + SurveyManager::save_shared_question_options($form_content, $survey_data); } // Table definition - $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); + $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); // We are editing a question so we first have to remove all the existing options from the database if (is_numeric($form_content['question_id'])) { @@ -1308,6 +1348,14 @@ class survey_manager '".Database::escape_string($values)."', '".Database::escape_string($counter)."')"; Database::query($sql); + + $insertId = Database::insert_id(); + + $sql = "UPDATE $table_survey_question_option + SET question_option_id = $insertId + WHERE iid = $insertId"; + Database::query($sql); + $counter++; } } @@ -1327,19 +1375,20 @@ class survey_manager { if (is_array($form_content) && is_array($form_content['answers'])) { // Table defintion - $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION); + $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION); // We are editing a question so we first have to remove all the existing options from the database - $sql = "DELETE FROM $table_survey_question_option WHERE question_id = '".Database::escape_string($form_content['shared_question_id'])."'"; + $sql = "DELETE FROM $table_survey_question_option + WHERE question_id = '".Database::escape_string($form_content['shared_question_id'])."'"; Database::query($sql); $counter = 1; foreach ($form_content['answers'] as & $answer) { $sql = "INSERT INTO $table_survey_question_option (question_id, survey_id, option_text, sort) VALUES ( - '".Database::escape_string($form_content['shared_question_id'])."', - '".Database::escape_string($survey_data['is_shared'])."', - '".Database::escape_string($answer)."', - '".Database::escape_string($counter)."')"; + '".Database::escape_string($form_content['shared_question_id'])."', + '".Database::escape_string($survey_data['is_shared'])."', + '".Database::escape_string($answer)."', + '".Database::escape_string($counter)."')"; Database::query($sql); $counter++; } @@ -1647,6 +1696,10 @@ class SurveyUtil '".Database::escape_string($option_value)."' )"; Database::query($sql); + $insertId = Database::insert_id(); + + $sql = "UPDATE $table_survey_answer SET answer_id = $insertId WHERE iid = $insertId"; + Database::query($sql); } /** @@ -1661,7 +1714,7 @@ class SurveyUtil $error = false; // Getting the survey data - $survey_data = survey_manager::get_survey($_GET['survey_id']); + $survey_data = SurveyManager::get_survey($_GET['survey_id']); // $_GET['survey_id'] has to be numeric if (!is_numeric($_GET['survey_id'])) { @@ -1669,7 +1722,14 @@ class SurveyUtil } // $_GET['action'] - $allowed_actions = array('overview', 'questionreport', 'userreport', 'comparativereport', 'completereport','deleteuserreport'); + $allowed_actions = array( + 'overview', + 'questionreport', + 'userreport', + 'comparativereport', + 'completereport', + 'deleteuserreport' + ); if (isset($_GET['action']) && !in_array($_GET['action'], $allowed_actions)) { $error = get_lang('ActionNotAllowed'); } @@ -1718,7 +1778,7 @@ class SurveyUtil $action = isset($_GET['action']) ? $_GET['action'] : null; // Getting the number of question - $temp_questions_data = survey_manager::get_questions($_GET['survey_id']); + $temp_questions_data = SurveyManager::get_questions($_GET['survey_id']); // Sorting like they should be displayed and removing the non-answer question types (comment and pagebreak) $my_temp_questions_data = $temp_questions_data == null ? array() : $temp_questions_data; @@ -1801,12 +1861,12 @@ class SurveyUtil * @author Patrick Cool , Ghent University * @version February 2007 - Updated March 2008 */ - static function display_user_report($people_filled, $survey_data) + public static function display_user_report($people_filled, $survey_data) { // Database table definitions - $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); - $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); - $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); + $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); + $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); + $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); // Actions bar echo '
    '; @@ -1866,6 +1926,7 @@ class SurveyUtil echo '>'.$name.''; } echo ''; + $course_id = api_get_course_int_id(); // Step 2: displaying the survey and the answer of the selected users if (isset($_GET['user'])) { @@ -1895,12 +1956,12 @@ class SurveyUtil $result = Database::query($sql); while ($row = Database::fetch_array($result, 'ASSOC')) { if($row['type'] != 'pagebreak') { - $questions[$row['sort']]['question_id'] = $row['question_id']; - $questions[$row['sort']]['survey_id'] = $row['survey_id']; - $questions[$row['sort']]['survey_question'] = $row['survey_question']; - $questions[$row['sort']]['display'] = $row['display']; - $questions[$row['sort']]['type'] = $row['type']; - $questions[$row['sort']]['maximum_score'] = $row['max_value']; + $questions[$row['sort']]['question_id'] = $row['question_id']; + $questions[$row['sort']]['survey_id'] = $row['survey_id']; + $questions[$row['sort']]['survey_question'] = $row['survey_question']; + $questions[$row['sort']]['display'] = $row['display']; + $questions[$row['sort']]['type'] = $row['type']; + $questions[$row['sort']]['maximum_score'] = $row['max_value']; $questions[$row['sort']]['options'][$row['question_option_id']] = $row['option_text']; } } @@ -1909,7 +1970,7 @@ class SurveyUtil $sql = "SELECT * FROM $table_survey_answer WHERE c_id = $course_id AND - survey_id = '".Database::escape_string($_GET['survey_id'])."' AND + survey_id = '".intval($_GET['survey_id'])."' AND user = '".Database::escape_string($_GET['user'])."'"; $result = Database::query($sql); while ($row = Database::fetch_array($result, 'ASSOC')) { @@ -1917,7 +1978,7 @@ class SurveyUtil $all_answers[$row['question_id']][] = $row; } // Displaying all the questions - $second_parameter=array(); + $second_parameter = array(); foreach ($questions as & $question) { // If the question type is a scoring then we have to format the answers differently @@ -1928,15 +1989,24 @@ class SurveyUtil } } } else { - $second_parameter = $answers[$question['question_id']]; + $second_parameter = isset($answers[$question['question_id']]) ? $answers[$question['question_id']] : ''; if ($question['type'] == 'open') { $second_parameter = array(); $second_parameter[] = $all_answers[$question['question_id']][0]['option_id']; } } + $ch_type = 'ch_'.$question['type']; + /** @var survey_question $display */ $display = new $ch_type; - $display->render_question($question, $second_parameter); + + $url = api_get_self(); + $form = new FormValidator('question', 'post', $url); + $form->addHtml('
    '); + $form->addHtml($question['survey_question']); + $display->render($form, $question); + $form->addHtml('
    '); + $form->display(); } } } @@ -2995,7 +3065,7 @@ class SurveyUtil $allowed_question_types = array('yesno', 'multiplechoice', 'multipleresponse', 'dropdown', 'percentage', 'score'); // Getting all the questions - $questions = survey_manager::get_questions($_GET['survey_id']); + $questions = SurveyManager::get_questions($_GET['survey_id']); // Actions bar @@ -3047,12 +3117,12 @@ class SurveyUtil // Getting all the information of the x axis if (isset($_GET['xaxis']) && is_numeric($_GET['xaxis'])) { - $question_x = survey_manager::get_question($_GET['xaxis']); + $question_x = SurveyManager::get_question($_GET['xaxis']); } // Getting all the information of the y axis if (isset($_GET['yaxis']) && is_numeric($_GET['yaxis'])) { - $question_y = survey_manager::get_question($_GET['yaxis']); + $question_y = SurveyManager::get_question($_GET['yaxis']); } if (isset($_GET['xaxis']) && is_numeric($_GET['xaxis']) && isset($_GET['yaxis']) && is_numeric($_GET['yaxis'])) { @@ -3368,7 +3438,7 @@ class SurveyUtil * @version January 2007 * */ - public static function save_invitations( + public static function saveInvitations( $users_array, $invitation_title, $invitation_text, @@ -3383,7 +3453,7 @@ class SurveyUtil } // Getting the survey information - $survey_data = survey_manager::get_survey($_GET['survey_id']); + $survey_data = SurveyManager::get_survey($_GET['survey_id']); $survey_invitations = SurveyUtil::get_invitations($survey_data['survey_code']); $already_invited = SurveyUtil::get_invited_users($survey_data['code']); @@ -3391,7 +3461,7 @@ class SurveyUtil $exclude_users = array(); if ($remindUnAnswered == 1) { // Remind only unanswered users $reminder = 1; - $exclude_users = survey_manager::get_people_who_filled_survey($_GET['survey_id']); + $exclude_users = SurveyManager::get_people_who_filled_survey($_GET['survey_id']); } $counter = 0; // Nr of invitations "sent" (if sendmail option) @@ -3494,7 +3564,13 @@ class SurveyUtil (!empty($params['user']) || !empty($params['group_id'])) && !empty($params['survey_code']) ) { - return Database::insert($table, $params); + $insertId = Database::insert($table, $params); + if ($insertId) { + + $sql = "UPDATE $table SET survey_invitation_id = $insertId + WHERE iid = $insertId"; + Database::query($sql); + } } return false; } @@ -3918,7 +3994,7 @@ class SurveyUtil api_is_element_in_the_session(TOOL_SURVEY, $survey_id) ) { $return .= ''.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).''; - if (survey_manager::survey_generation_hash_available()) { + if (SurveyManager::survey_generation_hash_available()) { $return .= Display::url( Display::return_icon('new_link.png', get_lang('GenerateSurveyAccessLink'),'',ICON_SIZE_SMALL), api_get_path(WEB_CODE_PATH).'survey/generate_link.php?survey_id='.$survey_id.'&'.api_get_cidreq() @@ -4206,7 +4282,7 @@ class SurveyUtil * @author Patrick Cool , Ghent University * @version April 2007 */ - public static function survey_list_user($user_id) + public static function getSurveyList($user_id) { $_course = api_get_course_info(); $course_id = api_get_course_int_id(); @@ -4214,16 +4290,18 @@ class SurveyUtil $sessionId = api_get_session_id(); // Database table definitions - $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); + $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION); - $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); - $table_survey = Database :: get_course_table(TABLE_SURVEY); - $all_question_id = array(); + $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); + $table_survey = Database:: get_course_table(TABLE_SURVEY); - $sql = 'SELECT question_id FROM '.$table_survey_question." WHERE c_id = $course_id"; + $sql = 'SELECT question_id + FROM '.$table_survey_question." + WHERE c_id = $course_id"; $result = Database::query($sql); - while($row = Database::fetch_array($result, 'ASSOC')) { + $all_question_id = array(); + while ($row = Database::fetch_array($result, 'ASSOC')) { $all_question_id[] = $row; } @@ -4247,6 +4325,7 @@ class SurveyUtil break; } } + echo '
    '; echo '
    '; echo Display::return_icon('survey.png', get_lang('CreateNewSurvey'),array('style'=>'inline-block'),ICON_SIZE_SMALL); @@ -4256,19 +4335,23 @@ class SurveyUtil echo ' '.get_lang('SurveyName').''; echo ' '.get_lang('Anonymous').''; echo ''; - $sql = "SELECT * FROM $table_survey survey, $table_survey_invitation survey_invitation + + $sql = "SELECT * + FROM $table_survey survey, + $table_survey_invitation survey_invitation WHERE - survey_invitation.user = $user_id AND - survey.code = survey_invitation.survey_code AND - survey.avail_from <= '".date('Y-m-d H:i:s')."' AND - survey.avail_till >= '".date('Y-m-d H:i:s')."' AND - survey.c_id = $course_id AND - survey.session_id = $sessionId AND - survey_invitation.c_id = $course_id + survey_invitation.user = $user_id AND + survey.code = survey_invitation.survey_code AND + survey.avail_from <= '".date('Y-m-d H:i:s')."' AND + survey.avail_till >= '".date('Y-m-d H:i:s')."' AND + survey.c_id = $course_id AND + survey.session_id = $sessionId AND + survey_invitation.c_id = $course_id "; $result = Database::query($sql); $counter = 0; while ($row = Database::fetch_array($result, 'ASSOC')) { + // Get the user into survey answer table (user or anonymus) $sql = "SELECT user FROM $table_survey_answer WHERE c_id = $course_id AND survey_id = ( diff --git a/main/survey/survey.php b/main/survey/survey.php index d4d8c68d5f..61fd907d14 100755 --- a/main/survey/survey.php +++ b/main/survey/survey.php @@ -56,7 +56,7 @@ $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'survey/survey_ if (isset($_GET['survey_id'])) { $course_code = api_get_course_id(); if ($course_code!=-1) { - $survey_data = survey_manager::get_survey($survey_id); + $survey_data = SurveyManager::get_survey($survey_id); } else { Display :: display_header(get_lang('ToolSurvey')); Display :: display_error_message(get_lang('NotAllowed'), false); @@ -108,11 +108,11 @@ $message_information = isset($_GET['message']) ? Security::remove_XSS($_GET[' if (isset($action)) { if (($action == 'moveup' || $action == 'movedown') && isset($_GET['question_id'])) { - survey_manager::move_survey_question($my_action_survey,$my_question_id_survey,$my_survey_id_survey); + SurveyManager::move_survey_question($my_action_survey,$my_question_id_survey,$my_survey_id_survey); Display::display_confirmation_message(get_lang('SurveyQuestionMoved')); } if ($action == 'delete' AND is_numeric($_GET['question_id'])) { - survey_manager::delete_survey_question($my_survey_id_survey, $my_question_id_survey, $survey_data['is_shared']); + SurveyManager::delete_survey_question($my_survey_id_survey, $my_question_id_survey, $survey_data['is_shared']); } } diff --git a/main/survey/survey_invitation.php b/main/survey/survey_invitation.php index 89fd8874d4..5b368f4e9c 100755 --- a/main/survey/survey_invitation.php +++ b/main/survey/survey_invitation.php @@ -40,7 +40,7 @@ if (!isset($_GET['survey_id']) OR !is_numeric($_GET['survey_id'])) { } $survey_id = Security::remove_XSS($_GET['survey_id']); -$survey_data = survey_manager::get_survey($survey_id); +$survey_data = SurveyManager::get_survey($survey_id); if (empty($survey_data)) { Display :: display_header($tool_name); @@ -70,7 +70,7 @@ if (!is_numeric($survey_id)) { } // Getting all the people who have filled this survey -$answered_data = survey_manager::get_people_who_filled_survey($survey_id); +$answered_data = SurveyManager::get_people_who_filled_survey($survey_id); if ($survey_data['anonymous'] == 1) { Display::display_normal_message(get_lang('AnonymousSurveyCannotKnowWhoAnswered').' '.count($answered_data).' '.get_lang('PeopleAnswered')); $answered_data = array(); @@ -104,25 +104,36 @@ $course_id = api_get_course_int_id(); $sql = "SELECT survey_invitation.*, user.firstname, user.lastname, user.email FROM $table_survey_invitation survey_invitation - LEFT JOIN $table_user user ON (survey_invitation.user = user.user_id AND survey_invitation.c_id = $course_id) - WHERE survey_invitation.survey_code = '".Database::escape_string($survey_data['code'])."' "; + LEFT JOIN $table_user user + ON (survey_invitation.user = user.user_id AND survey_invitation.c_id = $course_id) + WHERE + survey_invitation.survey_code = '".Database::escape_string($survey_data['code'])."' "; $res = Database::query($sql); while ($row = Database::fetch_assoc($res)) { - if (!$_GET['view'] || $_GET['view'] == 'invited' || ($_GET['view'] == 'answered' && in_array($row['user'], $answered_data)) || ($_GET['view'] == 'unanswered' && !in_array($row['user'], $answered_data))) { + if (!$_GET['view'] || + $_GET['view'] == 'invited' || + ($_GET['view'] == 'answered' && in_array($row['user'], $answered_data)) || + ($_GET['view'] == 'unanswered' && !in_array($row['user'], $answered_data)) + ) { echo ''; if (is_numeric($row['user'])) { - echo ' '.api_get_person_name($row['firstname'], $row['lastname']).''; + $userInfo = api_get_user_info($row['user']); + echo ''; + echo UserManager::getUserProfileLink($userInfo); + echo ''; } else { - echo ' '.$row['user'].''; + echo ''.$row['user'].''; } echo ' '.$row['invitation_date'].''; echo ' '; + if (in_array($row['user'], $answered_data)) { echo ''.get_lang('ViewAnswers').''; } else { echo '-'; } + echo ' '; echo ''; } diff --git a/main/survey/survey_invite.php b/main/survey/survey_invite.php index 3e5ae5ff18..bb357012d4 100755 --- a/main/survey/survey_invite.php +++ b/main/survey/survey_invite.php @@ -35,7 +35,7 @@ $course_id = api_get_course_int_id(); // Getting the survey information $survey_id = Security::remove_XSS($_GET['survey_id']); -$survey_data = survey_manager::get_survey($survey_id); +$survey_data = SurveyManager::get_survey($survey_id); if (empty($survey_data)) { Display :: display_header(get_lang('ToolSurvey')); Display :: display_error_message(get_lang('InvallidSurvey'), false); @@ -198,14 +198,18 @@ if ($form->validate()) { !empty($survey_data['invite_mail']) ); + $resendAll = isset($values['resend_to_all']) ? $values['resend_to_all'] : ''; + $sendMail = isset($values['send_mail']) ? $values['send_mail'] : ''; + $remindUnAnswered = isset($values['remindUnAnswered']) ? $values['remindUnAnswered'] : ''; + // Saving the invitations for the course users - $count_course_users = SurveyUtil::save_invitations( + $count_course_users = SurveyUtil::saveInvitations( $values['users'], $values['mail_title'], $values['mail_text'], - $values['resend_to_all'], - $values['send_mail'], - $values['remindUnAnswered'] + $resendAll, + $sendMail, + $remindUnAnswered ); // Saving the invitations for the additional users @@ -216,13 +220,13 @@ if ($form->validate()) { $additional_users[$i] = trim($additional_users[$i]); } - $counter_additional_users = SurveyUtil::save_invitations( + $counter_additional_users = SurveyUtil::saveInvitations( $additional_users, $values['mail_title'], $values['mail_text'], - $values['resend_to_all'], - $values['send_mail'], - $values['remindUnAnswered'] + $resendAll, + $sendMail, + $remindUnAnswered ); // Updating the invited field in the survey table diff --git a/main/survey/survey_list.php b/main/survey/survey_list.php index 5580c468e3..388c5cb412 100755 --- a/main/survey/survey_list.php +++ b/main/survey/survey_list.php @@ -47,7 +47,7 @@ if ($isDrhOfCourse) { if (!api_is_allowed_to_edit(false, true)) { // Coach can see this Display::display_header(get_lang('SurveyList')); - SurveyUtil::survey_list_user(api_get_user_id()); + SurveyUtil::getSurveyList(api_get_user_id()); Display::display_footer(); exit; } @@ -62,7 +62,10 @@ $table_user = Database:: get_main_table(TABLE_MAIN_USER); // Language variables if (isset($_GET['search']) && $_GET['search'] == 'advanced') { - $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', 'name' => get_lang('SurveyList')); + $interbreadcrumb[] = array( + 'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', + 'name' => get_lang('SurveyList') + ); $tool_name = get_lang('SearchASurvey'); } else { $tool_name = get_lang('SurveyList'); @@ -70,7 +73,7 @@ if (isset($_GET['search']) && $_GET['search'] == 'advanced') { if ($action == 'copy_survey') { if (api_is_allowed_to_edit()) { - survey_manager::copy_survey($_GET['survey_id']); + SurveyManager::copy_survey($_GET['survey_id']); $message = get_lang('Copied'); header('Location: ' . api_get_path(WEB_CODE_PATH) . 'survey/survey_list.php?' . api_get_cidreq()); exit; @@ -87,10 +90,11 @@ Display::display_introduction_section('survey', 'left'); if (isset($_GET['search']) && $_GET['search'] == 'advanced') { SurveyUtil::display_survey_search_form(); } + // Action handling: deleting a survey if ($action == 'delete' && isset($_GET['survey_id'])) { // Getting the information of the survey (used for when the survey is shared) - $survey_data = survey_manager::get_survey($_GET['survey_id']); + $survey_data = SurveyManager::get_survey($_GET['survey_id']); if (api_is_course_coach() && intval($_SESSION['id_session']) != $survey_data['session_id']) { // The coach can't delete a survey not belonging to his session api_not_allowed(); @@ -98,10 +102,10 @@ if ($action == 'delete' && isset($_GET['survey_id'])) { } // If the survey is shared => also delete the shared content if (is_numeric($survey_data['survey_share'])) { - survey_manager::delete_survey($survey_data['survey_share'], true); + SurveyManager::delete_survey($survey_data['survey_share'], true); } - $return = survey_manager::delete_survey($_GET['survey_id']); + $return = SurveyManager::delete_survey($_GET['survey_id']); if ($return) { Display::display_confirmation_message(get_lang('SurveyDeleted'), false); @@ -125,7 +129,7 @@ if ($action == 'empty') { exit; } } - $return = survey_manager::empty_survey(intval($_GET['survey_id'])); + $return = SurveyManager::empty_survey(intval($_GET['survey_id'])); if ($return) { Display :: display_confirmation_message(get_lang('SurveyEmptied'), false); } else { @@ -138,13 +142,13 @@ if (isset($_POST['action']) && $_POST['action']) { if (is_array($_POST['id'])) { foreach ($_POST['id'] as $key => & $value) { // getting the information of the survey (used for when the survey is shared) - $survey_data = survey_manager::get_survey($value); + $survey_data = SurveyManager::get_survey($value); // if the survey is shared => also delete the shared content if (is_numeric($survey_data['survey_share'])) { - survey_manager::delete_survey($survey_data['survey_share'], true); + SurveyManager::delete_survey($survey_data['survey_share'], true); } // delete the actual survey - survey_manager::delete_survey($value); + SurveyManager::delete_survey($value); } Display :: display_confirmation_message(get_lang('SurveysDeleted'), false); } else { diff --git a/main/survey/survey_question.php b/main/survey/survey_question.php index cd4fcafec5..6007296bce 100644 --- a/main/survey/survey_question.php +++ b/main/survey/survey_question.php @@ -26,7 +26,7 @@ class survey_question $surveyId = isset($_GET['survey_id']) ? intval($_GET['survey_id']) : null; $toolName = Display::return_icon( - survey_manager::icon_question(Security::remove_XSS($_GET['type'])), + SurveyManager::icon_question(Security::remove_XSS($_GET['type'])), get_lang(ucfirst(Security::remove_XSS($_GET['type']))), array('align' => 'middle', 'height' => '22px') ).' '; @@ -255,7 +255,7 @@ class survey_question if (isset($_POST['buttons']) && isset($_POST['buttons']['save'])) { Session::erase('answer_count'); Session::erase('answer_list'); - $message = survey_manager::save_question( + $message = SurveyManager::save_question( $surveyData, $formData ); diff --git a/main/template/default/layout/footer.tpl b/main/template/default/layout/footer.tpl index 365bc729e2..38097a82e5 100755 --- a/main/template/default/layout/footer.tpl +++ b/main/template/default/layout/footer.tpl @@ -90,6 +90,13 @@ $.datepicker.setDefaults($.datepicker.regional["{{ locale }}"]); $.datepicker.regional["local"] = $.datepicker.regional["{{ locale }}"]; + $('.tab-wrapper a').click(function (e) { + e.preventDefault() + $(this).tab('show'); + + //$('#tabs a:first').tab('show') // Select first tab + }) + /** * Advanced options * Usage diff --git a/main/template/default/social/home.tpl b/main/template/default/social/home.tpl index ac881c5398..d330fe6e96 100644 --- a/main/template/default/social/home.tpl +++ b/main/template/default/social/home.tpl @@ -9,7 +9,7 @@ {{ social_menu_block }}
    -
    +
    {{ social_search_block }} {{ social_skill_block }} {{ social_group_block }} @@ -17,8 +17,5 @@
    {{ social_auto_extend_link }}
    -
    - -
    {% endblock %} diff --git a/main/tracking/courseLog.php b/main/tracking/courseLog.php index b879bb9023..1df74df498 100755 --- a/main/tracking/courseLog.php +++ b/main/tracking/courseLog.php @@ -18,7 +18,7 @@ $from = isset($_GET['from']) ? $_GET['from'] : null; // Starting the output buffering when we are exporting the information. $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false; -$session_id = intval($_REQUEST['id_session']); +$session_id = isset($_REQUEST['id_session']) ? intval($_REQUEST['id_session']) : 0; if ($from == 'myspace') { $from_myspace = true; @@ -302,7 +302,7 @@ $coaches = null; if (!empty($session_id)) { $coaches = CourseManager::get_coachs_from_course_to_string( $session_id, - $courseInfo['code'], + $courseInfo['real_id'], ',', false ); @@ -318,7 +318,7 @@ if (!empty($coaches)) { echo $coaches; } -$sessionList = SessionManager::get_session_by_course($courseInfo['code']); +$sessionList = SessionManager::get_session_by_course($courseInfo['real_id']); if (!empty($sessionList)) { echo Display::page_subheader2(get_lang('SessionList')); $sessionToShow = array(); @@ -517,7 +517,7 @@ if ($export_csv) { ob_end_clean(); array_unshift($csv_content, $csv_headers); // Adding headers before the content. - Export::export_table_csv($csv_content, 'reporting_student_list'); + Export::arrayToCsv($csv_content, 'reporting_student_list'); exit; } Display::display_footer(); diff --git a/main/tracking/courseLogCSV.php b/main/tracking/courseLogCSV.php index 4c90b7347a..a1a4c581b4 100755 --- a/main/tracking/courseLogCSV.php +++ b/main/tracking/courseLogCSV.php @@ -97,12 +97,15 @@ if ($is_allowedToTrack) { // BEGIN users in this course $sql = "SELECT $TABLECOURSUSER.user_i, $table_user.lastname, $table_user.firstname FROM $TABLECOURSUSER, $table_user - WHERE $TABLECOURSUSER.course_code = '" . $_cid . "' AND $TABLECOURSUSER.user_id = $table_user.user_id AND $TABLECOURSUSER.relation_type<>" . COURSE_RELATION_TYPE_RRHH . " + WHERE + $TABLECOURSUSER.c_id = '" . api_get_course_int_id() . "' AND + $TABLECOURSUSER.user_id = $table_user.user_id AND + $TABLECOURSUSER.relation_type<>" . COURSE_RELATION_TYPE_RRHH . " ORDER BY $table_user.lastname"; $results = StatsUtils::getManyResults3Col($sql); //BUGFIX: get visual code instead of real course code. Scormpaths use the visual code... (should be fixed in future versions) - $sql = "SELECT visual_code FROM $TABLECOURSE WHERE code = '" . $_cid . "'"; + $sql = "SELECT visual_code FROM $TABLECOURSE WHERE code = '" . api_get_course_id() . "'"; $_course['visual_code'] = StatsUtils::getOneResult($sql); if (is_array($results)) { @@ -167,7 +170,7 @@ if ($is_allowedToTrack) { $sql = "SELECT count(*) FROM $TABLECOURSUSER - WHERE course_code = '" . $_cid . "' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . ""; + WHERE c_id = '" . api_get_course_int_id() . "' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . ""; $count = StatsUtils::getOneResult($sql); $title_line = get_lang('CountUsers') . " ; " . $count . "\n"; } diff --git a/main/tracking/course_log_resources.php b/main/tracking/course_log_resources.php index 581b1fd641..43385a16a8 100755 --- a/main/tracking/course_log_resources.php +++ b/main/tracking/course_log_resources.php @@ -121,7 +121,7 @@ $table = new SortableTable( ); $parameters = array( - 'keyword' => Security::remove_XSS($_GET['keyword']), + //'keyword' => Security::remove_XSS($_GET['keyword']), 'id_session' => $session_id, 'cidReq' => api_get_course_id() ); diff --git a/main/tracking/course_log_tools.php b/main/tracking/course_log_tools.php index 5b5988914b..9715db4e90 100755 --- a/main/tracking/course_log_tools.php +++ b/main/tracking/course_log_tools.php @@ -335,7 +335,7 @@ echo '
    '; // send the csv file if asked if ($export_csv) { ob_end_clean(); - Export :: export_table_csv($csv_content, 'reporting_course_tools'); + Export :: arrayToCsv($csv_content, 'reporting_course_tools'); exit; } diff --git a/main/tracking/exams.php b/main/tracking/exams.php index 50946ae323..d2666d282c 100755 --- a/main/tracking/exams.php +++ b/main/tracking/exams.php @@ -173,7 +173,7 @@ $s_css_class = null; if (!empty($courseList) && is_array($courseList)) { foreach ($courseList as $courseInfo) { - $sessionList = SessionManager::get_session_by_course($courseInfo['code']); + $sessionList = SessionManager::get_session_by_course($courseInfo['real_id']); $newSessionList = array(); if (!empty($sessionList)) { diff --git a/main/tracking/logins_details.php b/main/tracking/logins_details.php index 456f863437..3e9f4296fc 100755 --- a/main/tracking/logins_details.php +++ b/main/tracking/logins_details.php @@ -70,15 +70,18 @@ $is_allowedToTrackEverybodyInCourse = $is_courseAdmin; // allowed to track all s " . COURSE_RELATION_TYPE_RRHH . " - AND cu.course_code = '$_cid' - AND u.user_id = '$uInfo'"; + WHERE + cu.user_id = u.user_id AND + cu.relation_type<>" . COURSE_RELATION_TYPE_RRHH . " AND + cu.c_id = '$courseId' AND + u.user_id = '$uInfo'"; } else { $sql = "SELECT u.firstname,u.lastname, u.email FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u diff --git a/main/tracking/lp_results_by_user.php b/main/tracking/lp_results_by_user.php index a3e3b3e24e..f1c9cbb89d 100755 --- a/main/tracking/lp_results_by_user.php +++ b/main/tracking/lp_results_by_user.php @@ -222,7 +222,7 @@ function export_complete_report_csv($filename, $array) { $header[] = array(get_lang('Course'),get_lang('LearningPath'), get_lang('Exercise'), get_lang('User'),get_lang('Attempt'), get_lang('Date'),get_lang('Results')); if (!empty($array)) { $array = array_merge($header, $array); - Export :: export_table_csv($array, $filename); + Export :: arrayToCsv($array, $filename); } exit; /* diff --git a/main/tracking/personnalLog.php b/main/tracking/personnalLog.php index a07c8ba6f9..4da7d44fc0 100755 --- a/main/tracking/personnalLog.php +++ b/main/tracking/personnalLog.php @@ -35,11 +35,6 @@ td {border-bottom: thin dashed gray;} /*]]>*/ "; -/* ------------------------------------------------------------ - Constants and variables ------------------------------------------------------------ -*/ //Remove all characters different than 0 and 1 from $view parameter $view = preg_replace('/[^01]/','',$_REQUEST['view']); diff --git a/main/tracking/userLog.php b/main/tracking/userLog.php index 136538f172..80915c1a0f 100755 --- a/main/tracking/userLog.php +++ b/main/tracking/userLog.php @@ -72,11 +72,11 @@ $now = api_get_utc_datetime(); $sql = "SELECT 1 FROM $tbl_session_course_user AS session_course_user INNER JOIN $tbl_session AS session - ON session_course_user.id_session = session.id + ON session_course_user.session_id = session.id AND ((date_start <= '$now' AND date_end >= '$now') OR (date_start='0000-00-00' AND date_end='0000-00-00')) - WHERE id_session='".api_get_session_id()."' AND course_code='$_cid'"; + WHERE session_id='".api_get_session_id()."' AND course_code='$_cid'"; //echo $sql; $result=Database::query($sql); if(!Database::num_rows($result)){ @@ -125,7 +125,7 @@ if (( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) { $sql = "SELECT count(user_id) FROM $TABLECOURSUSER - WHERE course_code = '".Database::escape_string($_cid)."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH.""; + WHERE c_id = '".$courseId."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH.""; } else { // if user can only track one group : list users of this group @@ -173,15 +173,18 @@ if (( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) { // list of users in this course $sql = "SELECT u.user_id, u.firstname,u.lastname FROM $TABLECOURSUSER cu , $TABLEUSER u - WHERE cu.user_id = u.user_id AND cu.relation_type<>".COURSE_RELATION_TYPE_RRHH." - AND cu.course_code = '".Database::escape_string($_cid)."' + WHERE + cu.user_id = u.user_id AND + cu.relation_type<>".COURSE_RELATION_TYPE_RRHH." AND + cu.c_id = '".$courseId."' LIMIT $offset,$step"; } else { // list of users of this group $sql = "SELECT u.user_id, u.firstname,u.lastname FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u - WHERE gu.user_id = u.user_id - AND gu.group_id = '".intval($_gid)."' + WHERE + gu.user_id = u.user_id AND + gu.group_id = '".intval($_gid)."' LIMIT $offset,$step"; } $list_users = getManyResults3Col($sql); diff --git a/main/tracking/userlogCSV.php b/main/tracking/userlogCSV.php index 0b6175b6dc..5c198b9cae 100755 --- a/main/tracking/userlogCSV.php +++ b/main/tracking/userlogCSV.php @@ -22,14 +22,6 @@ $user_id = api_get_user_id(); $course_id = api_get_course_id(); $courseId = api_get_course_int_id(); -/* -$role_id = RolesRights::get_local_user_role_id($user_id, $course_id); -$location_id = RolesRights::get_course_tool_location_id($course_id, TOOL_TRACKING); -$is_allowed = RolesRights::is_allowed_which_rights($role_id, $location_id); - -//block users without view right -RolesRights::protect_location($role_id, $location_id); -*/ //YW Hack security to quick fix RolesRights bug $is_allowed = true; @@ -75,11 +67,11 @@ $now = api_get_utc_datetime(); $sql = "SELECT 1 FROM $tbl_session_course_user AS session_course_user INNER JOIN $tbl_session AS session - ON session_course_user.id_session = session.id + ON session_course_user.session_id = session.id AND ((date_start <= '$now' AND date_end >= '$now') OR (date_start='0000-00-00' AND date_end='0000-00-00')) - WHERE id_session='" . $_SESSION['id_session'] . "' AND course_code='$_cid'"; + WHERE session_id='" . $_SESSION['id_session'] . "' AND course_code='$_cid'"; //echo $sql; $result = Database::query($sql); if (!Database::num_rows($result)) { @@ -123,8 +115,8 @@ if (($is_allowedToTrack || $is_allowedToTrackEverybodyInCourse)) { if ($is_allowedToTrackEverybodyInCourse) { // if user can track everybody : list user of course $sql = "SELECT count(user_id) - FROM $TABLECOURSUSER - WHERE course_code = '$_cid' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . ""; + FROM $TABLECOURSUSER + WHERE c_id = '$courseId' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . ""; } else { // if user can only track one group : list users of this group @@ -163,7 +155,7 @@ if (($is_allowedToTrack || $is_allowedToTrackEverybodyInCourse)) { $sql = "SELECT u.user_id, u.firstname,u.lastname FROM $TABLECOURSUSER cu , $TABLEUSER u WHERE cu.user_id = u.user_id AND cu.relation_type<>" . COURSE_RELATION_TYPE_RRHH . " - AND cu.course_code = '$_cid' + AND cu.c_id = '$courseId' LIMIT $offset,$step"; } else { // list of users of this group diff --git a/main/user/add_users_to_session.php b/main/user/add_users_to_session.php index e511cee49b..fd7ed256b2 100755 --- a/main/user/add_users_to_session.php +++ b/main/user/add_users_to_session.php @@ -32,20 +32,20 @@ if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') { $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); - + // setting the name of the tool $tool_name = get_lang('SubscribeUsersToSession'); - + $add_type = 'unique'; - + if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!='') { $add_type = Security::remove_XSS($_REQUEST['add_type']); } - + $page = isset($_GET['page']) ? Security::remove_XSS($_GET['page']) : null; - + //checking for extra field with filter on - + $extra_field_list= UserManager::get_extra_fields(); $new_field_list = array(); if (is_array($extra_field_list)) { @@ -56,35 +56,36 @@ if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') { } } } - + function search_users($needle, $type) - { + { global $tbl_user,$tbl_session_rel_user,$id_session; $xajax_response = new xajaxResponse(); $return = ''; - + if (!empty($needle) && !empty($type)) { - + //normal behaviour if ($type == 'any_session' && $needle == 'false') { $type = 'multiple'; $needle = ''; } - + // xajax send utf8 datas... datas in db can be non-utf8 datas $charset = api_get_system_encoding(); $needle = Database::escape_string($needle); $needle = api_convert_encoding($needle, $charset, 'utf-8'); - + $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; $cond_user_id = ''; - + //Only for single & multiple if (in_array($type, array('single','multiple'))) { if (!empty($id_session)) { $id_session = intval($id_session); // check id_user from session_rel_user table - $sql = 'SELECT id_user FROM '.$tbl_session_rel_user.' WHERE id_session ="'.$id_session.'" AND relation_type<>'.SESSION_RELATION_TYPE_RRHH.' '; + $sql = 'SELECT user_id FROM '.$tbl_session_rel_user.' + WHERE session_id ="'.$id_session.'" AND relation_type<>'.SESSION_RELATION_TYPE_RRHH.' '; $res = Database::query($sql); $user_ids = array(); if (Database::num_rows($res) > 0) { @@ -97,7 +98,7 @@ if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') { } } } - + switch ($type) { case 'single': // search users where username or firstname or lastname begins likes $needle @@ -109,13 +110,20 @@ if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') { break; case 'multiple': $sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user - WHERE '.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND user.status<>'.DRH.' AND user.status<>6 '.$cond_user_id. + WHERE '.(api_sort_by_first_name() ? 'firstname' : 'lastname').' + LIKE "'.$needle.'%" AND + user.status<>'.DRH.' AND + user.status<>6 '.$cond_user_id. $order_clause; break; case 'any_session': - $sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.id_user = user.user_id) - WHERE s.id_user IS null AND user.status<>'.DRH.' AND - user.status<>6 '.$cond_user_id. + $sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname + FROM '.$tbl_user.' user + LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.user_id = user.user_id) + WHERE + s.user_id IS NULL AND + user.status <>'.DRH.' AND + user.status <> 6 '.$cond_user_id. $order_clause; break; } @@ -141,18 +149,21 @@ if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') { $order_clause; break; case 'any_session' : - $sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.id_user = user.user_id) - INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id) - WHERE access_url_id = '.$access_url_id.' AND - s.id_user IS null AND - user.status<>'.DRH.' AND - user.status<>6 '.$cond_user_id. + $sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname + FROM '.$tbl_user.' user LEFT OUTER JOIN '.$tbl_session_rel_user.' s + ON (s.user_id = user.user_id) + INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id) + WHERE + access_url_id = '.$access_url_id.' AND + s.user_id IS null AND + user.status<>'.DRH.' AND + user.status<>6 '.$cond_user_id. $order_clause; break; } } } - + $rs = Database::query($sql); $i=0; if ($type == 'single') { @@ -165,7 +176,7 @@ if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') { $return .= '...
    '; } } - + $xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return)); } else { global $nosessionUsersList; @@ -180,18 +191,18 @@ if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') { } return $xajax_response; } - + $xajax -> processRequests(); - + $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); $htmlHeadXtra[] = ' '; - - + + $form_sent = 0; $errorMsg = $firstLetterUser = $firstLetterSession=''; $UserList = $SessionList = array(); $sessions = array(); $noPHP_SELF = true; - + if (isset($_POST['form_sent']) && $_POST['form_sent']) { $form_sent = $_POST['form_sent']; $firstLetterUser = $_POST['firstLetterUser']; $firstLetterSession = $_POST['firstLetterSession']; $UserList = $_POST['sessionUsersList']; - + if (!is_array($UserList)) { $UserList=array(); } - + if ($form_sent == 1) { //added a parameter to send emails when registering a user SessionManager::suscribe_users_to_session($id_session, $UserList, null, true); @@ -255,32 +266,32 @@ if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') { exit; } } - + $session_info = SessionManager::fetch($id_session); Display::display_header($tool_name); - + $nosessionUsersList = $sessionUsersList = array(); - + $ajax_search = $add_type == 'unique' ? true : false; - + $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; if ($ajax_search) { - $sql = "SELECT user_id, lastname, firstname, username, id_session + $sql = "SELECT u.user_id, lastname, firstname, username, session_id FROM $tbl_user u INNER JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." - AND $tbl_session_rel_user.id_session = ".intval($id_session)." - WHERE u.status<>".DRH." AND u.status<>6 $order_clause"; - + ON $tbl_session_rel_user.user_id = u.user_id AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." + AND $tbl_session_rel_user.session_id = ".intval($id_session)." + WHERE u.status<>".DRH." AND u.status<>6 $order_clause"; + if (api_is_multiple_url_enabled()) { $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { - $sql="SELECT u.user_id, lastname, firstname, username, id_session + $sql="SELECT u.user_id, lastname, firstname, username, session_id FROM $tbl_user u INNER JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." - AND $tbl_session_rel_user.id_session = ".intval($id_session)." + ON $tbl_session_rel_user.user_id = u.user_id AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." + AND $tbl_session_rel_user.session_id = ".intval($id_session)." INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id) WHERE access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6 $order_clause"; @@ -309,7 +320,7 @@ if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') { } } } - + if ($use_extra_fields) { $final_result = array(); if (count($extra_field_result)>1) { @@ -321,7 +332,7 @@ if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') { } else { $final_result = $extra_field_result[0]; } - + $where_filter =''; if (api_is_multiple_url_enabled()) { if (is_array($final_result) && count($final_result)>0) { @@ -339,20 +350,24 @@ if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') { } } } - + if ($use_extra_fields) { - $sql = "SELECT user_id, lastname, firstname, username, id_session + $sql = "SELECT u.user_id, lastname, firstname, username, session_id FROM $tbl_user u - LEFT JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.id_session = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." - $where_filter AND u.status<>".DRH." AND u.status<>6 - $order_clause"; - + LEFT JOIN $tbl_session_rel_user + ON $tbl_session_rel_user.user_id = u.user_id AND + $tbl_session_rel_user.session_id = '$id_session' AND + $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." + $where_filter AND u.status<>".DRH." AND u.status<>6 + $order_clause"; + } else { - $sql = "SELECT user_id, lastname, firstname, username, id_session + $sql = "SELECT user_id, lastname, firstname, username, session_id FROM $tbl_user u LEFT JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.id_session = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." + ON $tbl_session_rel_user.user_id = u.user_id AND + $tbl_session_rel_user.session_id = '$id_session' AND + $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." WHERE u.status<>".DRH." AND u.status<>6 $order_clause"; } @@ -360,42 +375,55 @@ if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') { $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { - $sql = "SELECT u.user_id, lastname, firstname, username, id_session + $sql = "SELECT u.user_id, lastname, firstname, username, session_id FROM $tbl_user u LEFT JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.id_session = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." + ON + $tbl_session_rel_user.user_id = u.user_id AND + $tbl_session_rel_user.session_id = '$id_session' AND + $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id) WHERE access_url_id = $access_url_id $where_filter AND u.status<>".DRH." AND u.status<>6 $order_clause"; } } - + $result = Database::query($sql); $users = Database::store_result($result,'ASSOC'); - + foreach ($users as $uid => $user) { - if ($user['id_session'] != $id_session) { - $nosessionUsersList[$user['user_id']] = array('fn'=>$user['firstname'],'ln'=>$user['lastname'],'un'=>$user['username']) ; + if ($user['session_id'] != $id_session) { + $nosessionUsersList[$user['user_id']] = array( + 'fn' => $user['firstname'], + 'ln' => $user['lastname'], + 'un' => $user['username'] + ); unset($users[$uid]); } } unset($users); //clean to free memory - + //filling the correct users in list - $sql="SELECT user_id, lastname, firstname, username, id_session + $sql="SELECT user_id, lastname, firstname, username, session_id FROM $tbl_user u LEFT JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.id_session = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." + ON + $tbl_session_rel_user.user_id = u.id AND + $tbl_session_rel_user.session_id = '$id_session' AND + $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." WHERE u.status<>".DRH." AND u.status<>6 $order_clause"; - + if (api_is_multiple_url_enabled()) { $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { - $sql="SELECT u.user_id, lastname, firstname, username, id_session + $sql="SELECT u.user_id, lastname, firstname, username, session_id FROM $tbl_user u LEFT JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.id_session = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." + ON + $tbl_session_rel_user.user_id = u.user_id AND + $tbl_session_rel_user.session_id = '$id_session' AND + $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id) WHERE access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6 $order_clause"; @@ -404,7 +432,7 @@ if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') { $result = Database::query($sql); $users = Database::store_result($result,'ASSOC'); foreach ($users as $uid => $user) { - if ($user['id_session'] == $id_session) { + if ($user['session_id'] == $id_session) { $sessionUsersList[$user['user_id']] = $user; if (array_key_exists($user['user_id'],$nosessionUsersList)) { unset($nosessionUsersList[$user['user_id']]); @@ -414,7 +442,7 @@ if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') { } unset($users); //clean to free memory } - + if ($add_type == 'multiple') { $link_add_type_unique = ''.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').''; $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'); @@ -457,10 +485,10 @@ if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') { } } ?> - + - +
    : - + : ", "", "
    \n"; -} if ($origin != 'learnpath') { Display::display_footer(); } diff --git a/main/user/userInfo.php b/main/user/userInfo.php deleted file mode 100755 index e6f65974b5..0000000000 --- a/main/user/userInfo.php +++ /dev/null @@ -1,590 +0,0 @@ - -function show_image(image,width,height) { - width = parseInt(width) + 20; - height = parseInt(height) + 20; - window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\'); -} - -'; - -$editMainUserInfo = Security::remove_XSS($_REQUEST['editMainUserInfo']); -$uInfo = $editMainUserInfo; -$this_section = SECTION_COURSES; - -$nameTools = get_lang('Users'); -api_protect_course_script(true); -$tool_info = api_get_tool_information_by_name(TOOL_USER); - -if (api_is_anonymous()) { - api_not_allowed(true); -} - -//prepare variables used in userInfoLib.php functions -$TBL_USERINFO_DEF = Database :: get_course_table(TABLE_USER_INFO); -$TBL_USERINFO_CONTENT = Database :: get_course_table(TABLE_USER_INFO_CONTENT); - -if ($tool_info['visibility'] == 1 ) { - $interbreadcrumb[] = array ('url' => 'user.php', 'name' => get_lang('Users')); -} - -if ($origin != 'learnpath') { //so we are not in learnpath tool - Display :: display_header($nameTools, "User"); - $origin = Security::remove_XSS($_GET['origin']); -} else { - ?> '; - if($origin=='users'){ - echo ''.Display::return_icon('back.png',get_lang('BackUser'),'',ICON_SIZE_MEDIUM).''; - } - else{ - echo ''.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).''; - } - - if (!is_numeric($_GET['editMainUserInfo'])) { - if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') { - echo ''.Display::return_icon('edit.png',get_lang('EditUser'),'',ICON_SIZE_MEDIUM).''; - } - } else { - if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') { - echo ''.Display::return_icon('user.png',get_lang('ViewUser'),'',ICON_SIZE_MEDIUM).''; - } - } - echo ''.Display::return_icon('stats.png',get_lang('UserStatistics'),'',ICON_SIZE_MEDIUM).''; - echo ''; -} else { - if ($tool_info['visibility'] == 1 ) { - echo ''; - } -} - -// get information about user id viewed -$user_info_viewed = api_get_user_info($userIdViewed); -$is_session_course_coach = UserManager::is_session_course_coach($userIdViewed, $_course['sysCode'], $current_session_id); - -if ($displayMode == "viewDefEdit") { - /* CATEGORIES DEFINITIONS : EDIT */ - - $catToEdit = get_cat_def($_GET['editDef']); - $edit_heading_form = new FormValidator('edit_heading_form'); - $edit_heading_form->addElement('hidden', 'id'); - $edit_heading_form->addText('title', get_lang('Title')); - $edit_heading_form->addElement('textarea', 'comment', get_lang('Comment'), array ('cols' => 60, 'rows' => 4)); - $possible_line_nrs[1] = '1 '.get_lang('Line'); - $possible_line_nrs[3] = '3 '.get_lang('Lines'); - $possible_line_nrs[5] = '5 '.get_lang('Lines'); - $possible_line_nrs[10] = '10 '.get_lang('Lines'); - $possible_line_nrs[15] = '15 '.get_lang('Lines'); - $edit_heading_form->addElement('select', 'nbline', get_lang('LineNumber'), $possible_line_nrs); - $edit_heading_form->addElement('submit', 'submitDef', get_lang('Ok')); - $edit_heading_form->setDefaults($catToEdit); - $edit_heading_form->display(); - -} elseif ($displayMode == "viewDefList") { - /*CATEGORIES DEFINITIONS : LIST */ - - $catList = get_cat_def_list(); - - if ($catList) { - foreach ($catList as $thisCat) { - // displays Title and comments - echo "

    ", "".htmlize($thisCat['title'])."
    \n", "".htmlize($thisCat['comment'])."\n", "

    "; - - // displays lines - echo "
    \n", "\n"; - - for ($i = 1; $i <= $thisCat['nbline']; $i ++) { - echo "
    __________________________________________\n"; - } - echo "
    \n", "
    \n"; - - // displays commands - echo "", "\"".get_lang('Remove')."\"", "", "", "\"".get_lang('Edit')."\"", "", "", "\"".get_lang('MoveUp')."\"", "", "", "\"".get_lang('MoveDown')."\"", "\n"; - } // end for each - } // end if ($catList) - - echo "
    \n", - "
    ", - "", - "\n", - "
    \n"; -} -elseif ($displayMode == "viewContentEdit") { - /* CATEGORIES CONTENTS : EDIT */ - - $catToEdit = get_cat_content($userIdViewed, $_GET['editContent']); - $content_heading_form = new FormValidator('content_heading_form'); - $content_heading_form->addElement('hidden', 'cntId'); - $content_heading_form->addElement('hidden', 'catId'); - $content_heading_form->addElement('hidden', 'uInfo'); - $content_heading_form->addElement('static', null, $catToEdit['title'], htmlize($catToEdit['comment'])); - if ($catToEdit['nbline'] == 1) { - $content_heading_form->addElement('text', 'content', null, array ('size' => 80)); - } else { - $content_heading_form->addElement('textarea', 'content', null, array ('cols' => 60, 'rows' => $catToEdit['nbline'])); - } - $content_heading_form->addElement('submit', 'submitContent', get_lang('Ok')); - $defaults = $catToEdit; - $defaults['cntId'] = $catToEdit['contentId']; - $defaults['uInfo'] = $userIdViewed; - $content_heading_form->setDefaults($defaults); - $content_heading_form->display(); -} elseif ($displayMode == "viewMainInfoEdit") { - - /* CATEGORIES MAIN INFO : EDIT */ - - $mainUserInfo = get_main_user_info($userIdViewed, $courseCode); - - if ($mainUserInfo) { - ($mainUserInfo['status'] == COURSEMANAGER) ? $courseAdminChecked = "checked" : $courseAdminChecked = ""; - - if ($current_session_id) { - ($is_session_course_coach)? $tutorChecked = "checked" : $tutorChecked = ""; - } else { - ($mainUserInfo['tutor_id'] == 1) ? $tutorChecked = "checked" : $tutorChecked = ""; - } - - $image_array=UserManager::get_user_picture_path_by_id($userIdViewed,'web',false,true); - // get the path,width and height from original picture - $big_image = $image_array['dir'].'big_'.$image_array['file']; - $big_image_size = api_getimagesize($big_image); - $big_image_width= $big_image_size['width']; - $big_image_height= $big_image_size['height']; - $url_big_image = $image_array['file']; - if (!api_get_configuration_value('gravatar_enabled')) { - $url_big_image = $big_image.'?rnd='.time(); - } - - if ($image_array['file']=='unknown.jpg') { - echo ''; - } else { - echo ''; - } - - echo "
    \n", - "\n", - "
    ", - "\n", - "\n", - "\n"; - - if ($current_session_id) { - if ($user_info_viewed['status'] == COURSEMANAGER) { - echo "\n"; - } - } else { - if ($user_info_viewed['status'] == STUDENT) { - echo "\n"; - } else { - echo "\n"; - } - } - - echo "\n", - "", - "\n", - ""; - - if (!($is_courseAdmin && $_user['user_id'] == $userIdViewed)) { - if ($current_session_id) { - if ($user_info_viewed['status'] == COURSEMANAGER) { - echo ""; - } - } else { - if ($user_info_viewed['status'] == STUDENT) { - echo ""; - } else { - echo "\n"; - } - } - } else { - echo "\n"; - - - } - - - echo "\n", "", "
    ", get_lang('Name'), "", get_lang('Description'), "", get_lang('Tutor'), "", get_lang('CourseAssistant'), "", get_lang('CourseManager'), "
    ", htmlize(api_get_person_name($mainUserInfo['firstName'], $mainUserInfo['lastName'])), "" . ' ' . Display::return_icon('synthese_view.gif',get_lang('TheTutorOnlyCanKeepTrackOfStudentsRegisteredInTheCourse')),$checked,"" . ' ' . Display::return_icon('synthese_view.gif',get_lang('TheTeacherCanQualifyEvaluateAndKeepTrackOfAllStudentsEnrolledInTheCourse')),$checked,"", get_lang('CourseManager'), "
    ", "\n"; - - if (api_get_setting('show_email_addresses') == 'true') { - echo "

    ".Display :: encrypted_mailto_link($mainUserInfo['email'], $mainUserInfo['email'])."

    "; - } - - if (api_get_setting('extended_profile') == 'true') { - if (!empty($mainUserInfo['competences'])) - echo '
    '.get_lang('MyCompetences').'
    '.$mainUserInfo['competences'].'
    '; - if (!empty($mainUserInfo['diplomas'])) - echo '
    '.get_lang('MyDiplomas').'
    '.$mainUserInfo['diplomas'].'
    '; - if (!empty($mainUserInfo['teach'])) - echo '
    '.get_lang('MyTeach').'
    '.$mainUserInfo['teach'].'
    '; - if (!empty($mainUserInfo['openarea'])) - echo '
    '.get_lang('MyPersonalOpenArea').'
    '.$mainUserInfo['openarea'].'
    '; - if (!empty($mainUserInfo['competences'])) - echo '
    '.get_lang('MyProductions').'
    '.UserManager::build_production_list($mainUserInfo['user_id']).'
    '; - } - } else { - Display :: display_normal_message(get_lang('ThisStudentIsSubscribeThroughASession')); - } -} elseif ($displayMode == "viewContentList") { - // default display - $virtual_course_code = $_GET["virtual_course"]; - if (isset ($virtual_course_code)) { - $courseCode = $virtual_course_code; - //not supported yet: editing users of virtual courses - $allowedToEditDef = false; - } - - $mainUserInfo = get_main_user_info($userIdViewed, $courseCode); - - if ($mainUserInfo) { - $image_array=UserManager::get_user_picture_path_by_id($userIdViewed,'web',false,true); - // get the path,width and height from original picture - $big_image = $image_array['dir'].'big_'.$image_array['file']; - $big_image_size = api_getimagesize($big_image); - $big_image_width= $big_image_size['width']; - $big_image_height= $big_image_size['height']; - $url_big_image = $image_array['file']; - if (!api_get_configuration_value('gravatar_enabled')) { - $url_big_image = $big_image.'?rnd='.time(); - } - if ($image_array['file']=='unknown.jpg') { - echo ''; - } else { - echo ''; - } - - // is the user online? - $online =''; - if (user_is_online($userIdViewed)) { - $online = Display::return_icon('online.gif', get_lang('OnLine'),array('style'=>'with="8"; height="8"')); - } - - //DISPLAY TABLE HEADING - if ($origin == 'learnpath') { $allowedToEditDef=false; $is_allowedToTrack=false; } - - //"",get_lang('Tutor'),"\n", - echo "", - - "\n", - "\n", - "\n"; - - if ($current_session_id) { - if ($user_info_viewed['status'] == COURSEMANAGER) { - echo "\n"; - } - } else { - if ($user_info_viewed['status'] == STUDENT) { - echo "\n"; - } else { - echo "\n"; - } - } - //echo ($allowedToEditDef && api_get_setting('allow_user_course_subscription_by_course_admin') == 'true'?"\n":""); - //echo ($is_allowedToTrack?"\n":""); - - echo "\n", - "\n", - - "\n", - ""; - - //DISPLAY TABLE CONTENT - - if ($current_session_id) { - if ($user_info_viewed['status'] == COURSEMANAGER) { - if ($is_session_course_coach) { - echo "\n"; - } else { - echo "\n"; - } - } - } else { - if ($user_info_viewed['status'] == STUDENT) { - if ($mainUserInfo['tutor_id'] == 1) { - echo "\n"; - } else { - echo "\n"; - } - } else { - if ($mainUserInfo['status'] == 1) { - echo ""; - } else { - echo "\n"; - } - } - } - - if ($allowedToEditDef && api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') { - //echo ""; - } - if ($is_allowedToTrack) { - //echo ""; - } - echo "
    ".get_lang('Name')."".get_lang('Description')."".get_lang('Tutor')."".get_lang('Tutor')."".get_lang('CourseManager')."".get_lang('Edit')."".get_lang('Tracking')."
    ".$online.' '.htmlize(api_get_person_name($mainUserInfo['firstName'], $mainUserInfo['lastName']))."".htmlize($mainUserInfo['role'])."",get_lang('Tutor')," - ",get_lang('Tutor')," - ",get_lang('CourseManager')," - "; - //echo "\"\""; - //echo ""; - //echo "\"".get_lang('Tracking').""; - //echo "
    "; - - if (api_get_setting("show_email_addresses") == "true") { - echo "

    ". Display::encrypted_mailto_link($mainUserInfo['email'],$mainUserInfo['email']). "

    "; - } - - if (api_get_setting('extended_profile') == 'true') { - if (!empty($mainUserInfo['competences'])) - echo '
    '.get_lang('MyCompetences').'
    '.$mainUserInfo['competences'].'
    '; - if (!empty($mainUserInfo['diplomas'])) - echo '
    '.get_lang('MyDiplomas').'
    '.$mainUserInfo['diplomas'].'
    '; - if (!empty($mainUserInfo['teach'])) - echo '
    '.get_lang('MyTeach').'
    '.$mainUserInfo['teach'].'
    '; - if (!empty($mainUserInfo['openarea'])) - echo '
    '.get_lang('MyPersonalOpenArea').'
    '.$mainUserInfo['openarea'].'
    '; - if (!empty($mainUserInfo['competences'])) - echo '
    '.get_lang('MyProductions').'
    '.UserManager::build_production_list($mainUserInfo['user_id']).'
    '; - } - } else { - Display :: display_normal_message(get_lang('ThisStudentIsSubscribeThroughASession')); - } - - if (api_get_setting('allow_user_headings') == 'true' && $allowedToEditDef) // only course administrators see this line - { - echo "
    ", - "
    ", - get_lang('CourseAdministratorOnly')," : ", - "", - "
    ", - "
    ", - "
    \n"; - } - - $catList = get_course_user_info($userIdViewed); - - if ($catList) - { - foreach ($catList as $thisCat) - { - // Category title - - echo "

    ",$thisCat['title'],"

    \n"; - - // Category content - - echo "
    \n"; - - if ($thisCat['content']) - { - echo htmlize($thisCat['content'])."\n"; - } - else - { - echo "...."; - } - - // Edit command - - if ($allowedToEditContent) - { - echo "

    \n", - "", - "\"edit\"", - "\n"; - } - - echo "
    \n"; - } - } -} - -// Back button for each display mode (bottom) -//echo "\n"; -/* FOOTER */ -Display :: display_footer(); diff --git a/main/user/userInfoLib.php b/main/user/userInfoLib.php deleted file mode 100755 index 4384eef96b..0000000000 --- a/main/user/userInfoLib.php +++ /dev/null @@ -1,586 +0,0 @@ - - * @author - Christophe Gesch� - * @param - string $title - category title - * @param - string $comment - title comment - * @param - int$nbline - lines number for the field the user will fill. - * @return - bollean true if succeed, else bolean false - */ - -function create_cat_def($title="", $comment="", $nbline="5") -{ - global $TBL_USERINFO_DEF; //taken from userInfo.php - - $title = Database::escape_string(trim($title)); - $comment = Database::escape_string(trim($comment)); - $nbline = strval(intval($nbline)); - - if ( 0 == (int) $nbline || empty($title)) - { - return false; - } - - $sql = "SELECT MAX(rank) as maxRank FROM ".$TBL_USERINFO_DEF; - $result = Database::query($sql); - if ($result) $maxRank = Database::fetch_array($result); - - $maxRank = $maxRank['maxRank']; - - $thisRank = $maxRank + 1; - - $sql = "INSERT INTO $TBL_USERINFO_DEF SET - title = '$title', - comment = '$comment', - line_count = '$nbline', - rank = '$thisRank'"; - - Database::query($sql); - - return true; -} - -/** - * modify the definition of a user information category - * - * @author - Hugues peeters - * @author - Christophe Gesch� - * @param - int $id - id of the category - * @param - string $title - category title - * @param - string $comment - title comment - * @param - int$nbline - lines number for the field the user will fill. - * @return - boolean true if succeed, else otherwise - */ - -function edit_cat_def($id, $title, $comment, $nbline) -{ - global $TBL_USERINFO_DEF; - - if ( 0 == $nbline || 0 == $id ) - { - return false; - } - $id = strval(intval($id)); //make sure id is integer - $title = Database::escape_string(trim($title)); - $comment = Database::escape_string(trim($comment)); - $nbline = strval(intval($nbline)); - - $sql = "UPDATE ".$TBL_USERINFO_DEF." SET - title = '$title', - comment = '$comment', - line_count = '$nbline' - WHERE id = '$id'"; - Database::query($sql); - - return true; -} - -/** - * remove a category from the category list - * - * @author - Hugues peeters - * @author - Christophe Gesche - * - * @param - int $id - id of the category - * or "ALL" for all category - * @param - boolean $force - FALSE (default) : prevents removal if users have - * already fill this category - * TRUE : bypass user content existence check - * @param - int $nbline - lines number for the field the user will fill. - * @return - bollean - TRUE if succeed, ELSE otherwise - */ - -function remove_cat_def($id, $force = false) -{ - $TBL_USERINFO_DEF = Database :: get_course_table(TABLE_USER_INFO); - $TBL_USERINFO_CONTENT = Database :: get_course_table(TABLE_USER_INFO_CONTENT); - - $id = strval(intval($id)); - - if ( (0 == (int) $id || $id == "ALL") || ! is_bool($force)) - { - return false; - } - $sqlCondition = " WHERE id = '$id'"; - if (!$force) - { - $sql = "SELECT * FROM $TBL_USERINFO_CONTENT $sqlCondition"; - $result = Database::query($sql); - - if ( Database::num_rows($result) > 0) - { - return false; - } - } - $sql = "DELETE FROM $TBL_USERINFO_DEF $sqlCondition"; - Database::query($sql); -} - -/** - * move a category in the category list - * - * @author - Hugues peeters - * @author - Christophe Gesch� - * - * @param - int $id - id of the category - * @param - direction "up" or "down" : - * "up" decrease the rank of gived $id by switching rank with the just lower - * "down" increase the rank of gived $id by switching rank with the just upper - * - * @return - boolean true if succeed, else bolean false - */ - -function move_cat_rank($id, $direction) // up & down. -{ - $TBL_USERINFO_DEF = Database :: get_course_table(TABLE_USER_INFO); - $id = strval(intval($id)); - - if ( 0 == (int) $id || ! ($direction == "up" || $direction == "down") ) - { - return false; - } - - $sql = "SELECT rank FROM $TBL_USERINFO_DEF WHERE id = '$id'"; - $result = Database::query($sql); - - if (Database::num_rows($result) < 1) - { - return false; - } - - $cat = Database::fetch_array($result); - $rank = (int) $cat['rank']; - return move_cat_rank_by_rank($rank, $direction); -} - -/** - * move a category in the category list - * - * @author - Hugues peeters - * @author - Christophe Gesche - * - * @param - int $rank - actual rank of the category - * @param - direction "up" or "down" : - * "up" decrease the rank of gived $rank by switching rank with the just lower - * "down" increase the rank of gived $rank by switching rank with the just upper - * - * @return - boolean true if succeed, else bolean false - */ - -function move_cat_rank_by_rank($rank, $direction) // up & down. -{ - $TBL_USERINFO_DEF = Database :: get_course_table(TABLE_USER_INFO); - - if ( 0 == (int) $rank || ! ($direction == "up" || $direction == "down") ) - { - return false; - } - - if ($direction == "down") // thus increase rank ... - { - $sort = "ASC"; - $compOp = ">="; - } - else // thus decrease rank ... - { - $sort = "DESC"; - $compOp = "<="; - } - - // this request find the 2 line to be switched (on rank value) - $sql = "SELECT id, rank FROM ".$TBL_USERINFO_DEF." WHERE rank $compOp $rank - ORDER BY rank $sort LIMIT 2"; - - $result = Database::query($sql); - - if (Database::num_rows($result) < 2) - { - return false; - } - - $thisCat = Database::fetch_array($result); - $nextCat = Database::fetch_array($result); - - $sql1 = "UPDATE ".$TBL_USERINFO_DEF." SET rank ='".$nextCat['rank']. - "' WHERE id = '".$thisCat['id']."'"; - $sql2 = "UPDATE ".$TBL_USERINFO_DEF." SET rank ='".$thisCat['rank']. - "' WHERE id = '".$nextCat['id']."'"; - - Database::query($sql1); - Database::query($sql2); - - return true; -} - - -/** - * @author Hugues Peeters - peeters@ipm.ucl.ac.be - * @param int $user_id - * @param string $course_code - * @param array $properties - should contain 'role', 'status', 'tutor_id' - * @return boolean true if succeed false otherwise - */ - -function update_user_course_properties($user_id, $course_code, $properties) -{ - global $tbl_coursUser,$_user; - $sqlChangeStatus = ""; - $user_id = strval(intval($user_id));//filter integer - $course_code = Database::escape_string($course_code); - if ($user_id != $_user['user_id']) - { - $sqlChangeStatus = "status = '".Database::escape_string($properties['status'])."',"; - } - - //feature deprecated tutor_id = '".Database::escape_string($properties['tutor'])."' - $sql = "UPDATE $tbl_coursUser - SET ".$sqlChangeStatus." - role = '".Database::escape_string($properties['role'])."', - tutor_id = '".Database::escape_string($properties['tutor'])."' - WHERE user_id = '".$user_id."' - AND course_code = '".$course_code."'"; - - $result = Database::query($sql); - - if (Database::affected_rows($result) > 0) { - return true; - } else { - return false; - } -} - -/** - * fill a bloc for information category - * - * @author - Hugues peeters - * @author - Christophe Gesche - * @param - $definition_id, - * @param - $user_id, - * @param - $user_ip, - * @param - $content - * @return - boolean true if succeed, else bolean false - */ - -function fill_new_cat_content($definition_id, $user_id, $content="", $user_ip="") -{ - global $TBL_USERINFO_CONTENT; - - if (empty($user_ip)) - { - $user_ip = $_SERVER['REMOTE_ADDR']; - } - $definition_id = strval(intval($definition_id)); - $user_id = strval(intval($user_id)); - $content = Database::escape_string(trim($content)); - $user_ip = Database::escape_string(trim($user_ip)); - - if ( 0 == $definition_id || 0 == $user_id || $content == "") - { - // Here we should introduce an error handling system... - - return false; - } - - // Do not create if already exist - - $sql = "SELECT id FROM ".$TBL_USERINFO_CONTENT." - WHERE definition_id = '$definition_id' - AND user_id = '$user_id'"; - - $result = Database::query($sql); - - if (Database::num_rows($result) > 0) - { - return false; - } - - $sql = "INSERT INTO ".$TBL_USERINFO_CONTENT." SET - content = '$content', - definition_id = '$definition_id', - user_id = '$user_id', - editor_ip = '$user_ip', - edition_time = now()"; - - Database::query($sql); - return true; -} - -/** - * Edit a bloc for information category - * - * @author - Hugues peeters - * @author - Christophe Gesche - * @param - $definition_id, - * @param - $user_id, - * @param - $user_ip, DEFAULT $REMOTE_ADDR - * @param - $content ; if empty call delete the bloc - * @return - boolean true if succeed, else bolean false - */ -function edit_cat_content($definition_id, $user_id, $content ="", $user_ip="") -{ - global $TBL_USERINFO_CONTENT; - $definition_id = strval(intval($definition_id)); - $user_id = strval(intval($user_id)); - $content = Database::escape_string(trim($content)); - if (empty($user_ip)) - { - $user_ip = $_SERVER['REMOTE_ADDR']; - } - $user_ip = Database::escape_string($user_ip); - - if (0 == $user_id || 0 == $definition_id) - { - return false; - } - - if ( $content == "") - { - return cleanout_cat_content($user_id, $definition_id); - } - - - $sql= "UPDATE ".$TBL_USERINFO_CONTENT." SET - content = '$content', - editor_ip = '$user_ip', - edition_time = now() - WHERE definition_id = '$definition_id' AND user_id = '$user_id'"; - - Database::query($sql); - - return true; -} - -/** - * clean the content of a bloc for information category - * - * @author - Hugues peeters - * @author - Christophe Gesche - * @param - $definition_id, - * @param - $user_id - * @return - boolean true if succeed, else bolean false - */ - -function cleanout_cat_content($user_id, $definition_id) -{ - global $TBL_USERINFO_CONTENT; - $user_id = strval(intval($user_id)); - $definition_id = strval(intval($definition_id)); - - if (0 == $user_id || 0 == $definition_id) - { - return false; - } - - $sql = "DELETE FROM ".$TBL_USERINFO_CONTENT." - WHERE user_id = '$user_id' AND definition_id = '$definition_id'"; - - Database::query($sql); - - return true; -} - - - -/*---------------------------------------- - SHOW USER INFORMATION TREATMENT - --------------------------------------*/ - -/** - * get the user info from the user id - * @author - Hugues Peeters - * @author - Christophe Gesche - * @param - int $user_id user id as stored in the Dokeos main db - * @return - array containg user info sort by categories rank - * each rank contains 'title', 'comment', 'content', 'cat_id' - */ - - -function get_course_user_info($user_id) -{ - $TBL_USERINFO_DEF = Database :: get_course_table(TABLE_USER_INFO); - $TBL_USERINFO_CONTENT = Database :: get_course_table(TABLE_USER_INFO_CONTENT); - - $sql = "SELECT cat.id catId, cat.title, - cat.comment , content.content - FROM ".$TBL_USERINFO_DEF." cat LEFT JOIN ".$TBL_USERINFO_CONTENT." content - ON cat.id = content.definition_id AND content.user_id = '$user_id' - ORDER BY cat.rank, content.id"; - - $result = Database::query($sql); - - if (Database::num_rows($result) > 0) - { - while ($userInfo = Database::fetch_array($result, 'ASSOC')) - { - $userInfos[]=$userInfo; - } - - return $userInfos; - } - - return false; -} - - - -/** - * get the main user information - * @author - Hugues Peeters - * @author - Christophe Gesche - * @param - int $user_id user id as stored in the Dokeos main db - * @return - array containing user info as 'lastName', 'firstName' - * 'email', 'role' - */ - -function get_main_user_info($user_id, $courseCode) -{ - $user_id = strval(intval($user_id)); - $courseCode = Database::escape_string($courseCode); - if (0 == $user_id) - { - return false; - } - - - $table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); - $table_user = Database::get_main_table(TABLE_MAIN_USER); - $sql = "SELECT u.*, u.lastname lastName, u.firstname firstName, - u.email, u.picture_uri picture, cu.role, - cu.status status, cu.tutor_id - FROM $table_user u, $table_course_user cu - WHERE u.user_id = cu.user_id AND cu.relation_type<>".COURSE_RELATION_TYPE_RRHH." - AND u.user_id = '$user_id' - AND cu.course_code = '$courseCode'"; - - $result = Database::query($sql); - - if (Database::num_rows($result) > 0) - { - $userInfo = Database::fetch_array($result, 'ASSOC'); - $userInfo['password']=''; - return $userInfo; - } - - return false; -} - - - - -/** - * get the user content of a categories plus the categories definition - * @author - Hugues Peeters - * @author - Christophe Gesche - * @param - int $userId - id of the user - * @param - int $catId - id of the categories - * @return - array containing 'catId', 'title', 'comment', - * 'nbline', 'contentId' and 'content' - */ - -function get_cat_content($userId, $catId) -{ - $TBL_USERINFO_DEF = Database :: get_course_table(TABLE_USER_INFO); - $TBL_USERINFO_CONTENT = Database :: get_course_table(TABLE_USER_INFO_CONTENT); - - $userId = strval(intval($userId)); - $catId = strval(intval($catId)); - $sql = "SELECT cat.id catId, cat.title, - cat.comment , cat.line_count, - content.id contentId, content.content - FROM ".$TBL_USERINFO_DEF." cat LEFT JOIN ".$TBL_USERINFO_CONTENT." content - ON cat.id = content.definition_id - AND content.user_id = '$userId' - WHERE cat.id = '$catId' "; - $result = Database::query($sql); - - if (Database::num_rows($result) > 0) - { - $catContent = Database::fetch_array($result, 'ASSOC'); - $catContent['nbline'] = $catContent['line_count']; - return $catContent; - } - - return false; -} - - -/** - * get the definition of a category - * - * @author - Christophe Gesche - * @author - Hugues Peeters - * @param - int $catId - id of the categories - * @return - array containing 'id', 'title', 'comment', and 'nbline', - */ -function get_cat_def($catId) -{ - $TBL_USERINFO_DEF = Database :: get_course_table(TABLE_USER_INFO); - - $catId = strval(intval($catId)); - $sql = "SELECT id, title, comment, line_count, rank FROM ".$TBL_USERINFO_DEF." WHERE id = '$catId'"; - - $result = Database::query($sql); - - if (Database::num_rows($result) > 0) - { - $catDef = Database::fetch_array($result, 'ASSOC'); - $catDef['nbline'] = $catDef['line_count']; - return $catDef; - } - - return false; -} - - -/** - * get list of all this course categories - * - * @author - Christophe Gesche - * @author - Hugues Peeters - * @return - array containing a list of arrays. - * And each of these arrays contains - * 'catId', 'title', 'comment', and 'nbline', - */ -function get_cat_def_list() -{ - $TBL_USERINFO_DEF = Database :: get_course_table(TABLE_USER_INFO); - - $sql = "SELECT id catId, title, comment , line_count - FROM ".$TBL_USERINFO_DEF." - ORDER BY rank"; - - $result = Database::query($sql); - - if (Database::num_rows($result) > 0) - { - while ($cat_def = Database::fetch_array($result, 'ASSOC')) - { - $cat_def_list[]=$cat_def; - } - - return $cat_def_list; - } - - return false; -} - -/** - * transform content in a html display - * @author - Hugues Peeters - * @param - string $string string to htmlize - * @ return - string htmlized - */ - -function htmlize($phrase) -{ - global $charset; - return nl2br(htmlspecialchars($phrase,ENT_QUOTES,$charset)); -} diff --git a/main/user/user_add.php b/main/user/user_add.php deleted file mode 100755 index f00c2af9d8..0000000000 --- a/main/user/user_add.php +++ /dev/null @@ -1,375 +0,0 @@ -"; - $emailfromaddr = $administratorEmail; - $emailfromname = api_get_setting('siteName'); - $emailsubject = get_lang('YourReg').' '.api_get_setting('siteName'); - - $emailheaders = "From: ".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS)." <".$administratorEmail.">\n"; - $emailheaders .= "Reply-To: ".$administratorEmail."\n"; - $emailheaders .= "Return-Path: ".$administratorEmail."\n"; - $emailheaders .= "charset: ".api_get_system_encoding()."\n"; - $emailheaders .= "X-Mailer: PHP/" . phpversion() . "\n"; - $emailheaders .= "X-Sender-IP: $REMOTE_ADDR"; // (small security precaution...) - $recipient_name = api_get_person_name($firstname_form, $lastname_form, null, PERSON_NAME_EMAIL_ADDRESS); - $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); - $email_admin = api_get_setting('emailAdministrator'); - - $portal_url = $_configuration['root_web']; - if ($_configuration['multiple_access_urls']) { - $access_url_id = api_get_current_access_url_id(); - if ($access_url_id != -1 ){ - $url = api_get_access_url($access_url_id); - $portal_url = $url['url']; - } - } - - if ($courseRegSucceed) - { - $emailbody = get_lang('Dear')." ".stripslashes(api_get_person_name($firstname_form, $lastname_form)).",\n".get_lang('OneResp')." $currentCourseName ".get_lang('RegYou')." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : $username_form\n".get_lang('Pass').": $password_form\n".get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is').": ".$portal_url."\n".get_lang('Problem')."\n".get_lang('SignatureFormula').",\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n".get_lang('Manager')." ".api_get_setting('siteName')." \nT. ".api_get_setting('administratorTelephone')."\n".get_lang('Email').": ".api_get_setting('emailAdministrator')."\n"; - $message = get_lang('TheU')." ".stripslashes(api_get_person_name($firstname_form, $lastname_form))." ".get_lang('AddedToCourse')."".get_lang('BackUser')."\n"; - } - else - { - $emailbody = get_lang('Dear')." ".api_get_person_name($firstname_form, $lastname_form).",\n ".get_lang('YouAreReg')." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : $username_form\n".get_lang('Pass').": $password_form\n".get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is').": ".$portal_url."\n".get_lang('Problem')."\n".get_lang('SignatureFormula').",\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n".get_lang('Manager')." ".api_get_setting('siteName')." \nT. ".api_get_setting('administratorTelephone')."\n".get_lang('Email').": ".api_get_setting('emailAdministrator')."\n"; - - $message = stripslashes(api_get_person_name($firstname_form, $lastname_form))." ".get_lang('AddedU'); - } - - $plugin = new AppPlugin(); - $additionalParameters = array( - 'smsType' => constant($plugin->getSMSPluginName().'::BEEN_SUBSCRIBED_COURSE'), - 'userId' => $user_id, - 'courseTitle' => $currentCourseName - ); - - api_mail_html( - $recipient_name, - $email_form, - $emailsubject, - $emailbody, - $sender_name, - $email_admin, - null, - null, - null, - $additionalParameters - ); - - /* - * remove
    variables to prevent any pre-filled fields - */ - - unset($lastname_form, $firstname_form, $username_form, $password_form, $email_form, $admin_form, $tutor_form); - - } // end if ($platformRegSucceed) - //else - //{ - // $message = get_lang('UserAlreadyRegistered'); - //} - -} // end if register request - -$interbreadcrumb[] = array ("url"=>"user.php", "name"=> get_lang('ToolUser')); - -$nameTools = get_lang('AddAU'); - -Display::display_header($nameTools, "User"); - - -?> - - - -

    - - - - - - -

    - - - -. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - -
    :
    :
    :
    :
    :
    :
    :
    :
    : /> - />
    : /> - />
    : - -
     
    -
    - -".get_lang('IfYouWantToAddManyUsers')."

    "; -Display::display_footer(); diff --git a/main/user/user_import.php b/main/user/user_import.php index eb1bc24471..1959e92c54 100755 --- a/main/user/user_import.php +++ b/main/user/user_import.php @@ -43,8 +43,8 @@ if ($form->validate()) { if (isset($_FILES['import_file']['size']) && $_FILES['import_file']['size'] !== 0) { $unsubscribe_users = isset($_POST['unsubscribe_users']) ? true : false; - //@todo : csv_to_array deprecated - $users = Import::csv_to_array($_FILES['import_file']['tmp_name']); + //@todo : csvToArray deprecated + $users = Import::csvToArray($_FILES['import_file']['tmp_name']); $invalid_users = array(); $clean_users = array(); diff --git a/main/webservices/cm_webservice_inbox.php b/main/webservices/cm_webservice_inbox.php index 10bdb55a56..7a42bf8949 100755 --- a/main/webservices/cm_webservice_inbox.php +++ b/main/webservices/cm_webservice_inbox.php @@ -1,9 +1,6 @@ verifyUserPass($username, $password) == "valid") @@ -22,7 +19,7 @@ class WSCMInbox extends WSCM { $condition_msg_status = ' msg_status = 1 '; // define('MESSAGE_STATUS_UNREAD', '1'); $sql_query = "SELECT COUNT(*) as number_messages FROM $table_message WHERE $condition_msg_status AND user_receiver_id=".$user_id; - + $sql_result = Database::query($sql_query); $result = Database::fetch_array($sql_result); return $result['number_messages']; @@ -30,11 +27,11 @@ class WSCMInbox extends WSCM { return "0"; } - + public function get_message_id($username, $password, $from, $number_of_items) - { + { if($this->verifyUserPass($username, $password) == "valid") - { + { $user_id = UserManager::get_user_id_from_username($username); $table_message = Database::get_main_table(TABLE_MESSAGE); @@ -48,7 +45,7 @@ class WSCMInbox extends WSCM { while ($result = Database::fetch_row($sql_result)) { $message .= $result[0]."#"; } - + return $message; } else @@ -84,7 +81,7 @@ class WSCMInbox extends WSCM { break; default : $field_table = "title"; - } + } $table_message = Database::get_main_table(TABLE_MESSAGE); @@ -193,7 +190,7 @@ class WSCMInbox extends WSCM { $query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id, update_date ) ". " VALUES ('$user_sender_id', '$receiver_user_id', '1', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')"; $result = Database::query($query); - + $query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id, update_date ) ". " VALUES ('$user_sender_id', '$receiver_user_id', '4', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')"; $result = Database::query($query); @@ -225,4 +222,4 @@ $aqui = new WSCMInbox(); print_r($aqui->message_send("aluno", "356a192b7913b04c54574d18c28d46e6395428ab", "1", "Título da mensagem", "Conteúdo da mensagem com ç ã")); -*/ \ No newline at end of file +*/ diff --git a/main/webservices/registration.soap.php b/main/webservices/registration.soap.php index a1baeb57bd..62abc1f2b5 100755 --- a/main/webservices/registration.soap.php +++ b/main/webservices/registration.soap.php @@ -331,7 +331,7 @@ function WSCreateUsers($params) { if ($result) { //echo "id returned"; $return = Database::insert_id(); - if ($_configuration['multiple_access_urls']) { + if (api_is_multiple_url_enabled()) { if (api_get_current_access_url_id() != -1) { UrlManager::add_user_to_url($return, api_get_current_access_url_id()); } else { @@ -536,7 +536,7 @@ function WSCreateUser($params) { if ($result) { //echo "id returned"; $return = Database::insert_id(); - if ($_configuration['multiple_access_urls']) { + if (api_is_multiple_url_enabled()) { if (api_get_current_access_url_id() != -1) { UrlManager::add_user_to_url($return, api_get_current_access_url_id()); } else { @@ -827,7 +827,7 @@ function WSCreateUsersPasswordCrypted($params) { if ($result) { //echo "id returned"; $return = Database::insert_id(); - if ($_configuration['multiple_access_urls']) { + if (api_is_multiple_url_enabled()) { if (api_get_current_access_url_id() != -1) { UrlManager::add_user_to_url($return, api_get_current_access_url_id()); } else { @@ -1089,10 +1089,9 @@ function WSCreateUserPasswordCrypted($params) { } } } else { - $error = Database::error(); - if ($debug) error_log($error); return 0; } + return $return; } @@ -2551,9 +2550,8 @@ function WSCreateCourseByTitle($params) { $orig_course_id_value[] = $course_param['original_course_id_value']; $extra_list = $course_param['extra']; - $dbnamelength = strlen($_configuration['db_prefix']); // Ensure the database prefix + database name do not get over 40 characters - $maxlength = 40 - $dbnamelength; + $maxlength = 40; if (empty($wanted_code)) { $wanted_code = CourseManager::generate_course_code(substr($title, 0, $maxlength)); @@ -2745,7 +2743,6 @@ function WSEditCourse($params){ } $course_table = Database::get_main_table(TABLE_MAIN_COURSE); - $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); $t_cfv = Database::get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES); $table_field = Database::get_main_table(TABLE_MAIN_COURSE_FIELD); @@ -2903,7 +2900,6 @@ function WSCourseDescription($params) { } $course_table = Database::get_main_table(TABLE_MAIN_COURSE); - $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); $t_cfv = Database::get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES); $table_field = Database::get_main_table(TABLE_MAIN_COURSE_FIELD); @@ -3068,7 +3064,6 @@ function WSEditCourseDescription($params) { } $course_table = Database::get_main_table(TABLE_MAIN_COURSE); - $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); $t_cfv = Database::get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES); $table_field = Database::get_main_table(TABLE_MAIN_COURSE_FIELD); @@ -3788,11 +3783,11 @@ function WSDeleteSession($params) { $sql_session = "DELETE FROM $tbl_session WHERE id = '$idChecked'"; @Database::query($sql_session); - $sql_session_rel_course = "DELETE FROM $tbl_session_rel_course WHERE id_session = '$idChecked'"; + $sql_session_rel_course = "DELETE FROM $tbl_session_rel_course WHERE session_id = '$idChecked'"; @Database::query($sql_session_rel_course); - $sql_session_rel_course_rel_user = "DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session = '$idChecked'"; + $sql_session_rel_course_rel_user = "DELETE FROM $tbl_session_rel_course_rel_user WHERE session_id = '$idChecked'"; @Database::query($sql_session_rel_course_rel_user); - $sql_session_rel_course = "DELETE FROM $tbl_session_rel_user WHERE id_session = '$idChecked'"; + $sql_session_rel_course = "DELETE FROM $tbl_session_rel_user WHERE session_id = '$idChecked'"; @Database::query($sql_session_rel_course); $results[] = 1; continue; @@ -4254,7 +4249,7 @@ function WSUnsubscribeUserFromCourse($params) { $results = array(); $orig_user_id_value = array(); $orig_course_id_value = array(); - foreach($userscourses_params as $usercourse_param) { + foreach ($userscourses_params as $usercourse_param) { $original_user_id_values = $usercourse_param['original_user_id_values']; $original_user_id_name = $usercourse_param['original_user_id_name']; @@ -4283,17 +4278,22 @@ function WSUnsubscribeUserFromCourse($params) { // Get course code from original course id - $sql_course = "SELECT course_code FROM $table_field cf,$t_cfv cfv WHERE cfv.field_id=cf.id AND field_variable='$original_course_id_name' AND field_value='$original_course_id_value'"; - $res_course = Database::query($sql_course); - $row_course = Database::fetch_row($res_course); + $sql_course = "SELECT course_code FROM $table_field cf,$t_cfv cfv + WHERE cfv.field_id=cf.id AND field_variable='$original_course_id_name' AND field_value='$original_course_id_value'"; + $res_course = Database::query($sql_course); + $row_course = Database::fetch_row($res_course); $course_code = $row_course[0]; + $courseInfo = api_get_course_info($course_code); + $courseId = $courseInfo['real_id']; + if (empty($course_code)) { $results[] = 0; continue; } else { - $sql = "SELECT code FROM $table_course WHERE code ='$course_code' AND visibility = '0'"; + $sql = "SELECT code FROM $table_course + WHERE code ='$course_code' AND visibility = '0'"; $resul = Database::query($sql); $r_check_code = Database::fetch_row($resul); if (!empty($r_check_code[0])) { @@ -4307,9 +4307,8 @@ function WSUnsubscribeUserFromCourse($params) { continue; } - foreach($usersList as $user_id) { - $course_code = Database::escape_string($course_code); - $sql = "DELETE FROM $table_course_user WHERE user_id = '$user_id' AND course_code = '".$course_code."'"; + foreach ($usersList as $user_id) { + $sql = "DELETE FROM $table_course_user WHERE user_id = '$user_id' AND c_id = '".$courseId."'"; $result = Database::query($sql); $return = Database::affected_rows($result); } @@ -4320,7 +4319,11 @@ function WSUnsubscribeUserFromCourse($params) { $count_results = count($results); $output = array(); for($i = 0; $i < $count_results; $i++) { - $output[] = array('original_user_id_values' => $orig_user_id_value[$i],'original_course_id_value' => $orig_course_id_value[$i], 'result' => $results[$i]); + $output[] = array( + 'original_user_id_values' => $orig_user_id_value[$i], + 'original_course_id_value' => $orig_course_id_value[$i], + 'result' => $results[$i] + ); } return $output; @@ -4469,17 +4472,18 @@ function WSSuscribeUsersToSession($params){ continue; } - $sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session='$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH.""; + $sql = "SELECT user_id FROM $tbl_session_rel_user + WHERE session_id='$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH.""; $result = Database::query($sql); $existingUsers = array(); while($row = Database::fetch_array($result)){ - $existingUsers[] = $row['id_user']; + $existingUsers[] = $row['user_id']; } - $sql = "SELECT course_code FROM $tbl_session_rel_course WHERE id_session='$id_session'"; + $sql = "SELECT c_id FROM $tbl_session_rel_course WHERE session_id='$id_session'"; $result=Database::query($sql); $CourseList = array(); while($row = Database::fetch_array($result)) { - $CourseList[] = $row['course_code']; + $CourseList[] = $row['c_id']; } foreach ($CourseList as $enreg_course) { @@ -4491,7 +4495,8 @@ function WSSuscribeUsersToSession($params){ foreach ($usersList as $enreg_user) { if(!in_array($enreg_user, $existingUsers)) { $enreg_user = Database::escape_string($enreg_user); - $insert_sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user) VALUES('$id_session','$enreg_course','$enreg_user')"; + $insert_sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(session_id, c_id, user_id) + VALUES('$id_session', '$enreg_course', '$enreg_user')"; $result = Database::query($insert_sql); if (Database::affected_rows($result)) { $nbr_users++; @@ -4499,11 +4504,14 @@ function WSSuscribeUsersToSession($params){ } } // count users in this session-course relation - $sql = "SELECT COUNT(id_user) as nbUsers FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code='$enreg_course'"; + $sql = "SELECT COUNT(user_id) as nbUsers + FROM $tbl_session_rel_course_rel_user + WHERE session_id = '$id_session' AND c_id='$enreg_course'"; $rs = Database::query($sql); list($nbr_users) = Database::fetch_array($rs); // update the session-course relation to add the users total - $update_sql = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'"; + $update_sql = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users + WHERE session_id='$id_session' AND c_id='$enreg_course'"; Database::query($update_sql); } @@ -4512,7 +4520,7 @@ function WSSuscribeUsersToSession($params){ foreach ($usersList as $enreg_user) { $enreg_user = Database::escape_string($enreg_user); $nbr_users++; - $insert_sql = "INSERT IGNORE INTO $tbl_session_rel_user(id_session, id_user) VALUES('$id_session','$enreg_user')"; + $insert_sql = "INSERT IGNORE INTO $tbl_session_rel_user(session_id, user_id) VALUES('$id_session','$enreg_user')"; Database::query($insert_sql); } // update number of users in the session @@ -4528,7 +4536,11 @@ function WSSuscribeUsersToSession($params){ $count_results = count($results); $output = array(); for($i = 0; $i < $count_results; $i++) { - $output[] = array('original_user_id_values' => $orig_user_id_value[$i], 'original_session_id_value' => $orig_session_id_value[$i], 'result' => $results[$i]); + $output[] = array( + 'original_user_id_values' => $orig_user_id_value[$i], + 'original_session_id_value' => $orig_session_id_value[$i], + 'result' => $results[$i] + ); } return $output; @@ -4743,17 +4755,18 @@ function WSUnsuscribeUsersFromSession($params) { continue; } - $sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session='$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH.""; + $sql = "SELECT user_id FROM $tbl_session_rel_user + WHERE session_id ='$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH.""; $result = Database::query($sql); $existingUsers = array(); while($row = Database::fetch_array($result)){ - $existingUsers[] = $row['id_user']; + $existingUsers[] = $row['user_id']; } - $sql = "SELECT course_code FROM $tbl_session_rel_course WHERE id_session='$id_session'"; + $sql = "SELECT c_id FROM $tbl_session_rel_course WHERE session_id='$id_session'"; $result = Database::query($sql); $CourseList = array(); - while($row = Database::fetch_array($result)) { - $CourseList[] = $row['course_code']; + while ($row = Database::fetch_array($result)) { + $CourseList[] = $row['c_id']; } foreach ($CourseList as $enreg_course) { @@ -4764,7 +4777,7 @@ function WSUnsuscribeUsersFromSession($params) { foreach ($existingUsers as $existing_user) { if (!in_array($existing_user, $usersList)) { $sql = "DELETE FROM $tbl_session_rel_course_rel_user - WHERE id_session='$id_session' AND course_code='$enreg_course' AND id_user='$existing_user'"; + WHERE session_id ='$id_session' AND c_id='$enreg_course' AND user_id='$existing_user'"; $result = Database::query($sql); if (Database::affected_rows($result)) { @@ -4773,14 +4786,14 @@ function WSUnsuscribeUsersFromSession($params) { } } // Count users in this session-course relation. - $sql = "SELECT COUNT(id_user) as nbUsers + $sql = "SELECT COUNT(user_id) as nbUsers FROM $tbl_session_rel_course_rel_user - WHERE id_session='$id_session' AND course_code='$enreg_course'"; + WHERE session_id = '$id_session' AND c_id='$enreg_course'"; $rs = Database::query($sql); list($nbr_users) = Database::fetch_array($rs); // update the session-course relation to add the users total $update_sql = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users - WHERE id_session='$id_session' AND course_code='$enreg_course'"; + WHERE session_id ='$id_session' AND c_id ='$enreg_course'"; Database::query($update_sql); } @@ -4788,7 +4801,10 @@ function WSUnsuscribeUsersFromSession($params) { foreach ($usersList as $enreg_user) { $enreg_user = Database::escape_string($enreg_user); $delete_sql = "DELETE FROM $tbl_session_rel_user - WHERE id_session = '$id_session' AND id_user ='$enreg_user' AND relation_type<>".SESSION_RELATION_TYPE_RRHH.""; + WHERE + session_id = '$id_session' AND + user_id = '$enreg_user' AND + relation_type<>".SESSION_RELATION_TYPE_RRHH.""; $result = Database::query($delete_sql); $return = Database::affected_rows($result); } @@ -4973,14 +4989,18 @@ function WSSuscribeCoursesToSession($params) { $orig_session_id_value = array(); foreach ($coursessessions_params as $coursesession_param) { - $original_session_id_value = $coursesession_param['original_session_id_value']; - $original_session_id_name = $coursesession_param['original_session_id_name']; - $original_course_id_name = $coursesession_param['original_course_id_name']; - $original_course_id_values = $coursesession_param['original_course_id_values']; - $orig_session_id_value[] = $original_session_id_value; + $original_session_id_value = $coursesession_param['original_session_id_value']; + $original_session_id_name = $coursesession_param['original_session_id_name']; + $original_course_id_name = $coursesession_param['original_course_id_name']; + $original_course_id_values = $coursesession_param['original_course_id_values']; + $orig_session_id_value[] = $original_session_id_value; // get session id from original session id - $sql_session = "SELECT session_id FROM $t_sf sf,$t_sfv sfv WHERE sfv.field_id=sf.id AND field_variable='$original_session_id_name' AND field_value='$original_session_id_value'"; + $sql_session = "SELECT session_id FROM $t_sf sf,$t_sfv sfv + WHERE + sfv.field_id=sf.id AND + field_variable='$original_session_id_name' AND + field_value='$original_session_id_value'"; if ($debug) error_log($sql_session); $res_session = Database::query($sql_session); @@ -4994,25 +5014,31 @@ function WSSuscribeCoursesToSession($params) { } // Get course list from row_original_course_id_values - $course_list = array(); + $course_list = []; + $courseCodeList = []; foreach ($original_course_id_values as $row_original_course_list) { $course_code = Database::escape_string($row_original_course_list['course_code']); - $sql_course = "SELECT course_code FROM $t_cf cf, $t_cfv cfv WHERE cfv.field_id=cf.id AND field_variable='$original_course_id_name' AND field_value = '$course_code'"; + $sql_course = "SELECT course_code FROM $t_cf cf, $t_cfv cfv + WHERE cfv.field_id=cf.id AND field_variable='$original_course_id_name' AND field_value = '$course_code'"; $res_course = Database::query($sql_course); $row_course = Database::fetch_row($res_course); + $courseId = null; if (empty($row_course[0])) { continue; // course_code doesn't exist. } else { - $sql = "SELECT code FROM $tbl_course WHERE code ='".$row_course[0]."' AND visibility = '0'"; + $sql = "SELECT id FROM $tbl_course WHERE code ='".$row_course[0]."' AND visibility = '0'"; $resu = Database::query($sql); $r_check_course = Database::fetch_row($resu); if (!empty($r_check_course[0])) { continue; // user_id is not active. } + $courseInfo = api_get_course_info($row_course[0]); + $courseId = $courseInfo['real_id']; } - $course_list[] = $row_course[0]; + $courseCodeList[] = $row_course[0]; + $course_list[] = $courseId; } if (empty($course_list)) { @@ -5020,7 +5046,7 @@ function WSSuscribeCoursesToSession($params) { continue; } - $orig_course_id_value[] = implode(',', $course_list); + $orig_course_id_value[] = implode(',', $courseCodeList); // Get general coach ID $sql = "SELECT id_coach FROM $tbl_session WHERE id='$id_session'"; @@ -5029,17 +5055,17 @@ function WSSuscribeCoursesToSession($params) { $id_coach = $id_coach[0]; // get list of courses subscribed to this session - $sql = "SELECT course_code FROM $tbl_session_rel_course WHERE id_session='$id_session'"; + $sql = "SELECT c_id FROM $tbl_session_rel_course WHERE session_id ='$id_session'"; $rs = Database::query($sql); $existingCourses = Database::store_result($rs); - $nbr_courses=count($existingCourses); + $nbr_courses = count($existingCourses); // get list of users subscribed to this session - $sql= "SELECT id_user FROM $tbl_session_rel_user - WHERE id_session = '$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH.""; - $result=Database::query($sql); - $user_list=Database::store_result($result); + $sql= "SELECT user_id FROM $tbl_session_rel_user + WHERE session_id = '$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH.""; + $result = Database::query($sql); + $user_list = Database::store_result($result); $course_directory = array(); // Pass through the courses list we want to add to the session. @@ -5049,7 +5075,7 @@ function WSSuscribeCoursesToSession($params) { // Check if the course we want to add is already subscribed. foreach ($existingCourses as $existingCourse) { - if ($enreg_course == $existingCourse['course_code']) { + if ($enreg_course == $existingCourse['c_id']) { $exists = true; } } @@ -5057,27 +5083,28 @@ function WSSuscribeCoursesToSession($params) { if (!$exists) { // if the course isn't subscribed yet - $sql_insert_rel_course= "INSERT INTO $tbl_session_rel_course (id_session,course_code) VALUES ('$id_session','$enreg_course')"; - Database::query($sql_insert_rel_course); + $sql = "INSERT INTO $tbl_session_rel_course (session_id, c_id) VALUES ('$id_session','$enreg_course')"; + Database::query($sql); // We add the current course in the existing courses array, to avoid adding another time the current course - $existingCourses[] = array('course_code' => $enreg_course); + $existingCourses[] = array('c_id' => $enreg_course); $nbr_courses++; // subscribe all the users from the session to this course inside the session $nbr_users = 0; foreach ($user_list as $enreg_user) { - $enreg_user_id = Database::escape_string($enreg_user['id_user']); - $sql_insert = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user (id_session,course_code,id_user) VALUES ('$id_session','$enreg_course','$enreg_user_id')"; - $result = Database::query($sql_insert); + $enreg_user_id = Database::escape_string($enreg_user['user_id']); + $sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user (session_id, c_id, user_id) + VALUES ('$id_session','$enreg_course','$enreg_user_id')"; + $result = Database::query($sql); if (Database::affected_rows($result)) { $nbr_users++; } } - Database::query("UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'"); + Database::query("UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE session_id='$id_session' AND c_id='$enreg_course'"); - $sql_directory = "SELECT directory FROM $tbl_course WHERE code = '$enreg_course'"; + $sql_directory = "SELECT directory FROM $tbl_course WHERE id = '$enreg_course'"; $res_directory = Database::query($sql_directory); $row_directory = Database::fetch_row($res_directory); $course_directory[] = $row_directory[0]; @@ -5094,7 +5121,11 @@ function WSSuscribeCoursesToSession($params) { $count_results = count($results); $output = array(); for ($i = 0; $i < $count_results; $i++) { - $output[] = array('original_course_id_values' => $orig_course_id_value[$i], 'original_session_id_value' => $orig_session_id_value[$i], 'result' => $results[$i]); + $output[] = array( + 'original_course_id_values' => $orig_course_id_value[$i], + 'original_session_id_value' => $orig_session_id_value[$i], + 'result' => $results[$i] + ); } return $output; } @@ -5218,12 +5249,15 @@ function WSUnsuscribeCoursesFromSession($params) { // Get courses list from row_original_course_id_values $course_list = array(); + $courseIdList = []; foreach ($original_course_id_values as $row_original_course_list) { $course_code = Database::escape_string($row_original_course_list['course_code']); - $sql_course = "SELECT course_code FROM $t_cf cf,$t_cfv cfv WHERE cfv.field_id=cf.id AND field_variable='$original_course_id_name' AND field_value = '$course_code'"; + $sql_course = "SELECT course_code FROM $t_cf cf,$t_cfv cfv + WHERE cfv.field_id=cf.id AND field_variable='$original_course_id_name' AND field_value = '$course_code'"; $res_course = Database::query($sql_course); $row_course = Database::fetch_row($res_course); + $courseId = null; if (empty($row_course[0])) { continue; // Course_code doesn't exist' } else { @@ -5233,8 +5267,10 @@ function WSUnsuscribeCoursesFromSession($params) { if (!empty($r_check_course[0])) { continue; // user_id is not active. } + $courseId = $row_course[0]; } $course_list[] = $row_course[0]; + $courseIdList[] = $courseId; } if (empty($course_list)) { @@ -5244,10 +5280,10 @@ function WSUnsuscribeCoursesFromSession($params) { $orig_course_id_value[] = implode(',', $course_list); - foreach ($course_list as $enreg_course) { - $enreg_course = Database::escape_string($enreg_course); - Database::query("DELETE FROM $tbl_session_rel_course WHERE course_code='$enreg_course' AND id_session='$id_session'"); - $result = Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE course_code='$enreg_course' AND id_session='$id_session'"); + foreach ($courseIdList as $courseId) { + $courseId = intval($courseId); + Database::query("DELETE FROM $tbl_session_rel_course WHERE c_id ='$courseId' AND session_id='$id_session'"); + $result = Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE c_id='$courseId' AND session_id = '$id_session'"); $return = Database::affected_rows($result); } diff --git a/main/webservices/user_import/import.lib.php b/main/webservices/user_import/import.lib.php index 694c0ba0c2..fa6d0d384d 100755 --- a/main/webservices/user_import/import.lib.php +++ b/main/webservices/user_import/import.lib.php @@ -93,9 +93,9 @@ function save_data($users) { if(is_array($users)) { foreach ($users as $index => $user) { $user = complete_missing_data($user); - + $user['Status'] = api_status_key($user['Status']); - + $user_id = UserManager :: create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], api_get_setting('PlatformLanguage'), $user['PhoneNumber'], '', $user['AuthSource']); foreach ($user['Courses'] as $index => $course) { if(CourseManager :: course_exists($course)) @@ -105,24 +105,24 @@ function save_data($users) { $class_id = ClassManager :: get_class_id($user['ClassName']); ClassManager :: add_user($user_id, $class_id); } - + // TODO: Hard-coded French texts. - + // Qualite if (!empty($user['Qualite'])) { UserManager::update_extra_field_value($user_id, 'qualite', $user['Qualite']); } - + // Categorie if (!empty($user['Categorie'])) { UserManager::update_extra_field_value($user_id, 'categorie', $user['Categorie']); } - + // Etat if (!empty($user['Etat'])) { UserManager::update_extra_field_value($user_id, 'etat', $user['Etat']); } - + // Niveau if (!empty($user['Niveau'])) { UserManager::update_extra_field_value($user_id, 'niveau', $user['Niveau']); @@ -137,7 +137,7 @@ function save_data($users) { * @return array All userinformation read from the file */ function parse_csv_data($file) { - $users = Import :: csv_to_array($file); + $users = Import :: csvToArray($file); foreach ($users as $index => $user) { if (isset ($user['Courses'])) { $user['Courses'] = explode('|', trim($user['Courses'])); diff --git a/main/webservices/webservice_session.php b/main/webservices/webservice_session.php index 02df801b90..a50a649bf8 100755 --- a/main/webservices/webservice_session.php +++ b/main/webservices/webservice_session.php @@ -112,7 +112,7 @@ class WSSession extends WS if($session_id instanceof WSError) { return $session_id; } else { - SessionManager::delete_session($session_id, true); + SessionManager::delete($session_id, true); return true; } } @@ -315,8 +315,7 @@ class WSSession extends WS return $course_id; } else { if($state == 1) { - $course_code = CourseManager::get_course_code_from_course_id($course_id); - SessionManager::add_courses_to_session($session_id, array($course_code)); + SessionManager::add_courses_to_session($session_id, array($course_id)); return true; } else { $result = SessionManager::unsubscribe_course_from_session($session_id, $course_id); diff --git a/main/wiki/wiki.inc.php b/main/wiki/wiki.inc.php index 32b428eeea..4e8e9028fc 100755 --- a/main/wiki/wiki.inc.php +++ b/main/wiki/wiki.inc.php @@ -1,7 +1,7 @@ 0) { + $sql = "UPDATE $tbl_wiki SET id = iid WHERE iid = $id"; + Database::query($sql); + //insert into item_property api_item_property_update( api_get_course_info(), @@ -343,14 +346,21 @@ class Wiki } if ($_clean['page_id'] == 0) { - $sql='UPDATE '.$tbl_wiki.' SET page_id="'.$id.'" WHERE c_id = '.$course_id.' AND id="'.$id.'"'; + $sql = 'UPDATE '.$tbl_wiki.' SET page_id="'.$id.'" + WHERE c_id = '.$course_id.' AND id="'.$id.'"'; Database::query($sql); } //update wiki config if ($values['reflink'] == 'index' && $_clean['version'] == 1 ) { $sql = "INSERT INTO ".$tbl_wiki_conf." (c_id, page_id, task, feedback1, feedback2, feedback3, fprogress1, fprogress2, fprogress3, max_text, max_version, startdate_assig, enddate_assig, delayedsubmit) - VALUES ($course_id, '".$id."','".$_clean['task']."','".$_clean['feedback1']."','".$_clean['feedback2']."','".$_clean['feedback3']."','".$_clean['fprogress1']."','".$_clean['fprogress2']."','".$_clean['fprogress3']."','".$_clean['max_text']."','".$_clean['max_version']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['delayedsubmit']."')"; + VALUES ($course_id, '".$id."','".$_clean['task']."','".$_clean['feedback1']."','".$_clean['feedback2']."','".$_clean['feedback3']."','".$_clean['fprogress1']."','".$_clean['fprogress2']."','".$_clean['fprogress3']."','".$_clean['max_text']."','".$_clean['max_version']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['delayedsubmit']."')"; + Database::query($sql); + + $confId = Database::insert_id(); + + $sql = "UPDATE $tbl_wiki_conf SET page_id = $confId WHERE iid = $confId"; + Database::query($sql); } else { $sql = 'UPDATE '.$tbl_wiki_conf.' SET task="'.$_clean['task'].'", @@ -368,9 +378,10 @@ class Wiki WHERE page_id = "'.$_clean['page_id'].'" AND c_id = '.$course_id; + Database::query($sql); } - Database::query($sql); + api_item_property_update($_course, 'wiki', $id, 'WikiAdded', api_get_user_id(), $groupId); self::check_emailcue($_clean['reflink'], 'P', $dtime, $_clean['user_id']); $this->setWikiData($id); @@ -419,8 +430,21 @@ class Wiki Database::query($sql); $id = Database::insert_id(); - api_item_property_update($_course, 'wiki', $id, 'WikiAdded', api_get_user_id(), $r_group_id); - self::check_emailcue($r_reflink, 'P', $r_dtime, $r_user_id); + + if ($id) { + $sql = "UPDATE $tbl_wiki SET id = iid WHERE iid = $id"; + Database::query($sql); + + api_item_property_update( + $_course, + 'wiki', + $id, + 'WikiAdded', + api_get_user_id(), + $r_group_id + ); + self::check_emailcue($r_reflink, 'P', $r_dtime, $r_user_id); + } return get_lang('PageRestored'); } @@ -2110,8 +2134,8 @@ class Wiki $obj->title.''; } - $row[] = $obj->user_id <>0 ? ''. - api_htmlentities($userinfo['complete_name']).'' : get_lang('Anonymous').' ('.$obj->user_ip.')'; + $row[] = $obj->user_id < >0 ? UserManager::getUserProfileLink($userinfo) : get_lang('Anonymous').' ('.$obj->user_ip.')'; + $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds; if ($all_vers=='1') { @@ -2981,9 +3005,8 @@ class Wiki $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES); $row = array(); if ($obj->user_id <> 0) { - $row[] = ''. - Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)). - 'user_id). '&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'; } else { $row[] = get_lang('Anonymous').' ('.$obj->user_ip.')'; @@ -2993,7 +3016,14 @@ class Wiki } $table = new SortableTableFromArrayConfig($rows,1,10,'MostActiveUsersA_table','','','DESC'); - $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($action),'session_id'=>Security::remove_XSS($_GET['session_id']),'group_id'=>Security::remove_XSS($_GET['group_id']))); + $table->set_additional_parameters( + array( + 'cidReq' => Security::remove_XSS($_GET['cidReq']), + 'action' => Security::remove_XSS($action), + 'session_id' => Security::remove_XSS($_GET['session_id']), + 'group_id' => Security::remove_XSS($_GET['group_id']) + ) + ); $table->set_header(0,get_lang('Author'), true); $table->set_header(1,get_lang('Contributions'), true,array ('style' => 'width:30px;')); $table->display(); @@ -3020,9 +3050,12 @@ class Wiki return; } - //first extract the date of last version + // First extract the date of last version $sql = 'SELECT * FROM '.$tbl_wiki.' - WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.' + WHERE + c_id = '.$course_id.' AND + reflink = "'.Database::escape_string($page).'" AND + '.$groupfilter.$condition_session.' ORDER BY id DESC'; $result=Database::query($sql); $row=Database::fetch_array($result); @@ -3032,7 +3065,10 @@ class Wiki //select page to discuss $sql = 'SELECT * FROM '.$tbl_wiki.' - WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.' + WHERE + c_id = '.$course_id.' AND + reflink="'.Database::escape_string($page).'" AND + '.$groupfilter.$condition_session.' ORDER BY id ASC'; $result=Database::query($sql); $row=Database::fetch_array($result); @@ -3042,18 +3078,24 @@ class Wiki //mode assignment: previous to show page type $icon_assignment = null; if ($row['assignment']==1) { - $icon_assignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL); + $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL); } elseif($row['assignment']==2) { - $icon_assignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL); + $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL); } $countWPost = null; $avg_WPost_score = null; - //Show title and form to discuss if page exist + // Show title and form to discuss if page exist if ($id!='') { - //Show discussion to students if isn't hidden. Show page to all teachers if is hidden. Mode assignments: If is hidden, show pages to student only if student is the author - if ($row['visibility_disc']==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin() || ($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id']))) { + // Show discussion to students if isn't hidden. + // Show page to all teachers if is hidden. + // Mode assignments: If is hidden, show pages to student only if student is the author + if ($row['visibility_disc']==1 || + api_is_allowed_to_edit(false,true) || + api_is_platform_admin() || + ($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id'])) + ) { echo '
    '; // discussion action: protecting (locking) the discussion @@ -3120,9 +3162,7 @@ class Wiki echo $icon_assignment.'   '.api_htmlentities($row['title']); - echo ' ('.get_lang('MostRecentVersionBy').' '. - Display::tag('span', api_htmlentities(api_get_person_name($lastuserinfo['firstname'], $lastuserinfo['lastname'])), array('title'=>$username)). - ' '.$lastversiondate.$countWPost.')'.$avg_WPost_score.' '; //TODO: read average score + echo ' ('.get_lang('MostRecentVersionBy').' '.UserManager::getUserProfileLink($lastuserinfo).' '.$lastversiondate.$countWPost.')'.$avg_WPost_score.' '; //TODO: read average score echo '
    '; @@ -3175,7 +3215,7 @@ class Wiki $message_author = api_get_user_id(); $sql="INSERT INTO $tbl_wiki_discuss (c_id, publication_id, userc_id, comment, p_score, dtime) VALUES ($course_id, '".$id."','".$message_author."','".Database::escape_string($_POST['comment'])."','".Database::escape_string($_POST['rating'])."','".$dtime."')"; - $result=Database::query($sql) or die(Database::error()); + $result = Database::query($sql); self::check_emailcue($id, 'D', $dtime, $message_author); } }//end discuss lock @@ -3185,8 +3225,8 @@ class Wiki $sql="SELECT * FROM $tbl_wiki_discuss reviews, $user_table user WHERE reviews.c_id = $course_id AND reviews.publication_id='".$id."' AND user.user_id='".$firstuserid."' - ORDER BY reviews.id DESC"; - $result=Database::query($sql) or die(Database::error()); + ORDER BY id DESC"; + $result=Database::query($sql); $countWPost = Database::num_rows($result); echo get_lang('NumComments').": ".$countWPost; //comment's numbers @@ -3200,7 +3240,7 @@ class Wiki $sql = "SELECT * FROM $tbl_wiki_discuss WHERE c_id = $course_id AND publication_id='".$id."' AND NOT p_score='-'"; - $result3=Database::query($sql) or die(Database::error()); + $result3=Database::query($sql); $countWPost_score= Database::num_rows($result3); echo ' - '.get_lang('NumCommentsScore').': '.$countWPost_score;// @@ -3281,9 +3321,7 @@ class Wiki echo '

    '; echo ''; echo ''; - echo ''; echo ''; @@ -3359,12 +3397,10 @@ class Wiki $row[] = ' '.api_htmlentities($obj->title).''; if ($obj->user_id <>0) { - $row[] = ''. - Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)). - ''; + $row[] = UserManager::getUserProfileLink($userinfo); } else { - $row[] = get_lang('Anonymous').' ('.api_htmlentities($obj->user_ip).')'; + $row[] = get_lang('Anonymous').' ('.api_htmlentities($obj->user_ip).')'; } $row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get()); @@ -3472,13 +3508,11 @@ class Wiki $row = array(); $row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get()); $row[] = $ShowAssignment.$icon_task; - $row[] = ''. + $row[] = ''. api_htmlentities($obj->title).''; $row[] = $obj->version>1 ? get_lang('EditedBy') : get_lang('AddedBy'); if ($obj->user_id <> 0 ) { - $row[] = ''. - Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)). - ''; + $row[] = UserManager::getUserProfileLink($userinfo); } else { $row[] = get_lang('Anonymous').' ('.api_htmlentities($obj->user_ip).')'; } @@ -3601,8 +3635,7 @@ class Wiki $row[] = ''. api_htmlentities($obj->title).''; if ($obj->user_id <>0) { - $row[] = ''. - Display::tag('span', api_htmlentities($userinfo['complete_name_with_username'])).''; + $row[] = UserManager::getUserProfileLink($userinfo); } else { $row[] = get_lang('Anonymous').' ('.$obj->user_ip.')'; @@ -3687,10 +3720,10 @@ class Wiki $userinfo = api_get_user_info($userId); $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES); - echo ''; + echo '
    '.get_lang('UserContributions').': '.UserManager::getUserProfileLink($userinfo). + ' +
    '; if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden @@ -3828,6 +3861,8 @@ class Wiki } /** + * Restore page + * @return bool */ public function restorePage() { @@ -3844,7 +3879,7 @@ class Wiki /* Only teachers and platform admin can edit the index page. Only teachers and platform admin can edit an assignment teacher*/ - if (($current_row['reflink']=='index' || $current_row['reflink']=='' || $current_row['assignment'] == 1) && + if (($current_row['reflink'] == 'index' || $current_row['reflink'] == '' || $current_row['assignment'] == 1) && (!api_is_allowed_to_edit(false,true) && $this->group_id == 0) ) { self::setMessage( @@ -3873,9 +3908,7 @@ class Wiki //$icon_assignment = null; if ($current_row['assignment'] == 1) { self::setMessage(Display::display_normal_message(get_lang('EditAssignmentWarning'), false, true)); - //$icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL); } elseif($current_row['assignment']==2) { - //$icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL); if (($userId == $current_row['user_id'])==false) { if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { $PassEdit = true; @@ -3890,7 +3923,9 @@ class Wiki //show editor if edit is allowed if ($PassEdit) { - if ($current_row['editlock'] == 1 && (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false)) { + if ($current_row['editlock'] == 1 && + (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false) + ) { self::setMessage(Display::display_normal_message(get_lang('PageLockedExtra'), false, true)); } else { if ($last_row['is_editing']!=0 && $last_row['is_editing'] != $userId) { @@ -3900,7 +3935,7 @@ class Wiki $max_edit_time = 1200; // 20 minutes $rest_time = $max_edit_time - $time_editing; $userinfo = api_get_user_info($last_row['is_editing']); - $is_being_edited = get_lang('ThisPageisBeginEditedBy').' '. + $is_being_edited = get_lang('ThisPageisBeginEditedBy').' '. Display::tag('span', $userinfo['complete_name_with_username']). get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes'); self::setMessage(Display::display_normal_message($is_being_edited, false, true)); @@ -4480,8 +4515,8 @@ class Wiki $default_table_for_content_Start='
    '.$author_photo.''. - Display::tag('span', api_htmlentities($userinfo['complete_name'])). - ' ('.$author_status.') '. + echo ''.UserManager::getUserProfileLink($userinfo).' ('.$author_status.') '. api_get_local_time($row['dtime'], null, date_default_timezone_get()). ' - '.get_lang('Rating').': '.$row['p_score'].' '.$imagerating.'
    '; $default_table_for_content_End='
    '; $content = $default_table_for_content_Start.sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH)).$default_table_for_content_End; - $title=get_lang('DefaultTitle'); - $page_id=0; + $title = get_lang('DefaultTitle'); + $page_id = 0; } else { $content = api_html_entity_decode($row['content']); $title = api_html_entity_decode($row['title']); @@ -4594,25 +4629,27 @@ class Wiki } else { $message_task_delayedsubmit=get_lang('Yes'); } + if ($row['max_version']==0) { $message_task_max_version=get_lang('No'); } else { $message_task_max_version=$row['max_version']; } + if ($row['max_text']==0) { $message_task_max_text=get_lang('No'); } else { $message_task_max_text=$row['max_text']; } - //comp message + // Comp message $message_task=''.get_lang('DescriptionOfTheTask').'

    '.$row['task'].'


    '; $message_task.='

    '.get_lang('StartDate').': '.$message_task_startdate.'

    '; $message_task.='

    '.get_lang('EndDate').': '.$message_task_enddate; $message_task.=' ('.get_lang('AllowLaterSends').') '.$message_task_delayedsubmit.'

    '; $message_task.='

    '.get_lang('OtherSettings').': '.get_lang('NMaxVersion').': '.$message_task_max_version; $message_task.=' '.get_lang('NMaxWords').': '.$message_task_max_text; - //display message + // Display message self::setMessage(Display::display_normal_message($message_task, false, true)); } @@ -4631,22 +4668,22 @@ class Wiki if ($row['is_editing']==0) { self::setMessage(Display::display_normal_message(get_lang('WarningMaxEditingTime'), false, true)); $time_edit = date("Y-m-d H:i:s"); - $sql = 'UPDATE '.$tbl_wiki.' SET is_editing="'.$userId.'", time_edit="'.$time_edit.'" + $sql = 'UPDATE '.$tbl_wiki.' SET + is_editing = "'.$userId.'", + time_edit = "'.$time_edit.'" WHERE c_id = '.$course_id.' AND id="'.$row['id'].'"'; Database::query($sql); } elseif ($row['is_editing']!= $userId) { $timestamp_edit=strtotime($row['time_edit']); - $time_editing=time()-$timestamp_edit; - $max_edit_time=1200; // 20 minutes - $rest_time=$max_edit_time-$time_editing; + $time_editing = time() - $timestamp_edit; + $max_edit_time = 1200; // 20 minutes + $rest_time = $max_edit_time - $time_editing; $userinfo = api_get_user_info($row['is_editing']); $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES); - $is_being_edited = get_lang('ThisPageisBeginEditedBy'). - ' '. - Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)). - '. '.get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes').''; + $is_being_edited = get_lang('ThisPageisBeginEditedBy').' '.UserManager::getUserProfileLink($userinfo).' + '.get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes').''; self::setMessage(Display::display_normal_message($is_being_edited, false, true)); $this->redirectHome(); } @@ -4794,10 +4831,8 @@ class Wiki echo ''; echo ' ('.get_lang('Version').' '.$row['version'].')'; echo ' '.get_lang('By').' '; - if ($row['user_id']<>0) { - echo ''. - Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)). - ''; + if ($row['user_id'] <> 0) { + echo UserManager::getUserProfileLink($userinfo); } else { echo get_lang('Anonymous').' ('.api_htmlentities($row['user_ip']).')'; } diff --git a/main/work/edit.php b/main/work/edit.php index 7b0ee4d69e..5c9d0f4e99 100755 --- a/main/work/edit.php +++ b/main/work/edit.php @@ -71,13 +71,11 @@ if (!api_is_allowed_to_edit()) { if (!empty($my_folder_data)) { $homework = get_work_assignment_by_id($my_folder_data['id']); - if ($homework['expires_on'] != '0000-00-00 00:00:00' || - $homework['ends_on'] != '0000-00-00 00:00:00' - ) { + if (!empty($homework['expires_on'] || !empty($homework['ends_on'])) { $time_now = time(); if (!empty($homework['expires_on']) && - $homework['expires_on'] != '0000-00-00 00:00:00' + !empty($homework['expires_on']) ) { $time_expires = api_strtotime($homework['expires_on'], 'UTC'); $difference = $time_expires - $time_now; @@ -86,15 +84,11 @@ if (!empty($my_folder_data)) { } } - if (empty($homework['expires_on']) || - $homework['expires_on'] == '0000-00-00 00:00:00' - ) { + if (empty($homework['expires_on'])) { $has_expired = false; } - if (!empty($homework['ends_on']) && - $homework['ends_on'] != '0000-00-00 00:00:00' - ) { + if (!empty($homework['ends_on'])) { $time_ends = api_strtotime($homework['ends_on'], 'UTC'); $difference2 = $time_ends - $time_now; if ($difference2 < 0) { @@ -102,7 +96,7 @@ if (!empty($my_folder_data)) { } } - $ends_on = api_convert_and_format_date($homework['ends_on']); + $ends_on = api_convert_and_format_date($homework['ends_on']); $expires_on = api_convert_and_format_date($homework['expires_on']); } } diff --git a/main/work/edit_work.php b/main/work/edit_work.php index 361a7eeedb..59d7952955 100755 --- a/main/work/edit_work.php +++ b/main/work/edit_work.php @@ -64,7 +64,7 @@ if (Gradebook::is_active()) { $defaults['category_id'] = ''; } -if ($homework['expires_on'] != '0000-00-00 00:00:00') { +if (!empty($homework['expires_on'])) { $homework['expires_on'] = api_get_local_time($homework['expires_on']); $there_is_a_expire_date = true; $defaults['enableExpiryDate'] = true; @@ -73,7 +73,7 @@ if ($homework['expires_on'] != '0000-00-00 00:00:00') { $there_is_a_expire_date = false; } -if ($homework['ends_on'] != '0000-00-00 00:00:00') { +if (!empty($homework['ends_on'])) { $homework['ends_on'] = api_get_local_time($homework['ends_on']); $there_is_a_end_date = true; $defaults['enableEndDate'] = true; @@ -108,6 +108,7 @@ if ($form->validate()) { } if ($editCheck) { + var_dump($params);exit; updateWork($workId, $params, $courseInfo, $sessionId); updatePublicationAssignment($workId, $params, $courseInfo, $groupId); updateDirName($workData, $params['new_dir']); diff --git a/main/work/student_work.php b/main/work/student_work.php index 18750a1f56..07bfb83e27 100755 --- a/main/work/student_work.php +++ b/main/work/student_work.php @@ -156,7 +156,7 @@ foreach ($workPerUser as $work) { $column++; $table->setCellContents($row, $column, $userResult['sent_date']); $column++; - $dateQualification = !empty($workExtraData['expires_on']) && $workExtraData['expires_on'] != '0000-00-00 00:00:00' ? api_get_local_time($workExtraData['expires_on']) : '-'; + $dateQualification = !empty($workExtraData['expires_on']) ? api_get_local_time($workExtraData['expires_on']) : '-'; $table->setCellContents($row, $column, $dateQualification); $column++; diff --git a/main/work/work.lib.php b/main/work/work.lib.php index 40be793740..bd00a331c0 100755 --- a/main/work/work.lib.php +++ b/main/work/work.lib.php @@ -724,7 +724,7 @@ function display_student_publications_list( if (!empty($homework)) { // use original utc value saved previously to avoid doubling the utc-to-local conversion ($homework['expires_on'] might have been tainted) - $row[] = !empty($utc_expiry_time) && $utc_expiry_time != '0000-00-00 00:00:00' ? api_get_local_time($utc_expiry_time): '-'; + $row[] = !empty($utc_expiry_time) ? api_get_local_time($utc_expiry_time): '-'; } else { $row[] = '-'; } @@ -1399,8 +1399,7 @@ function insert_all_directory_in_course_table($base_work_dir) active = '1', accepted = '1', filetype = 'folder', - post_group_id = '".$group_id."', - sent_date = '0000-00-00 00:00:00' "; + post_group_id = '".$group_id."'"; Database::query($sql); } } @@ -1600,12 +1599,12 @@ function get_count_work($work_id, $onlyMeUserId = null, $notMeUserId = null) $is_allowed_to_edit = api_is_allowed_to_edit(null, true); $session_id = api_get_session_id(); - $condition_session = api_get_session_condition($session_id); + $condition_session = api_get_session_condition($session_id, true, false, 'work.session_id'); - $course_id = api_get_course_int_id(); - $group_id = api_get_group_id(); - $course_info = api_get_course_info(api_get_course_id()); - $work_id = intval($work_id); + $course_id = api_get_course_int_id(); + $group_id = api_get_group_id(); + $course_info = api_get_course_info(api_get_course_id()); + $work_id = intval($work_id); if (!empty($group_id)) { // set to select only messages posted by the user's group @@ -1755,7 +1754,7 @@ function getWorkListStudent( continue; } $work['type'] = Display::return_icon('work.png'); - $work['expires_on'] = $work['expires_on'] == '0000-00-00 00:00:00' ? null : api_get_local_time($work['expires_on']); + $work['expires_on'] = empty($work['expires_on']) ? null : api_get_local_time($work['expires_on']); if (empty($work['title'])) { $work['title'] = basename($work['url']); @@ -1869,7 +1868,7 @@ function getWorkListTeacher( while ($work = Database::fetch_array($result, 'ASSOC')) { $workId = $work['id']; $work['type'] = Display::return_icon('work.png'); - $work['expires_on'] = $work['expires_on'] == '0000-00-00 00:00:00' ? null : api_get_local_time($work['expires_on']); + $work['expires_on'] = empty($work['expires_on']) ? null : api_get_local_time($work['expires_on']); $totalUsers = getStudentSubscribedToWork( $workId, @@ -2189,7 +2188,7 @@ function get_work_user_list( $work_data = get_work_data_by_id($work_id); $is_allowed_to_edit = api_is_allowed_to_edit() || api_is_coach(); - $condition_session = api_get_session_condition($session_id); + $condition_session = api_get_session_condition($session_id, true, false, 'work.session_id'); $locked = api_resource_is_locked_by_gradebook($work_id, LINK_STUDENTPUBLICATION); $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh( @@ -2326,11 +2325,17 @@ function get_work_user_list( $work['qualification_score'] = $work['qualification']; $add_string = ''; - $time_expires = api_strtotime($work_assignment['expires_on'], 'UTC'); + + $time_expires = ''; + if (!empty($work_assignment['expires_on'])) { + $time_expires = api_strtotime( + $work_assignment['expires_on'], + 'UTC' + ); + } if (!empty($work_assignment['expires_on']) && - $work_assignment['expires_on'] != '0000-00-00 00:00:00' && - $time_expires && ($time_expires < api_strtotime($work['sent_date'], 'UTC'))) { + !empty($time_expires) && ($time_expires < api_strtotime($work['sent_date'], 'UTC'))) { $add_string = Display::label(get_lang('Expired'), 'important'); } @@ -2527,9 +2532,8 @@ function send_email_on_homework_creation($course_id) $emailbody .= get_lang('HomeworkHasBeenCreatedForTheCourse')." ".$course_id.". "."\n\n".get_lang('PleaseCheckHomeworkPage'); $emailbody .= "\n\n".api_get_person_name($currentUser["firstname"], $currentUser["lastname"]); - $plugin = new AppPlugin(); $additionalParameters = array( - 'smsType' => constant($plugin->getSMSPluginName().'::ASSIGNMENT_BEEN_CREATED_COURSE'), + 'smsType' => SmsPlugin::ASSIGNMENT_BEEN_CREATED_COURSE, 'userId' => $student["user_id"], 'courseTitle' => $course_id ); @@ -2742,11 +2746,17 @@ function get_list_users_without_publication($task_id, $studentId = null) } if ($session_id == 0) { - $sql_users = "SELECT cu.user_id, u.lastname, u.firstname, u.email FROM $table_course_user AS cu, $table_user AS u - WHERE u.status != 1 and cu.course_code='".api_get_course_id()."' AND u.user_id = cu.user_id"; + $sql_users = "SELECT cu.user_id, u.lastname, u.firstname, u.email + FROM $table_course_user AS cu, $table_user AS u + WHERE u.status != 1 and cu.c_id='".api_get_course_int_id()."' AND u.user_id = cu.user_id"; } else { - $sql_users = "SELECT cu.id_user, u.lastname, u.firstname, u.email FROM $session_course_rel_user AS cu, $table_user AS u - WHERE u.status != 1 and cu.course_code='".api_get_course_id()."' AND u.user_id = cu.id_user and cu.id_session = '".$session_id."'"; + $sql_users = "SELECT cu.user_id, u.lastname, u.firstname, u.email + FROM $session_course_rel_user AS cu, $table_user AS u + WHERE + u.status != 1 AND + cu.c_id='".api_get_course_int_id()."' AND + u.user_id = cu.user_id AND + cu.session_id = '".$session_id."'"; } if (!empty($studentId)) { @@ -3662,14 +3672,10 @@ function getWorkDateValidationStatus($homework) { if (!empty($homework)) { - if ($homework['expires_on'] != '0000-00-00 00:00:00' || - $homework['ends_on'] != '0000-00-00 00:00:00' - ) { + if (!empty($homework['expires_on']) || !empty($homework['ends_on'])) { $time_now = time(); - if (!empty($homework['expires_on']) && - $homework['expires_on'] != '0000-00-00 00:00:00' - ) { + if (!empty($homework['expires_on'])) { $time_expires = api_strtotime($homework['expires_on'], 'UTC'); $difference = $time_expires - $time_now; if ($difference < 0) { @@ -3677,17 +3683,13 @@ function getWorkDateValidationStatus($homework) { } } - if (empty($homework['expires_on']) || - $homework['expires_on'] == '0000-00-00 00:00:00' - ) { + if (empty($homework['expires_on'])) { $has_expired = false; } - if (!empty($homework['ends_on']) && - $homework['ends_on'] != '0000-00-00 00:00:00' - ) { - $time_ends = api_strtotime($homework['ends_on'], 'UTC'); - $difference2 = $time_ends - $time_now; + if (!empty($homework['ends_on'])) { + $time_ends = api_strtotime($homework['ends_on'], 'UTC'); + $difference2 = $time_ends - $time_now; if ($difference2 < 0) { $has_ended = true; } @@ -3974,12 +3976,15 @@ function processWorkForm($workInfo, $values, $courseInfo, $sessionId, $groupId, Database::query($sql); $workId = Database::insert_id(); + $sql = "UPDATE $work_table SET id = iid WHERE iid = $workId "; + Database::query($sql); + if ($workId) { if (array_key_exists('filename', $workInfo) && !empty($filename)) { $filename = Database::escape_string($filename); $sql = "UPDATE $work_table SET filename = '$filename' - WHERE c_id = $courseId AND id = $workId"; + WHERE iid = $workId"; Database::query($sql); } @@ -3987,7 +3992,7 @@ function processWorkForm($workInfo, $values, $courseInfo, $sessionId, $groupId, $documentId = isset($values['document_id']) ? intval($values['document_id']) : 0; $sql = "UPDATE $work_table SET document_id = '$documentId' - WHERE c_id = $courseId AND id = $workId"; + WHERE iid = $workId"; Database::query($sql); } api_item_property_update( @@ -4059,19 +4064,21 @@ function addDir($params, $user_id, $courseInfo, $group_id, $session_id) qualification = '".($params['qualification'] != '' ? Database::escape_string($params['qualification']) : '') ."', parent_id = '', qualificator_id = '', - date_of_qualification = '0000-00-00 00:00:00', weight = '".Database::escape_string($params['weight'])."', session_id = '".$session_id."', allow_text_assignment = '".Database::escape_string($params['allow_text_assignment'])."', contains_file = 0, user_id = '".$user_id."'"; - Database::query($sql); // Add the directory $id = Database::insert_id(); if ($id) { + + $sql = "UPDATE $work_table SET id = iid WHERE iid = $id"; + Database::query($sql); + // Folder created api_item_property_update( $courseInfo, @@ -4155,7 +4162,7 @@ function updatePublicationAssignment($workId, $params, $courseInfo, $groupId) $table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); $workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION); $workId = intval($workId); - $time = time(); + $time = api_get_utc_datetime(); $course_id = $courseInfo['real_id']; // Insert into agenda @@ -4167,7 +4174,7 @@ function updatePublicationAssignment($workId, $params, $courseInfo, $groupId) // Setting today date $date = $end_date = $time; - if (!empty($params['enableExpiryDate'])) { + if (isset($params['enableExpiryDate'])) { $end_date = $params['expires_on']; $date = $end_date; } @@ -4206,29 +4213,45 @@ function updatePublicationAssignment($workId, $params, $courseInfo, $groupId) } $qualification = isset($params['qualification']) && !empty($params['qualification']) ? 1 : 0; - $expiryDate = isset($params['enableExpiryDate']) && $params['enableExpiryDate'] == 1 ? api_get_utc_datetime($params['expires_on']) : '0000-00-00 00:00:00'; - $endDate = isset($params['enableEndDate']) && $params['enableEndDate'] == 1 ? api_get_utc_datetime($params['ends_on']) : '0000-00-00 00:00:00'; + $expiryDate = isset($params['enableExpiryDate']) && $params['enableExpiryDate'] == 1 ? api_get_utc_datetime($params['expires_on']) : ''; + $endDate = isset($params['enableEndDate']) && $params['enableEndDate'] == 1 ? api_get_utc_datetime($params['ends_on']) : ''; $data = get_work_assignment_by_id($workId, $course_id); if (empty($data)) { + $expiryDateCondition = ''; + if (!empty($expiryDate)) { + $expiryDateCondition = "expires_on = '".Database::escape_string($expiryDate)."', "; + } else { + $expiryDateCondition = "expires_on = null, "; + } + + $endOnCondition = ''; + if (!empty($endDate)) { + $endOnCondition = "ends_on = '".Database::escape_string($endDate)."', "; + } else { + $endOnCondition = "ends_on = null, "; + } $sql = "INSERT INTO $table SET c_id = $course_id , - expires_on = '".Database::escape_string($expiryDate)."', - ends_on = '".Database::escape_string($endDate)."', + $expiryDateCondition + $endOnCondition add_to_calendar = $agendaId, enable_qualification = '$qualification', publication_id = '$workId'"; + Database::query($sql); $my_last_id = Database::insert_id(); + if ($my_last_id) { - $sql = "UPDATE $workTable SET - has_properties = $my_last_id , - view_properties = 1 - WHERE c_id = $course_id AND id = $workId"; - Database::query($sql); + $sql = "UPDATE $workTable SET + has_properties = $my_last_id, + view_properties = 1 + WHERE c_id = $course_id AND id = $workId"; + Database::query($sql); + } } else { $sql = "UPDATE $table SET expires_on = '".$expiryDate."', @@ -5006,7 +5029,7 @@ function exportAllStudentWorkFromPublication( $header .= '
    ' . $sessionInfo['description']; $teachers = SessionManager::getCoachesByCourseSessionToString( $sessionId, - $courseCode + $courseInfo['real_id'] ); } } diff --git a/main/work/work.php b/main/work/work.php index e764163195..f26bb4973d 100755 --- a/main/work/work.php +++ b/main/work/work.php @@ -172,6 +172,7 @@ switch ($action) { $form->addButtonCreate(get_lang('CreateDirectory')); if ($form->validate()) { + $result = addDir( $_POST, $user_id, @@ -179,6 +180,7 @@ switch ($action) { $group_id, $id_session ); + if ($result) { $message = Display::return_message(get_lang('DirectoryCreated'), 'success'); } else { diff --git a/news_list.php b/news_list.php index 44fa6fc848..498f2a050b 100755 --- a/news_list.php +++ b/news_list.php @@ -6,8 +6,9 @@ require_once 'main/inc/global.inc.php'; $tool_name = get_lang('SystemAnnouncements'); $actions = ''; -if (api_is_platform_admin()) { - $actions = ''.Display::return_icon('edit.png', get_lang('EditSystemAnnouncement'), array(), 32).''; +if (api_is_platform_admin()) { + $actions = ''. + Display::return_icon('edit.png', get_lang('EditSystemAnnouncement'), array(), 32).''; } if (api_is_anonymous()) { diff --git a/plugin/advanced_subscription/cron/notify_by_mail.php b/plugin/advanced_subscription/cron/notify_by_mail.php index a60ac5ab95..642c35fdcb 100644 --- a/plugin/advanced_subscription/cron/notify_by_mail.php +++ b/plugin/advanced_subscription/cron/notify_by_mail.php @@ -19,9 +19,9 @@ $sessionExtraFieldValue = new ExtraFieldValue('session'); * Get session list */ $joinTables = Database::get_main_table(TABLE_MAIN_SESSION) . ' s INNER JOIN ' . - Database::get_main_table(TABLE_MAIN_SESSION_USER) . ' su ON s.id = su.id_session INNER JOIN ' . - Database::get_main_table(TABLE_MAIN_USER_REL_USER) . ' uu ON su.id_user = uu.user_id INNER JOIN ' . - Database::get_main_table(TABLE_ADVANCED_SUBSCRIPTION_QUEUE) . ' asq ON su.id_session = asq.session_id AND su.id_user = asq.user_id'; + Database::get_main_table(TABLE_MAIN_SESSION_USER) . ' su ON s.id = su.session_id INNER JOIN ' . + Database::get_main_table(TABLE_MAIN_USER_REL_USER) . ' uu ON su.user_id = uu.user_id INNER JOIN ' . + Database::get_main_table(TABLE_ADVANCED_SUBSCRIPTION_QUEUE) . ' asq ON su.session_id = asq.session_id AND su.user_id = asq.user_id'; $columns = 's.id AS session_id, uu.friend_user_id AS superior_id, uu.user_id AS student_id, asq.id AS queue_id, asq.status AS status'; $conditions = array( 'where' => array( @@ -154,4 +154,4 @@ foreach ($queueByAdmin as $sessionId => $studentInfo) { $data['session'] = $sessionInfoList[$sessionId]; $data['students'] = $studentInfo['students']; $plugin->sendMail($data, ADVANCED_SUBSCRIPTION_ACTION_REMINDER_ADMIN); -} \ No newline at end of file +} diff --git a/plugin/advanced_subscription/src/AdvancedSubscriptionPlugin.php b/plugin/advanced_subscription/src/AdvancedSubscriptionPlugin.php index 8942832d88..cfadc48d39 100644 --- a/plugin/advanced_subscription/src/AdvancedSubscriptionPlugin.php +++ b/plugin/advanced_subscription/src/AdvancedSubscriptionPlugin.php @@ -1,12 +1,12 @@ uninstallHook(); - // Note: Keeping area field data is intended so it will not be removed - $this->uninstallDatabase(); + $setting = api_get_setting('advanced_subscription'); + if (!empty($setting)) { + $this->uninstallHook(); + // Note: Keeping area field data is intended so it will not be removed + $this->uninstallDatabase(); + } } /** @@ -86,9 +89,9 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface ) ) ); + if (empty($result)) { - require_once api_get_path(LIBRARY_PATH).'extra_field.lib.php'; - $extraField = new Extrafield('user'); + $extraField = new ExtraField('user'); $extraField->save(array( 'field_type' => 1, 'field_variable' => 'area', @@ -219,8 +222,8 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface $now; $extra = new ExtraFieldValue('session'); $joinSessionTable = Database::get_main_table(TABLE_MAIN_SESSION_USER) . ' su INNER JOIN ' . - Database::get_main_table(TABLE_MAIN_SESSION) . ' s ON s.id = su.id_session'; - $whereSessionParams = 'su.relation_type = ? AND s.date_start >= ? AND su.id_user = ?'; + Database::get_main_table(TABLE_MAIN_SESSION) . ' s ON s.id = su.session_id'; + $whereSessionParams = 'su.relation_type = ? AND s.date_start >= ? AND su.user_id = ?'; $whereSessionParamsValues = array( 0, $newYearDate->format('Y-m-d'), @@ -830,6 +833,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface $count = Database::select('COUNT(*)', $advancedSubscriptionQueueTable, $where); $count = $count[0]['COUNT(*)']; } + return $count; } @@ -863,6 +867,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface * Return the status from user in queue to session subscription * @param int $userId * @param int $sessionId + * * @return bool|int */ public function getQueueStatus($userId, $sessionId) @@ -969,6 +974,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface if (isset($sessionArray['banner'])) { $sessionArray['banner'] = api_get_path(WEB_CODE_PATH) . $sessionArray['banner']; } + return $sessionArray; } @@ -979,13 +985,13 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface * Get status message * @param int $status * @param bool $isAble + * * @return string */ public function getStatusMessage($status, $isAble = true) { - $message = ''; - switch ($status) - { + $message = ''; + switch ($status) { case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_NO_QUEUE: if ($isAble) { $message = $this->get_lang('AdvancedSubscriptionNoQueueIsAble'); @@ -1010,7 +1016,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface break; default: $message = sprintf($this->get_lang('AdvancedSubscriptionQueueDefault'), $status); - } return $message; @@ -1019,11 +1024,13 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface /** * Return the url to go to session * @param $sessionId + * * @return string */ public function getSessionUrl($sessionId) { $url = api_get_path(WEB_CODE_PATH) . 'session/?session_id=' . intval($sessionId); + return $url; } @@ -1044,12 +1051,14 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface 'is_connected=' . 1 . '&' . 'profile_completed=' . intval($params['profile_completed']) . '&' . 'v=' . $this->generateHash($params); + return $url; } /** * Return the list of student, in queue used by admin view * @param int $sessionId + * * @return array */ public function listAllStudentsInQueueBySession($sessionId) @@ -1308,13 +1317,15 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface $tSessionField = Database::get_main_table(TABLE_MAIN_SESSION_FIELD); $tSessionFieldValues = Database::get_main_table(TABLE_MAIN_SESSION_FIELD_VALUES); $tSessionUser = Database::get_main_table(TABLE_MAIN_SESSION_USER); - $sql = "SELECT s.id FROM $tSession AS s " - . "INNER JOIN $tSessionFieldValues AS sfv ON s.id = sfv.session_id " - . "INNER JOIN $tSessionField AS sf ON sfv.field_id = sf.id " - . "INNER JOIN $tSessionUser AS su ON s.id = su.id_session " - . "WHERE sf.field_variable = 'is_induction_session' " - . "AND su.relation_type = 0 " - . "AND su.id_user = " . intval($userId); + + $sql = "SELECT s.id FROM $tSession AS s + INNER JOIN $tSessionFieldValues AS sfv ON s.id = sfv.session_id + INNER JOIN $tSessionField AS sf ON sfv.field_id = sf.id + INNER JOIN $tSessionUser AS su ON s.id = su.id_session + WHERE + sf.field_variable = 'is_induction_session' AND + su.relation_type = 0 AND + su.user_id = " . intval($userId); $result = Database::query($sql); diff --git a/plugin/advanced_subscription/src/terms_and_conditions.php b/plugin/advanced_subscription/src/terms_and_conditions.php index ccaa3bb3ab..8eff785878 100644 --- a/plugin/advanced_subscription/src/terms_and_conditions.php +++ b/plugin/advanced_subscription/src/terms_and_conditions.php @@ -57,7 +57,7 @@ if ( } $data['session'] = api_get_session_info($data['sessionId']); - $data['student'] = Usermanager::get_user_info_by_id($data['studentUserId']); + $data['student'] = UserManager::get_user_info_by_id($data['studentUserId']); $data['course'] = api_get_course_info_by_id($data['courseId']); $data['acceptTermsUrl'] = $plugin->getQueueUrl($data); $data['rejectTermsUrl'] = $plugin->getTermsUrl($data, ADVANCED_SUBSCRIPTION_TERMS_MODE_REJECT); diff --git a/plugin/buycourses/src/buy_course.lib.php b/plugin/buycourses/src/buy_course.lib.php index 3d723ad3ce..48da15614f 100644 --- a/plugin/buycourses/src/buy_course.lib.php +++ b/plugin/buycourses/src/buy_course.lib.php @@ -160,9 +160,9 @@ function userSessionList() // loop through all sessions while ($rowSession = Database::fetch_assoc($resSessions)) { // get courses of current session - $sqlSessionCourse = "SELECT DISTINCT a.id_session, a.course_code, a.nbr_users + $sqlSessionCourse = "SELECT DISTINCT a.session_id, a.course_code, a.nbr_users FROM $tableBuySessionRelCourse a, $tableSessionRelCourse b - WHERE a.id_session = b.id_session AND a.id_session = " . $rowSession['session_id'] . ";"; + WHERE a.session_id = b.session_id AND a.session_id = " . $rowSession['session_id'] . ";"; $resSessionCourse = Database::query($sqlSessionCourse); $aux = array(); // loop through courses of current session @@ -197,7 +197,7 @@ function userSessionList() if ($currentUserId > 0) { $sql = "SELECT 1 FROM $tableSessionRelUser WHERE id_session ='".$rowSession['session_id']."' AND - id_user = $currentUserId"; + user_id = $currentUserId"; $result = Database::query($sql); if (Database::affected_rows($result) > 0) { $rowSession['enrolled'] = "YES"; @@ -244,24 +244,26 @@ function userCourseList() $currentUserId = api_get_user_id(); $sql = "SELECT a.course_id, a.visible, a.price, b.* - FROM $tableBuyCourse a, $tableCourse b - WHERE a.course_id = b.id AND a.session_id = 0 AND a.visible = 1;"; + FROM $tableBuyCourse a, $tableCourse b + WHERE a.course_id = b.id AND a.session_id = 0 AND a.visible = 1;"; $res = Database::query($sql); $aux = array(); while ($row = Database::fetch_assoc($res)) { //check teacher $sql = "SELECT lastname, firstname - FROM course_rel_user a, user b - WHERE a.course_code='" . $row['code'] . "' - AND a.role<>'' AND a.role<>'NULL' - AND a.user_id=b.user_id;"; + FROM $tableCourseRelUser a, user b + WHERE + a.c_id='" . $row['id'] . "' AND + a.role<>'' AND + a.role<>'NULL' AND + a.user_id=b.user_id;"; $tmp = Database::query($sql); $rowTmp = Database::fetch_assoc($tmp); $row['teacher'] = $rowTmp['firstname'] . ' ' . $rowTmp['lastname']; //check if the user is enrolled if ($currentUserId > 0) { $sql = "SELECT 1 FROM $tableCourseRelUser - WHERE course_code='" . $row['code'] . "' + WHERE c_id='" . $row['id'] . "' AND user_id='" . $currentUserId . "';"; $result = Database::query($sql); if (Database::affected_rows($result) > 0) { @@ -305,14 +307,15 @@ function userCourseList() * @param string Session id or course code * @param int User id * @param string What has to be checked + * @todo fix this function because TABLE_MAIN_COURSE_USER needs a c_id not a course_code * @return boolean True if it is already bought, and false otherwise */ function checkUserBuy($parameter, $user, $type = 'COURSE') { $sql = "SELECT 1 FROM %s WHERE %s ='" . Database::escape_string($parameter) . "' AND %s ='" . intval($user) . "';"; $sql = $type === 'SESSION' ? - sprintf($sql, Database::get_main_table(TABLE_MAIN_SESSION_USER), 'id_session', 'id_user') : - sprintf($sql, Database::get_main_table(TABLE_MAIN_COURSE_USER), 'course_code', 'user_id'); + sprintf($sql, Database::get_main_table(TABLE_MAIN_SESSION_USER), 'session_id', 'user_id') : + sprintf($sql, Database::get_main_table(TABLE_MAIN_COURSE_USER), 'c_id', 'user_id'); $result = Database::query($sql); if (Database::affected_rows($result) > 0) { return true; @@ -485,9 +488,9 @@ function sessionInfo($code) AND b.id = '".$code."';"; $res = Database::query($sql); $rowSession = Database::fetch_assoc($res); - $sqlSessionCourse = "SELECT DISTINCT a.id_session, a.course_code, a.nbr_users + $sqlSessionCourse = "SELECT DISTINCT a.session_id, a.course_code, a.nbr_users FROM $tableBuySessionRelCourse a, $tableSessionRelCourse b - WHERE a.id_session = b.id_session AND a.id_session = " . $rowSession['session_id'] . ";"; + WHERE a.session_id = b.session_id AND a.session_id = " . $rowSession['session_id'] . ";"; $resSessionCourse = Database::query($sqlSessionCourse); $aux = array(); // loop through courses of current session @@ -521,13 +524,13 @@ function sessionInfo($code) //check if the user is enrolled in the current session if ($currentUserId > 0) { $sql = "SELECT 1 FROM $tableSessionRelUser - WHERE id_user = $currentUserId"; + WHERE user_id = $currentUserId"; $result = Database::query($sql); if (Database::affected_rows($result) > 0) { $rowSession['enrolled'] = "YES"; } else { $sql = "SELECT 1 FROM $tableBuySessionTemporal - WHERE user_id='".$currentUserId."';"; + WHERE user_id='".$currentUserId."';"; $result = Database::query($sql); if (Database::affected_rows($result) > 0) { $rowSession['enrolled'] = "TMP"; @@ -563,26 +566,30 @@ function courseInfo($code) $currentUserId = api_get_user_id(); $code = Database::escape_string($code); $sql = "SELECT a.course_id, a.visible, a.price, b.* - FROM $tableBuyCourse a, course b - WHERE a.course_id=b.id - AND a.visible = 1 - AND b.id = '" . $code . "';"; + FROM $tableBuyCourse a, course b + WHERE + a.course_id=b.id AND + a.visible = 1 AND + b.id = '" . $code . "'"; $res = Database::query($sql); $row = Database::fetch_assoc($res); // Check teacher $sql = "SELECT lastname, firstname FROM $tableCourseRelUser a, $tableUser b - WHERE a.course_code = '" . $row['code'] . "' - AND a.role <> '' AND a.role <> 'NULL' - AND a.user_id = b.user_id;"; + WHERE + a.c_id = '" . $row['id'] . "' AND + a.role <> '' AND + a.role <> 'NULL' AND + a.user_id = b.user_id;"; $tmp = Database::query($sql); $rowTmp = Database::fetch_assoc($tmp); $row['teacher'] = $rowTmp['firstname'] . ' ' . $rowTmp['lastname']; //Check if student is enrolled if ($currentUserId > 0) { $sql = "SELECT 1 FROM $tableCourseRelUser - WHERE course_code='" . $row['code'] . "' - AND user_id='" . $currentUserId . "';"; + WHERE + c_id ='" . $row['id'] . "' AND + user_id='" . $currentUserId . "';"; $result = Database::query($sql); if (Database::affected_rows($result) > 0) { $row['enrolled'] = "YES"; diff --git a/plugin/buycourses/src/function.php b/plugin/buycourses/src/function.php index db7244e8d3..30e42ed547 100644 --- a/plugin/buycourses/src/function.php +++ b/plugin/buycourses/src/function.php @@ -83,9 +83,9 @@ if ($_REQUEST['tab'] == 'sessions_filter') { // loop through all sessions while ($rowSession = Database::fetch_assoc($resSessions)) { // get courses of current session - $sqlSessionCourse = "SELECT DISTINCT a.id_session, a.course_code, a.nbr_users + $sqlSessionCourse = "SELECT DISTINCT a.session_id, a.course_code, a.nbr_users FROM $tableBuySessionRelCourse a, $tableSessionRelCourse b - WHERE a.id_session = b.id_session AND a.id_session = " . $rowSession['session_id'] . ";"; + WHERE a.session_id = b.session_id AND a.session_id = " . $rowSession['session_id'] . ";"; $resSessionCourse = Database::query($sqlSessionCourse); $aux = array(); // loop through courses of current session @@ -119,15 +119,15 @@ if ($_REQUEST['tab'] == 'sessions_filter') { //check if the user is enrolled in the current session if (isset($_SESSION['_user']) || $_SESSION['_user']['user_id'] != '') { $sql = "SELECT 1 FROM $tableSessionRelUser - WHERE id_session='".$rowSession['session_id']."' AND - id_user ='" . $_SESSION['_user']['user_id'] . "';"; + WHERE session_id ='".$rowSession['session_id']."' AND + user_id ='" . api_get_user_id() . "'"; $result = Database::query($sql); if (Database::affected_rows($result) > 0) { $rowSession['enrolled'] = "YES"; } else { $sql = "SELECT 1 FROM $tableBuySessionTemporal WHERE session_id ='".$rowSession['session_id']."' AND - user_id='" . $_SESSION['_user']['user_id'] . "';"; + user_id='" . api_get_user_id() . "'"; $result = Database::query($sql); if (Database::affected_rows($result) > 0) { $rowSession['enrolled'] = "TMP"; @@ -138,7 +138,7 @@ if ($_REQUEST['tab'] == 'sessions_filter') { } else { $sql = "SELECT 1 FROM $tableBuySessionTemporal WHERE session_id ='".$rowSession['session_id']."' AND - user_id='" . $_SESSION['_user']['user_id'] . "';"; + user_id='" . api_get_user_id() . "'"; $result = Database::query($sql); if (Database::affected_rows($result) > 0) { $rowSession['enrolled'] = "TMP"; @@ -364,8 +364,8 @@ if ($_REQUEST['tab'] == 'save_currency') { $res = Database::query($sql); $sql = "UPDATE $tableBuyCourseCountry SET status='1' WHERE country_id='" . $id . "';"; $res = Database::query($sql); - if (!res) { - $content = $plugin->get_lang('ProblemToSaveTheCurrencyType') . Database::error(); + if (!$res) { + $content = $plugin->get_lang('ProblemToSaveTheCurrencyType'); echo json_encode(array("status" => "false", "content" => $content)); } else { $content = get_lang('Saved'); @@ -386,8 +386,8 @@ if ($_REQUEST['tab'] == 'save_paypal') { WHERE id = '1';"; $res = Database::query($sql); - if (!res) { - $content = $plugin->get_lang('ProblemToSaveThePaypalParameters') . Database::error(); + if (!$res) { + $content = $plugin->get_lang('ProblemToSaveThePaypalParameters'); echo json_encode(array("status" => "false", "content" => $content)); } else { $content = get_lang('Saved'); @@ -403,8 +403,8 @@ if ($_REQUEST['tab'] == 'add_account') { VALUES ('" . $name . "','" . $account . "', '" . $swift . "');"; $res = Database::query($sql); - if (!res) { - $content = $plugin->get_lang('ProblemToInsertANewAccount') . Database::error(); + if (!$res) { + $content = $plugin->get_lang('ProblemToInsertANewAccount'); echo json_encode(array("status" => "false", "content" => $content)); } else { $content = get_lang('Saved'); @@ -417,8 +417,8 @@ if ($_REQUEST['tab'] == 'delete_account') { $sql = "DELETE FROM $tableBuyCourseTransfer WHERE id='" . $id . "';"; $res = Database::query($sql); - if (!res) { - $content = $plugin->get_lang('ProblemToDeleteTheAccount') . Database::error(); + if (!$res) { + $content = $plugin->get_lang('ProblemToDeleteTheAccount'); echo json_encode(array("status" => "false", "content" => $content)); } else { $content = get_lang('Saved'); @@ -452,7 +452,7 @@ if ($_REQUEST['tab'] == 'save_mod') { $res = Database::query($sql); if (!$res) { - $content = $plugin->get_lang('ProblemToSaveTheMessage') . Database::error(); + $content = $plugin->get_lang('ProblemToSaveTheMessage'); echo json_encode(array("status" => "false", "content" => $content)); } else { echo json_encode(array("status" => "true", "course_id" => $id)); @@ -479,8 +479,8 @@ if ($_REQUEST['tab'] == 'clear_order') { $sql = "DELETE FROM $tableBuyCourseTemporal WHERE cod='" . $id . "';"; $res = Database::query($sql); - if (!res) { - $content = $plugin->get_lang('ProblemToDeleteTheAccount') . Database::error(); + if (!$res) { + $content = $plugin->get_lang('ProblemToDeleteTheAccount'); echo json_encode(array("status" => "false", "content" => $content)); } else { $content = get_lang('Saved'); diff --git a/plugin/buycourses/src/inscription.php b/plugin/buycourses/src/inscription.php index f414759bfe..503b66458c 100644 --- a/plugin/buycourses/src/inscription.php +++ b/plugin/buycourses/src/inscription.php @@ -19,7 +19,7 @@ if (!empty($_SESSION['user_language_choice'])) { } elseif (!empty($_SESSION['_user']['language'])) { $user_selected_language = $_SESSION['_user']['language']; } else { - $user_selected_language = get_setting('platformLanguage'); + $user_selected_language = api_get_setting('platformLanguage'); } $form = new FormValidator('registration'); diff --git a/plugin/clockworksms/config.php b/plugin/clockworksms/config.php index 52017f034b..fd2a790e06 100755 --- a/plugin/clockworksms/config.php +++ b/plugin/clockworksms/config.php @@ -8,7 +8,6 @@ * @author Imanol Losada */ require_once __DIR__ . '/../../main/inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH).'plugin.class.php'; require_once 'lib/clockworksms.lib.php'; require_once 'vendor/clockworksms_api.php'; diff --git a/plugin/clockworksms/lib/clockworksms.lib.php b/plugin/clockworksms/lib/clockworksms.lib.php index d8d2c5312d..4fd7bb281c 100755 --- a/plugin/clockworksms/lib/clockworksms.lib.php +++ b/plugin/clockworksms/lib/clockworksms.lib.php @@ -4,14 +4,14 @@ /** * Class Clockworksms * This script handles incoming SMS information, process it and sends an SMS if everything is right - * + * * @package chamilo.plugin.clockworksms.lib * @author Imanol Losada * * Clockworksms-Chamilo connector class */ -class Clockworksms +class Clockworksms implements SmsPluginLibraryInterface { public $apiKey; public $api; @@ -35,7 +35,9 @@ class Clockworksms if ($clockWorkSMSPlugin == true) { $this->apiKey = $clockWorkSMSApiKey; // Setting Clockworksms api - define('CONFIG_SECURITY_API_KEY', $this->apiKey); + if (!defined('CONFIG_SECURITY_API_KEY')) { + define('CONFIG_SECURITY_API_KEY', $this->apiKey); + } $trimmedApiKey = trim(CONFIG_SECURITY_API_KEY); if (!empty($trimmedApiKey)) { $this->api = new Clockwork(CONFIG_SECURITY_API_KEY); @@ -47,27 +49,29 @@ class Clockworksms null, PERSON_NAME_EMAIL_ADDRESS ); - $email_form = get_setting('emailAdministrator'); + $email_form = api_get_setting('emailAdministrator'); $emailsubject = 'Clockworksms error'; $emailbody = 'Key cannot be blank'; $sender_name = $recipient_name; $email_admin = $email_form; - api_mail_html($recipient_name, $email_form, $emailsubject, $emailbody, $sender_name, $email_admin); + api_mail_html( + $recipient_name, + $email_form, + $emailsubject, + $emailbody, + $sender_name, + $email_admin + ); } $this->plugin_enabled = true; } } /** - * getMobilePhoneNumberById (retrieves a user mobile phone number by user id) - * @param int User id - * @return int User's mobile phone number + * @inheritdoc */ - private function getMobilePhoneNumberById($userId) + public function getMobilePhoneNumberById($userId) { - require_once api_get_path(LIBRARY_PATH).'extra_field.lib.php'; - require_once api_get_path(LIBRARY_PATH).'extra_field_value.lib.php'; - $mobilePhoneNumberExtraField = new ExtraField('user'); $mobilePhoneNumberExtraField = $mobilePhoneNumberExtraField->get_handler_field_info_by_field_variable('mobile_phone_number'); @@ -93,10 +97,11 @@ class Clockworksms { $trimmedKey = trim(CONFIG_SECURITY_API_KEY); if (!empty($trimmedKey)) { + $phoneExists = array_key_exists("mobilePhoneNumber", $additionalParameters); + $to = $phoneExists ? $additionalParameters['mobilePhoneNumber'] : $this->getMobilePhoneNumberById($additionalParameters['userId']); + $message = array( - "to" => array_key_exists("mobilePhoneNumber",$additionalParameters) ? - $additionalParameters['mobilePhoneNumber'] : - $this->getMobilePhoneNumberById($additionalParameters['userId']), + "to" => $to, "message" => $this->getSms($additionalParameters) ); @@ -104,7 +109,7 @@ class Clockworksms $result = $this->api->send($message); // Commented for future message logging / tracking purposes - /*if( $result["success"] ) { + /*if ($result["success"]) { echo "Message sent - ID: " . $result["id"]; } else { echo "Message failed - Error: " . $result["error_message"]; @@ -133,7 +138,8 @@ class Clockworksms ) ); - if (empty($result)) { + //if (empty($result)) { + if (0) { $tpl->assign('message', ''); } else { $templatePath = 'clockworksms/sms_templates/'; @@ -166,8 +172,8 @@ class Clockworksms $tool_name = $plugin->get_lang('plugin_title'); $tpl = new Template($tool_name); - switch (constant('ClockworksmsPlugin::'.$additionalParameters['smsType'])) { - case ClockworksmsPlugin::WELCOME_LOGIN_PASSWORD: + switch ($additionalParameters['smsType']) { + case SmsPlugin::WELCOME_LOGIN_PASSWORD: $userInfo = api_get_user_info($additionalParameters['userId']); return $this->buildSms( $plugin, @@ -181,7 +187,7 @@ class Clockworksms ) ); break; - case ClockworksmsPlugin::NEW_FILE_SHARED_COURSE_BY: + case SmsPlugin::NEW_FILE_SHARED_COURSE_BY: return $this->buildSms( $plugin, $tpl, @@ -194,7 +200,7 @@ class Clockworksms ) ); break; - case ClockworksmsPlugin::ACCOUNT_APPROVED_CONNECT: + case SmsPlugin::ACCOUNT_APPROVED_CONNECT: return $this->buildSms( $plugin, $tpl, @@ -206,7 +212,7 @@ class Clockworksms ) ); break; - case ClockworksmsPlugin::NEW_COURSE_BEEN_CREATED: + case SmsPlugin::NEW_COURSE_BEEN_CREATED: return $this->buildSms( $plugin, $tpl, @@ -219,7 +225,7 @@ class Clockworksms ) ); break; - case ClockworksmsPlugin::NEW_USER_SUBSCRIBED_COURSE: + case SmsPlugin::NEW_USER_SUBSCRIBED_COURSE: return $this->buildSms( $plugin, $tpl, @@ -232,7 +238,7 @@ class Clockworksms ) ); break; - case ClockworksmsPlugin::NEW_COURSE_SUGGESTED_TEACHER: + case SmsPlugin::NEW_COURSE_SUGGESTED_TEACHER: return $this->buildSms( $plugin, $tpl, @@ -244,7 +250,7 @@ class Clockworksms ) ); break; - case ClockworksmsPlugin::COURSE_OPENING_REQUEST_CODE_REGISTERED: + case SmsPlugin::COURSE_OPENING_REQUEST_CODE_REGISTERED: return $this->buildSms( $plugin, $tpl, @@ -256,7 +262,7 @@ class Clockworksms ) ); break; - case ClockworksmsPlugin::COURSE_OPENING_REQUEST_CODE_APPROVED: + case SmsPlugin::COURSE_OPENING_REQUEST_CODE_APPROVED: return $this->buildSms( $plugin, $tpl, @@ -268,7 +274,7 @@ class Clockworksms ) ); break; - case ClockworksmsPlugin::COURSE_OPENING_REQUEST_CODE_REJECTED: + case SmsPlugin::COURSE_OPENING_REQUEST_CODE_REJECTED: return $this->buildSms( $plugin, $tpl, @@ -280,7 +286,7 @@ class Clockworksms ) ); break; - case ClockworksmsPlugin::COURSE_OPENING_REQUEST_CODE: + case SmsPlugin::COURSE_OPENING_REQUEST_CODE: return $this->buildSms( $plugin, $tpl, @@ -292,7 +298,7 @@ class Clockworksms ) ); break; - case ClockworksmsPlugin::BEEN_SUBSCRIBED_COURSE: + case SmsPlugin::BEEN_SUBSCRIBED_COURSE: return $this->buildSms( $plugin, $tpl, @@ -304,7 +310,7 @@ class Clockworksms ) ); break; - case ClockworksmsPlugin::ASSIGNMENT_BEEN_CREATED_COURSE: + case SmsPlugin::ASSIGNMENT_BEEN_CREATED_COURSE: return $this->buildSms( $plugin, $tpl, @@ -317,7 +323,7 @@ class Clockworksms ); break; // Message types to be implemented. Fill the array parameter with arguments. - /*case ClockworksmsPlugin::ACCOUNT_CREATED_UPDATED_LOGIN_PASSWORD: + /*case SmsPlugin::ACCOUNT_CREATED_UPDATED_LOGIN_PASSWORD: return $this->buildSms( $plugin, $tpl, @@ -328,7 +334,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::PASSWORD_UPDATED_LOGIN_PASSWORD: + /*case SmsPlugin::PASSWORD_UPDATED_LOGIN_PASSWORD: return $this->buildSms( $plugin, $tpl, @@ -339,7 +345,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::REQUESTED_PASSWORD_CHANGE: + /*case SmsPlugin::REQUESTED_PASSWORD_CHANGE: return $this->buildSms( $plugin, $tpl, @@ -350,7 +356,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::RECEIVED_NEW_PERSONAL_MESSAGES: + /*case SmsPlugin::RECEIVED_NEW_PERSONAL_MESSAGES: return $this->buildSms( $plugin, $tpl, @@ -361,7 +367,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::NEW_USER_PENDING_APPROVAL: + /*case SmsPlugin::NEW_USER_PENDING_APPROVAL: return $this->buildSms( $plugin, $tpl, @@ -372,7 +378,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::POSTED_FORUM_COURSE: + /*case SmsPlugin::POSTED_FORUM_COURSE: return $this->buildSms( $plugin, $tpl, @@ -383,7 +389,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::CHECK_EMAIL_CONNECT_MORE_INFO: + /*case SmsPlugin::CHECK_EMAIL_CONNECT_MORE_INFO: return $this->buildSms( $plugin, $tpl, @@ -394,7 +400,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::STUDENT_ANSWERED_TEST: + /*case SmsPlugin::STUDENT_ANSWERED_TEST: return $this->buildSms( $plugin, $tpl, @@ -405,7 +411,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::STUDENT_ANSWERED_TEST_OPEN_QUESTION: + /*case SmsPlugin::STUDENT_ANSWERED_TEST_OPEN_QUESTION: return $this->buildSms( $plugin, $tpl, @@ -416,7 +422,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::STUDENT_ANSWERED_TEST_VOICE_QUESTION: + /*case SmsPlugin::STUDENT_ANSWERED_TEST_VOICE_QUESTION: return $this->buildSms( $plugin, $tpl, @@ -427,7 +433,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::ANSWER_OPEN_QUESTION_TEST_REVIEWED: + /*case SmsPlugin::ANSWER_OPEN_QUESTION_TEST_REVIEWED: return $this->buildSms( $plugin, $tpl, @@ -438,7 +444,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::NEW_THREAD_STARTED_FORUM: + /*case SmsPlugin::NEW_THREAD_STARTED_FORUM: return $this->buildSms( $plugin, $tpl, @@ -449,7 +455,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::NEW_ANSWER_POSTED_FORUM: + /*case SmsPlugin::NEW_ANSWER_POSTED_FORUM: return $this->buildSms( $plugin, $tpl, @@ -460,7 +466,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::NEW_SYSTEM_ANNOUNCEMENT_ADDED: + /*case SmsPlugin::NEW_SYSTEM_ANNOUNCEMENT_ADDED: return $this->buildSms( $plugin, $tpl, @@ -471,7 +477,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::TEST_NEW_SYSTEM_ANNOUNCEMENT_ADDED: + /*case SmsPlugin::TEST_NEW_SYSTEM_ANNOUNCEMENT_ADDED: return $this->buildSms( $plugin, $tpl, @@ -482,7 +488,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::SYSTEM_ANNOUNCEMENT_UPDATE: + /*case SmsPlugin::SYSTEM_ANNOUNCEMENT_UPDATE: return $this->buildSms( $plugin, $tpl, @@ -493,7 +499,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::TEST_SYSTEM_ANNOUNCEMENT_UPDATE: + /*case SmsPlugin::TEST_SYSTEM_ANNOUNCEMENT_UPDATE: return $this->buildSms( $plugin, $tpl, @@ -504,7 +510,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::USER_UPLOADED_ASSIGNMENT_COURSE_STUDENT_SUBMITS_PAPER: + /*case SmsPlugin::USER_UPLOADED_ASSIGNMENT_COURSE_STUDENT_SUBMITS_PAPER: return $this->buildSms( $plugin, $tpl, @@ -515,7 +521,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::USER_UPLOADED_ASSIGNMENT_CHECK_STUDENT_SUBMITS_PAPER: + /*case SmsPlugin::USER_UPLOADED_ASSIGNMENT_CHECK_STUDENT_SUBMITS_PAPER: return $this->buildSms( $plugin, $tpl, @@ -526,7 +532,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::USER_UPLOADED_ASSIGNMENT_COURSE: + /*case SmsPlugin::USER_UPLOADED_ASSIGNMENT_COURSE: return $this->buildSms( $plugin, $tpl, @@ -537,7 +543,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::USER_UPLOADED_ASSIGNMENT_CHECK: + /*case SmsPlugin::USER_UPLOADED_ASSIGNMENT_CHECK: return $this->buildSms( $plugin, $tpl, @@ -548,7 +554,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::SUBSCRIBED_SESSION: + /*case SmsPlugin::SUBSCRIBED_SESSION: return $this->buildSms( $plugin, $tpl, @@ -559,7 +565,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::SUBSCRIBED_SESSION_CSV: + /*case SmsPlugin::SUBSCRIBED_SESSION_CSV: return $this->buildSms( $plugin, $tpl, @@ -570,7 +576,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::USER_SUGGESTED_BE_FRIENDS: + /*case SmsPlugin::USER_SUGGESTED_BE_FRIENDS: return $this->buildSms( $plugin, $tpl, @@ -581,7 +587,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::USER_ANSWERED_INBOX_MESSAGE: + /*case SmsPlugin::USER_ANSWERED_INBOX_MESSAGE: return $this->buildSms( $plugin, $tpl, @@ -592,7 +598,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::BEEN_INVITED_JOIN_GROUP: + /*case SmsPlugin::BEEN_INVITED_JOIN_GROUP: return $this->buildSms( $plugin, $tpl, @@ -603,7 +609,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::MESSAGES_SENT_EDITED_GROUP_EDITED: + /*case SmsPlugin::MESSAGES_SENT_EDITED_GROUP_EDITED: return $this->buildSms( $plugin, $tpl, @@ -614,7 +620,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::MESSAGES_SENT_EDITED_GROUP_ADDED: + /*case SmsPlugin::MESSAGES_SENT_EDITED_GROUP_ADDED: return $this->buildSms( $plugin, $tpl, @@ -625,7 +631,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::BEEN_INVITED_COMPLETE_SURVEY_COURSE: + /*case SmsPlugin::BEEN_INVITED_COMPLETE_SURVEY_COURSE: return $this->buildSms( $plugin, $tpl, @@ -636,7 +642,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::REMINDER_ASSIGNMENT_COURSE_DUE: + /*case SmsPlugin::REMINDER_ASSIGNMENT_COURSE_DUE: return $this->buildSms( $plugin, $tpl, @@ -647,7 +653,7 @@ class Clockworksms ) ); break;*/ - /*case ClockworksmsPlugin::USER_DETAILS_MODIFIED: + /*case SmsPlugin::USER_DETAILS_MODIFIED: return $this->buildSms( $plugin, $tpl, diff --git a/plugin/clockworksms/lib/clockworksms_plugin.class.php b/plugin/clockworksms/lib/clockworksms_plugin.class.php index 12bbacfcfb..c8635aaa8f 100755 --- a/plugin/clockworksms/lib/clockworksms_plugin.class.php +++ b/plugin/clockworksms/lib/clockworksms_plugin.class.php @@ -4,59 +4,13 @@ /** * Class ClockworksmsPlugin * This script contains SMS type constants and basic plugin functions - * + * * @package chamilo.plugin.clockworksms.lib * @author Imanol Losada + * @author Julio Montoya - Refactor code */ -class ClockworksmsPlugin extends Plugin +class ClockworksmsPlugin extends SmsPlugin { - const WELCOME_LOGIN_PASSWORD = 0; - const NEW_FILE_SHARED_COURSE_BY = 1; - const ACCOUNT_APPROVED_CONNECT = 2; - const NEW_COURSE_BEEN_CREATED = 3; - const NEW_USER_SUBSCRIBED_COURSE = 4; - const NEW_COURSE_SUGGESTED_TEACHER = 5; - const COURSE_OPENING_REQUEST_CODE_REGISTERED = 6; - const COURSE_OPENING_REQUEST_CODE_APPROVED = 7; - const COURSE_OPENING_REQUEST_CODE_REJECTED = 8; - const COURSE_OPENING_REQUEST_CODE = 9; - const BEEN_SUBSCRIBED_COURSE = 10; - const ASSIGNMENT_BEEN_CREATED_COURSE = 11; - const ACCOUNT_CREATED_UPDATED_LOGIN_PASSWORD = 12; - const PASSWORD_UPDATED_LOGIN_PASSWORD = 13; - const REQUESTED_PASSWORD_CHANGE = 14; - const RECEIVED_NEW_PERSONAL_MESSAGES = 15; - const NEW_USER_PENDING_APPROVAL = 16; - const POSTED_FORUM_COURSE = 17; - const CHECK_EMAIL_CONNECT_MORE_INFO = 18; - const STUDENT_ANSWERED_TEST = 19; - const STUDENT_ANSWERED_TEST_OPEN_QUESTION = 20; - const STUDENT_ANSWERED_TEST_VOICE_QUESTION = 21; - const ANSWER_OPEN_QUESTION_TEST_REVIEWED = 22; - const NEW_THREAD_STARTED_FORUM = 23; - const NEW_ANSWER_POSTED_FORUM = 24; - const NEW_SYSTEM_ANNOUNCEMENT_ADDED = 25; - const TEST_NEW_SYSTEM_ANNOUNCEMENT_ADDED = 26; - const SYSTEM_ANNOUNCEMENT_UPDATE = 27; - const TEST_SYSTEM_ANNOUNCEMENT_UPDATE = 28; - const USER_UPLOADED_ASSIGNMENT_COURSE_STUDENT_SUBMITS_PAPER = 29; - const USER_UPLOADED_ASSIGNMENT_CHECK_STUDENT_SUBMITS_PAPER = 30; - const USER_UPLOADED_ASSIGNMENT_COURSE = 31; - const USER_UPLOADED_ASSIGNMENT_CHECK = 32; - const SUBSCRIBED_SESSION = 33; - const SUBSCRIBED_SESSION_CSV = 34; - const USER_SUGGESTED_BE_FRIENDS = 35; - const USER_ANSWERED_INBOX_MESSAGE = 36; - const BEEN_INVITED_JOIN_GROUP = 37; - const MESSAGES_SENT_EDITED_GROUP_EDITED = 38; - const MESSAGES_SENT_EDITED_GROUP_ADDED = 39; - const BEEN_INVITED_COMPLETE_SURVEY_COURSE = 40; - const REMINDER_ASSIGNMENT_COURSE_DUE = 41; - const USER_DETAILS_MODIFIED = 42; - - public $isCoursePlugin = true; - public $isMailPlugin = true; - /** * create (a singleton function that ensures ClockworksmsPlugin instance is * created only once. If it is already created, it returns the instance) @@ -72,7 +26,7 @@ class ClockworksmsPlugin extends Plugin * Constructor * @return void */ - protected function __construct() + public function __construct() { $fields = array('tool_enable' => 'boolean', 'api_key' => 'text'); $smsTypeOptions = $this->getSmsTypeOptions(); @@ -82,91 +36,7 @@ class ClockworksmsPlugin extends Plugin parent::__construct('0.1', 'Imanol Losada', $fields); } - /** - * addMobilePhoneNumberField (adds a mobile phone number field if it is not - * already created) - * @return void - */ - private function addMobilePhoneNumberField() - { - $result = Database::select('mobile_phone_number', 'user_field'); - if (empty($result)) { - require_once api_get_path(LIBRARY_PATH).'extra_field.lib.php'; - $extraField = new Extrafield('user'); - $extraField->save(array( - 'field_type' => 1, - 'field_variable' => 'mobile_phone_number', - 'field_display_text' => $this->get_lang('mobile_phone_number'), - 'field_default_value' => null, - 'field_order' => 2, - 'field_visible' => 1, - 'field_changeable' => 1, - 'field_filter' => null - )); - } - } - - /** - * getSmsTypeOptions (returns all SMS types) - * @return array SMS types - */ - private function getSmsTypeOptions() - { - return array( - 'MessageWelcomeXLoginXPasswordX', - 'MessageXNewFileSharedCourseXByX', - 'MessageXAccountApprovedConnectX', - 'MessageXNewCourseXBeenCreatedX', - 'MessageXNewUserXSubscribedCourseX', - 'MessageXNewCourseSuggestedTeacherX', - 'MessageXCourseOpeningRequestCodeXRegistered', - 'MessageXCourseOpeningRequestCourseCodeXApproved', - 'MessageXRequestOpenCourseCodeXReject', - 'MessageXCourseOpeningRequestCourseCodeX', - 'MessageXBeenSubscribedCourseX', - 'MessageXAssignmentBeenCreatedCourseX', - 'MessageXAccountCreatedUpdatedLoginXPasswordX', - 'MessageXPasswordUpdatedLoginXPasswordX', - 'MessageXRequestedPasswordChange', - 'MessageXReceivedNewPersonalMessages', - 'MessageXNewUserXPendingApproval', - 'MessageXXPostedForumXCourseX', - 'MessageXXXCheckEmailConnectMoreInfo', - 'MessageXXStudentXAnsweredTestX', - 'MessageXXStudentXAnsweredTestXOpenQuestion', - 'MessageXXStudentXAnsweredTestXVoiceQuestion', - 'MessageXXAnswerOpenQuestionTestXReviewed', - 'MessageXXNewThreadXStartedForumX', - 'MessageXXNewAnswerPostedXForumX', - 'MessageXXNewSystemAnnouncementAdded', - 'MessageXTestXNewSystemAnnouncementAdded', - 'MessageXXSystemAnnouncementUpdate', - 'MessageXTestXSystemAnnouncementUpdate', - 'MessageXUserXUploadedAssignmentXCourseXStudentSubmitsPaper', - 'MessageXUserXUploadedAssignmentXCheckXStudentSubmitsPaper', - 'MessageXUserXUploadedAssignmentXCourseX', - 'MessageXUserXUploadedAssignmentXCheckX', - 'MessageXSubscribedSessionX', - 'MessageXSubscribedSessionXCSV', - 'MessageXUserXSuggestedBeFriends', - 'MessageXUserXAnsweredInboxMessage', - 'MessageXBeenInvitedJoinGroupX', - 'MessageXMessagesSentEditedGroupXEdited', - 'MessageXMessagesSentEditedGroupXAdded', - 'MessageXBeenInvitedCompleteSurveyXCourseX', - 'MessageXReminderAssignmentXCourseXDue', - 'MessageXUserDetailsModified' - ); - } - /** - * install (installs the plugin) - * @return void - */ - public function install() - { - $this->addMobilePhoneNumberField(); - } /** * install (uninstalls the plugin and removes all plugin's tables and/or rows) * @return void diff --git a/plugin/createdrupaluser/src/CreateDrupalUser.php b/plugin/createdrupaluser/src/CreateDrupalUser.php index 0f41abd815..40924a0e3d 100644 --- a/plugin/createdrupaluser/src/CreateDrupalUser.php +++ b/plugin/createdrupaluser/src/CreateDrupalUser.php @@ -9,7 +9,6 @@ */ class CreateDrupalUser extends Plugin implements HookPluginInterface { - /** * Class constructor */ @@ -56,8 +55,9 @@ class CreateDrupalUser extends Plugin implements HookPluginInterface */ public function installHook() { - $hook = HookCreateDrupalUser::create(); - HookCreateUser::create()->attach($hook); + /** @var HookCreateDrupalUser $observer */ + $observer = HookCreateDrupalUser::create(); + HookCreateUser::create()->attach($observer); } /** @@ -65,8 +65,13 @@ class CreateDrupalUser extends Plugin implements HookPluginInterface */ public function uninstallHook() { - $hook = HookCreateDrupalUser::create(); - HookCreateUser::create()->detach($hook); + /** @var HookCreateDrupalUser $observer */ + $observer = HookCreateDrupalUser::create(); + $event = HookCreateUser::create(); + + if ($event) { + $event->detach($observer); + } } } diff --git a/plugin/createdrupaluser/src/HookCreateDrupalUser.php b/plugin/createdrupaluser/src/HookCreateDrupalUser.php index 3ae11ca0b2..6c9d21d8af 100644 --- a/plugin/createdrupaluser/src/HookCreateDrupalUser.php +++ b/plugin/createdrupaluser/src/HookCreateDrupalUser.php @@ -2,6 +2,7 @@ /* For licensing terms, see /license.txt */ /** + * Class HookCreateDrupalUser * Hook to create an user in Drupal website * * @author Angel Fernando Quiroz Campos @@ -9,9 +10,8 @@ */ class HookCreateDrupalUser extends HookObserver implements HookCreateUserObserverInterface { - /** - * Class constructor + * Constructor */ public function __construct() { diff --git a/plugin/dashboard/block_course/block_course.class.php b/plugin/dashboard/block_course/block_course.class.php index cfa6f6ae8b..4fb8c8f550 100755 --- a/plugin/dashboard/block_course/block_course.class.php +++ b/plugin/dashboard/block_course/block_course.class.php @@ -163,7 +163,7 @@ class BlockCourse extends Block // students directly subscribed to the course $sql = "SELECT user_id FROM $tbl_course_user as course_rel_user - WHERE course_rel_user.status=" . STUDENT . " AND course_rel_user.course_code='$course_code'"; + WHERE course_rel_user.status=" . STUDENT . " AND course_rel_user.c_id='$courseId'"; $rs = Database::query($sql); $users = array(); while ($row = Database::fetch_array($rs)) { diff --git a/plugin/kannelsms/lib/kannelsms.lib.php b/plugin/kannelsms/lib/kannelsms.lib.php index 84a61cf3af..b32589f822 100644 --- a/plugin/kannelsms/lib/kannelsms.lib.php +++ b/plugin/kannelsms/lib/kannelsms.lib.php @@ -10,8 +10,7 @@ * * Kannelsms-Chamilo connector class */ - -class Kannelsms +class Kannelsms implements SmsPluginLibraryInterface { public $api; public $hostAddress; @@ -45,7 +44,7 @@ class Kannelsms * @param int $userId User id * @return int User's mobile phone number */ - private function getMobilePhoneNumberById($userId) + public function getMobilePhoneNumberById($userId) { $mobilePhoneNumberExtraField = new ExtraField('user'); $mobilePhoneNumberExtraField = $mobilePhoneNumberExtraField->get_handler_field_info_by_field_variable('mobile_phone_number'); @@ -153,7 +152,7 @@ class Kannelsms $tpl = new Template($tool_name); switch ($additionalParameters['smsType']) { - case KannelsmsPlugin::WELCOME_LOGIN_PASSWORD: + case SmsPlugin::WELCOME_LOGIN_PASSWORD: $userInfo = api_get_user_info($additionalParameters['userId']); return $this->buildSms( $plugin, @@ -167,7 +166,7 @@ class Kannelsms ) ); break; - case KannelsmsPlugin::NEW_FILE_SHARED_COURSE_BY: + case SmsPlugin::NEW_FILE_SHARED_COURSE_BY: return $this->buildSms( $plugin, $tpl, @@ -180,7 +179,7 @@ class Kannelsms ) ); break; - case KannelsmsPlugin::ACCOUNT_APPROVED_CONNECT: + case SmsPlugin::ACCOUNT_APPROVED_CONNECT: return $this->buildSms( $plugin, $tpl, @@ -192,7 +191,7 @@ class Kannelsms ) ); break; - case KannelsmsPlugin::NEW_COURSE_BEEN_CREATED: + case SmsPlugin::NEW_COURSE_BEEN_CREATED: return $this->buildSms( $plugin, $tpl, @@ -205,7 +204,7 @@ class Kannelsms ) ); break; - case KannelsmsPlugin::NEW_USER_SUBSCRIBED_COURSE: + case SmsPlugin::NEW_USER_SUBSCRIBED_COURSE: return $this->buildSms( $plugin, $tpl, @@ -218,7 +217,7 @@ class Kannelsms ) ); break; - case KannelsmsPlugin::NEW_COURSE_SUGGESTED_TEACHER: + case SmsPlugin::NEW_COURSE_SUGGESTED_TEACHER: return $this->buildSms( $plugin, $tpl, @@ -230,7 +229,7 @@ class Kannelsms ) ); break; - case KannelsmsPlugin::COURSE_OPENING_REQUEST_CODE_REGISTERED: + case SmsPlugin::COURSE_OPENING_REQUEST_CODE_REGISTERED: return $this->buildSms( $plugin, $tpl, @@ -242,7 +241,7 @@ class Kannelsms ) ); break; - case KannelsmsPlugin::COURSE_OPENING_REQUEST_CODE_APPROVED: + case SmsPlugin::COURSE_OPENING_REQUEST_CODE_APPROVED: return $this->buildSms( $plugin, $tpl, @@ -254,7 +253,7 @@ class Kannelsms ) ); break; - case KannelsmsPlugin::COURSE_OPENING_REQUEST_CODE_REJECTED: + case SmsPlugin::COURSE_OPENING_REQUEST_CODE_REJECTED: return $this->buildSms( $plugin, $tpl, @@ -266,7 +265,7 @@ class Kannelsms ) ); break; - case KannelsmsPlugin::COURSE_OPENING_REQUEST_CODE: + case SmsPlugin::COURSE_OPENING_REQUEST_CODE: return $this->buildSms( $plugin, $tpl, @@ -278,7 +277,7 @@ class Kannelsms ) ); break; - case KannelsmsPlugin::BEEN_SUBSCRIBED_COURSE: + case SmsPlugin::BEEN_SUBSCRIBED_COURSE: return $this->buildSms( $plugin, $tpl, @@ -290,7 +289,7 @@ class Kannelsms ) ); break; - case KannelsmsPlugin::ASSIGNMENT_BEEN_CREATED_COURSE: + case SmsPlugin::ASSIGNMENT_BEEN_CREATED_COURSE: return $this->buildSms( $plugin, $tpl, @@ -303,7 +302,7 @@ class Kannelsms ); break; // Message types to be implemented. Fill the array parameter with arguments. - /*case KannelsmsPlugin::ACCOUNT_CREATED_UPDATED_LOGIN_PASSWORD: + /*case SmsPlugin::ACCOUNT_CREATED_UPDATED_LOGIN_PASSWORD: return $this->buildSms( $plugin, $tpl, @@ -314,7 +313,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::PASSWORD_UPDATED_LOGIN_PASSWORD: + /*case SmsPlugin::PASSWORD_UPDATED_LOGIN_PASSWORD: return $this->buildSms( $plugin, $tpl, @@ -325,7 +324,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::REQUESTED_PASSWORD_CHANGE: + /*case SmsPlugin::REQUESTED_PASSWORD_CHANGE: return $this->buildSms( $plugin, $tpl, @@ -336,7 +335,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::RECEIVED_NEW_PERSONAL_MESSAGES: + /*case SmsPlugin::RECEIVED_NEW_PERSONAL_MESSAGES: return $this->buildSms( $plugin, $tpl, @@ -347,7 +346,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::NEW_USER_PENDING_APPROVAL: + /*case SmsPlugin::NEW_USER_PENDING_APPROVAL: return $this->buildSms( $plugin, $tpl, @@ -358,7 +357,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::POSTED_FORUM_COURSE: + /*case SmsPlugin::POSTED_FORUM_COURSE: return $this->buildSms( $plugin, $tpl, @@ -369,7 +368,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::CHECK_EMAIL_CONNECT_MORE_INFO: + /*case SmsPlugin::CHECK_EMAIL_CONNECT_MORE_INFO: return $this->buildSms( $plugin, $tpl, @@ -380,7 +379,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::STUDENT_ANSWERED_TEST: + /*case SmsPlugin::STUDENT_ANSWERED_TEST: return $this->buildSms( $plugin, $tpl, @@ -391,7 +390,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::STUDENT_ANSWERED_TEST_OPEN_QUESTION: + /*case SmsPlugin::STUDENT_ANSWERED_TEST_OPEN_QUESTION: return $this->buildSms( $plugin, $tpl, @@ -402,7 +401,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::STUDENT_ANSWERED_TEST_VOICE_QUESTION: + /*case SmsPlugin::STUDENT_ANSWERED_TEST_VOICE_QUESTION: return $this->buildSms( $plugin, $tpl, @@ -413,7 +412,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::ANSWER_OPEN_QUESTION_TEST_REVIEWED: + /*case SmsPlugin::ANSWER_OPEN_QUESTION_TEST_REVIEWED: return $this->buildSms( $plugin, $tpl, @@ -424,7 +423,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::NEW_THREAD_STARTED_FORUM: + /*case SmsPlugin::NEW_THREAD_STARTED_FORUM: return $this->buildSms( $plugin, $tpl, @@ -435,7 +434,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::NEW_ANSWER_POSTED_FORUM: + /*case SmsPlugin::NEW_ANSWER_POSTED_FORUM: return $this->buildSms( $plugin, $tpl, @@ -446,7 +445,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::NEW_SYSTEM_ANNOUNCEMENT_ADDED: + /*case SmsPlugin::NEW_SYSTEM_ANNOUNCEMENT_ADDED: return $this->buildSms( $plugin, $tpl, @@ -457,7 +456,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::TEST_NEW_SYSTEM_ANNOUNCEMENT_ADDED: + /*case SmsPlugin::TEST_NEW_SYSTEM_ANNOUNCEMENT_ADDED: return $this->buildSms( $plugin, $tpl, @@ -468,7 +467,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::SYSTEM_ANNOUNCEMENT_UPDATE: + /*case SmsPlugin::SYSTEM_ANNOUNCEMENT_UPDATE: return $this->buildSms( $plugin, $tpl, @@ -479,7 +478,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::TEST_SYSTEM_ANNOUNCEMENT_UPDATE: + /*case SmsPlugin::TEST_SYSTEM_ANNOUNCEMENT_UPDATE: return $this->buildSms( $plugin, $tpl, @@ -490,7 +489,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::USER_UPLOADED_ASSIGNMENT_COURSE_STUDENT_SUBMITS_PAPER: + /*case SmsPlugin::USER_UPLOADED_ASSIGNMENT_COURSE_STUDENT_SUBMITS_PAPER: return $this->buildSms( $plugin, $tpl, @@ -501,7 +500,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::USER_UPLOADED_ASSIGNMENT_CHECK_STUDENT_SUBMITS_PAPER: + /*case SmsPlugin::USER_UPLOADED_ASSIGNMENT_CHECK_STUDENT_SUBMITS_PAPER: return $this->buildSms( $plugin, $tpl, @@ -512,7 +511,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::USER_UPLOADED_ASSIGNMENT_COURSE: + /*case SmsPlugin::USER_UPLOADED_ASSIGNMENT_COURSE: return $this->buildSms( $plugin, $tpl, @@ -523,7 +522,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::USER_UPLOADED_ASSIGNMENT_CHECK: + /*case SmsPlugin::USER_UPLOADED_ASSIGNMENT_CHECK: return $this->buildSms( $plugin, $tpl, @@ -534,7 +533,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::SUBSCRIBED_SESSION: + /*case SmsPlugin::SUBSCRIBED_SESSION: return $this->buildSms( $plugin, $tpl, @@ -545,7 +544,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::SUBSCRIBED_SESSION_CSV: + /*case SmsPlugin::SUBSCRIBED_SESSION_CSV: return $this->buildSms( $plugin, $tpl, @@ -556,7 +555,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::USER_SUGGESTED_BE_FRIENDS: + /*case SmsPlugin::USER_SUGGESTED_BE_FRIENDS: return $this->buildSms( $plugin, $tpl, @@ -567,7 +566,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::USER_ANSWERED_INBOX_MESSAGE: + /*case SmsPlugin::USER_ANSWERED_INBOX_MESSAGE: return $this->buildSms( $plugin, $tpl, @@ -578,7 +577,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::BEEN_INVITED_JOIN_GROUP: + /*case SmsPlugin::BEEN_INVITED_JOIN_GROUP: return $this->buildSms( $plugin, $tpl, @@ -589,7 +588,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::MESSAGES_SENT_EDITED_GROUP_EDITED: + /*case SmsPlugin::MESSAGES_SENT_EDITED_GROUP_EDITED: return $this->buildSms( $plugin, $tpl, @@ -600,7 +599,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::MESSAGES_SENT_EDITED_GROUP_ADDED: + /*case SmsPlugin::MESSAGES_SENT_EDITED_GROUP_ADDED: return $this->buildSms( $plugin, $tpl, @@ -611,7 +610,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::BEEN_INVITED_COMPLETE_SURVEY_COURSE: + /*case SmsPlugin::BEEN_INVITED_COMPLETE_SURVEY_COURSE: return $this->buildSms( $plugin, $tpl, @@ -622,7 +621,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::REMINDER_ASSIGNMENT_COURSE_DUE: + /*case SmsPlugin::REMINDER_ASSIGNMENT_COURSE_DUE: return $this->buildSms( $plugin, $tpl, @@ -633,7 +632,7 @@ class Kannelsms ) ); break;*/ - /*case KannelsmsPlugin::USER_DETAILS_MODIFIED: + /*case SmsPlugin::USER_DETAILS_MODIFIED: return $this->buildSms( $plugin, $tpl, diff --git a/plugin/kannelsms/lib/kannelsms_plugin.class.php b/plugin/kannelsms/lib/kannelsms_plugin.class.php index eaf6b65a00..ece978cc61 100644 --- a/plugin/kannelsms/lib/kannelsms_plugin.class.php +++ b/plugin/kannelsms/lib/kannelsms_plugin.class.php @@ -4,59 +4,13 @@ /** * Class KannelsmsPlugin * This script contains SMS type constants and basic plugin functions - * + * * @package chamilo.plugin.kannelsms.lib * @author Imanol Losada + * @author Julio Montoya Refactor code */ -class KannelsmsPlugin extends Plugin +class KannelsmsPlugin extends SmsPlugin { - const WELCOME_LOGIN_PASSWORD = 0; - const NEW_FILE_SHARED_COURSE_BY = 1; - const ACCOUNT_APPROVED_CONNECT = 2; - const NEW_COURSE_BEEN_CREATED = 3; - const NEW_USER_SUBSCRIBED_COURSE = 4; - const NEW_COURSE_SUGGESTED_TEACHER = 5; - const COURSE_OPENING_REQUEST_CODE_REGISTERED = 6; - const COURSE_OPENING_REQUEST_CODE_APPROVED = 7; - const COURSE_OPENING_REQUEST_CODE_REJECTED = 8; - const COURSE_OPENING_REQUEST_CODE = 9; - const BEEN_SUBSCRIBED_COURSE = 10; - const ASSIGNMENT_BEEN_CREATED_COURSE = 11; - const ACCOUNT_CREATED_UPDATED_LOGIN_PASSWORD = 12; - const PASSWORD_UPDATED_LOGIN_PASSWORD = 13; - const REQUESTED_PASSWORD_CHANGE = 14; - const RECEIVED_NEW_PERSONAL_MESSAGES = 15; - const NEW_USER_PENDING_APPROVAL = 16; - const POSTED_FORUM_COURSE = 17; - const CHECK_EMAIL_CONNECT_MORE_INFO = 18; - const STUDENT_ANSWERED_TEST = 19; - const STUDENT_ANSWERED_TEST_OPEN_QUESTION = 20; - const STUDENT_ANSWERED_TEST_VOICE_QUESTION = 21; - const ANSWER_OPEN_QUESTION_TEST_REVIEWED = 22; - const NEW_THREAD_STARTED_FORUM = 23; - const NEW_ANSWER_POSTED_FORUM = 24; - const NEW_SYSTEM_ANNOUNCEMENT_ADDED = 25; - const TEST_NEW_SYSTEM_ANNOUNCEMENT_ADDED = 26; - const SYSTEM_ANNOUNCEMENT_UPDATE = 27; - const TEST_SYSTEM_ANNOUNCEMENT_UPDATE = 28; - const USER_UPLOADED_ASSIGNMENT_COURSE_STUDENT_SUBMITS_PAPER = 29; - const USER_UPLOADED_ASSIGNMENT_CHECK_STUDENT_SUBMITS_PAPER = 30; - const USER_UPLOADED_ASSIGNMENT_COURSE = 31; - const USER_UPLOADED_ASSIGNMENT_CHECK = 32; - const SUBSCRIBED_SESSION = 33; - const SUBSCRIBED_SESSION_CSV = 34; - const USER_SUGGESTED_BE_FRIENDS = 35; - const USER_ANSWERED_INBOX_MESSAGE = 36; - const BEEN_INVITED_JOIN_GROUP = 37; - const MESSAGES_SENT_EDITED_GROUP_EDITED = 38; - const MESSAGES_SENT_EDITED_GROUP_ADDED = 39; - const BEEN_INVITED_COMPLETE_SURVEY_COURSE = 40; - const REMINDER_ASSIGNMENT_COURSE_DUE = 41; - const USER_DETAILS_MODIFIED = 42; - - public $isCoursePlugin = true; - public $isMailPlugin = true; - /** * create (a singleton function that ensures KannelsmsPlugin instance is * created only once. If it is already created, it returns the instance) @@ -88,91 +42,6 @@ class KannelsmsPlugin extends Plugin parent::__construct('0.1', 'Imanol Losada', $fields); } - /** - * addMobilePhoneNumberField (adds a mobile phone number field if it is not - * already created) - * @return void - */ - private function addMobilePhoneNumberField() - { - $result = Database::select('mobile_phone_number', 'user_field'); - if (empty($result)) { - require_once api_get_path(LIBRARY_PATH).'extra_field.lib.php'; - $extraField = new Extrafield('user'); - $extraField->save(array( - 'field_type' => 1, - 'field_variable' => 'mobile_phone_number', - 'field_display_text' => $this->get_lang('mobile_phone_number'), - 'field_default_value' => null, - 'field_order' => 2, - 'field_visible' => 1, - 'field_changeable' => 1, - 'field_filter' => null - )); - } - } - - /** - * getSmsTypeOptions (returns all SMS types) - * @return array SMS types - */ - private function getSmsTypeOptions() - { - return array( - 'MessageWelcomeXLoginXPasswordX', - 'MessageXNewFileSharedCourseXByX', - 'MessageXAccountApprovedConnectX', - 'MessageXNewCourseXBeenCreatedX', - 'MessageXNewUserXSubscribedCourseX', - 'MessageXNewCourseSuggestedTeacherX', - 'MessageXCourseOpeningRequestCodeXRegistered', - 'MessageXCourseOpeningRequestCourseCodeXApproved', - 'MessageXRequestOpenCourseCodeXReject', - 'MessageXCourseOpeningRequestCourseCodeX', - 'MessageXBeenSubscribedCourseX', - 'MessageXAssignmentBeenCreatedCourseX', - 'MessageXAccountCreatedUpdatedLoginXPasswordX', - 'MessageXPasswordUpdatedLoginXPasswordX', - 'MessageXRequestedPasswordChange', - 'MessageXReceivedNewPersonalMessages', - 'MessageXNewUserXPendingApproval', - 'MessageXXPostedForumXCourseX', - 'MessageXXXCheckEmailConnectMoreInfo', - 'MessageXXStudentXAnsweredTestX', - 'MessageXXStudentXAnsweredTestXOpenQuestion', - 'MessageXXStudentXAnsweredTestXVoiceQuestion', - 'MessageXXAnswerOpenQuestionTestXReviewed', - 'MessageXXNewThreadXStartedForumX', - 'MessageXXNewAnswerPostedXForumX', - 'MessageXXNewSystemAnnouncementAdded', - 'MessageXTestXNewSystemAnnouncementAdded', - 'MessageXXSystemAnnouncementUpdate', - 'MessageXTestXSystemAnnouncementUpdate', - 'MessageXUserXUploadedAssignmentXCourseXStudentSubmitsPaper', - 'MessageXUserXUploadedAssignmentXCheckXStudentSubmitsPaper', - 'MessageXUserXUploadedAssignmentXCourseX', - 'MessageXUserXUploadedAssignmentXCheckX', - 'MessageXSubscribedSessionX', - 'MessageXSubscribedSessionXCSV', - 'MessageXUserXSuggestedBeFriends', - 'MessageXUserXAnsweredInboxMessage', - 'MessageXBeenInvitedJoinGroupX', - 'MessageXMessagesSentEditedGroupXEdited', - 'MessageXMessagesSentEditedGroupXAdded', - 'MessageXBeenInvitedCompleteSurveyXCourseX', - 'MessageXReminderAssignmentXCourseXDue', - 'MessageXUserDetailsModified' - ); - } - - /** - * install (installs the plugin) - * @return void - */ - public function install() - { - $this->addMobilePhoneNumberField(); - } /** * install (uninstalls the plugin and removes all plugin's tables and/or rows) * @return void diff --git a/plugin/resubscription/src/HookResubscription.php b/plugin/resubscription/src/HookResubscription.php index 0901d10188..819bba22da 100644 --- a/plugin/resubscription/src/HookResubscription.php +++ b/plugin/resubscription/src/HookResubscription.php @@ -31,7 +31,7 @@ class HookResubscription extends HookObserver implements HookResubscribeObserver $resubscriptionLimit = Resubscription::create()->get('resubscription_limit'); - // Initialize variables as a calendar year by default + // Initialize variables as a calendar year by default $limitDateFormat = 'Y-01-01'; $limitDate = gmdate($limitDateFormat); $resubscriptionOffset = "1 year"; @@ -44,15 +44,15 @@ class HookResubscription extends HookObserver implements HookResubscribeObserver $limitDate = gmdate($limitDateFormat, strtotime("$limitDate -$resubscriptionOffset")); } - $join = " INNER JOIN ".Database::get_main_table(TABLE_MAIN_SESSION)."ON id = id_session"; + $join = " INNER JOIN ".Database::get_main_table(TABLE_MAIN_SESSION)."ON id = session_id"; // User sessions and courses $userSessions = Database::select( - 'id_session, date_end', + 'session_id, date_end', Database::get_main_table(TABLE_MAIN_SESSION_USER).$join, array( 'where' => array( - 'id_user = ? AND date_end >= ?' => array( + 'user_id = ? AND date_end >= ?' => array( api_get_user_id(), $limitDate ) @@ -67,15 +67,15 @@ class HookResubscription extends HookObserver implements HookResubscribeObserver Database::get_main_table(TABLE_MAIN_SESSION_COURSE), array( 'where' => array( - 'id_session = ?' => array( - $userSession['id_session'] + 'session_id = ?' => array( + $userSession['session_id'] ) ) ) ); foreach ($userSessionCourseResult as $userSessionCourse) { - if (!isset($userSessionCourses[$userSessionCourse['course_code']])) { - $userSessionCourses[$userSessionCourse['course_code']] = $userSession['date_end']; + if (!isset($userSessionCourses[$userSessionCourse['c_id']])) { + $userSessionCourses[$userSessionCourse['c_id']] = $userSession['date_end']; } } @@ -83,11 +83,11 @@ class HookResubscription extends HookObserver implements HookResubscribeObserver // Current session and courses $currentSessionCourseResult = Database::select( - 'course_code', + 'c_id', Database::get_main_table(TABLE_MAIN_SESSION_COURSE), array( 'where' => array( - 'id_session = ?' => array( + 'session_id = ?' => array( $data['session_id'] ) ) diff --git a/plugin/search_course/lib/search_course_widget.class.php b/plugin/search_course/lib/search_course_widget.class.php index 30fd407320..3792758a7e 100755 --- a/plugin/search_course/lib/search_course_widget.class.php +++ b/plugin/search_course/lib/search_course_widget.class.php @@ -3,9 +3,9 @@ require_once dirname(__FILE__) . '/register_course_widget.class.php'; /** - * Search course widget. + * Search course widget. * Display a search form and a list of courses that matches the search. - * + * * @copyright (c) 2011 University of Geneva * @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html * @author Laurent Opprecht @@ -18,10 +18,10 @@ class SearchCourseWidget /** * Returns $_POST data for $key is it exists or $default otherwise. - * + * * @param string $key * @param object $default - * @return string + * @return string */ public static function post($key, $default = '') { @@ -30,10 +30,10 @@ class SearchCourseWidget /** * Returns $_GET data for $key is it exists or $default otherwise. - * + * * @param string $key * @param object $default - * @return string + * @return string */ public static function get($key, $default = '') { @@ -91,7 +91,7 @@ class SearchCourseWidget } /** - * + * */ function accept() { @@ -100,10 +100,10 @@ class SearchCourseWidget /** * Display the search course widget: - * + * * Title * Search form - * + * * Search results */ function run() @@ -216,7 +216,7 @@ EOT; /** * * @param array $courses - * @return bool + * @return bool */ function display_list($courses) { @@ -227,8 +227,8 @@ EOT; $user_courses = $this->retrieve_user_courses(); - $display_coursecode = (get_setting('display_coursecode_in_courselist') == 'true'); - $display_teacher = (get_setting('display_teacher_in_courselist') == 'true'); + $display_coursecode = (api_get_setting('display_coursecode_in_courselist') == 'true'); + $display_teacher = (api_get_setting('display_teacher_in_courselist') == 'true'); echo ''; foreach ($courses as $key => $course) @@ -262,13 +262,13 @@ EOT; } /** - * Displays the subscribe icon if subscribing is allowed and + * Displays the subscribe icon if subscribing is allowed and * if the user is not yet subscribed to this course - * + * * @global type $stok * @param array $current_course * @param array $user_courses - * @return bool + * @return bool */ function display_subscribe_icon($current_course, $user_courses) { @@ -289,7 +289,7 @@ EOT; return false; } - //Subscribe form + //Subscribe form $self = $_SERVER['PHP_SELF']; echo << @@ -323,9 +323,9 @@ EOT; /** * Search courses that match the search term. * Search is done on the code, title and tutor fields. - * - * @param string $search_term - * @return array + * + * @param string $search_term + * @return array */ function retrieve_courses($search_term) { @@ -348,15 +348,14 @@ EOT; } $sql = << $code, @@ -374,9 +373,9 @@ EOT; /** * Retrieves courses that the user is subscribed to - * + * * @param int $user_id - * @return array + * @return array */ function retrieve_user_courses($user_id = null) { @@ -390,19 +389,17 @@ EOT; $user_id = intval($user_id); $sql_select_courses = "SELECT course.code k, course.visual_code vc, course.subscribe subscr, course.unsubscribe unsubscr, - course.title i, course.tutor_name t, course.db_name db, course.directory dir, course_rel_user.status status, + course.title i, course.tutor_name t, course.directory dir, course_rel_user.status status, course_rel_user.sort sort, course_rel_user.user_course_cat user_course_cat FROM $course_table course, $user_course_table course_rel_user - WHERE course.code = course_rel_user.course_code + WHERE course.id = course_rel_user.c_id AND course_rel_user.user_id = $user_id ORDER BY course_rel_user.sort ASC"; $result = array(); - $resultset = api_sql_query($sql_select_courses, __FILE__, __LINE__); - while ($row = Database::fetch_array($resultset)) - { + $resultset = Database::query($sql_select_courses); + while ($row = Database::fetch_array($resultset)) { $code = $row['k']; $result[$code] = array( - 'db' => $row['db'], 'code' => $code, 'visual_code' => $row['vc'], 'title' => $row['i'], @@ -414,19 +411,20 @@ EOT; 'sort' => $row['sort'], 'user_course_category' => $row['user_course_cat']); } + return $result; } /* - * Utility functions - Utility functions - Utility functions + * Utility functions - Utility functions - Utility functions */ /** * Removes from $courses all courses the user is subscribed to. - * + * * @global array $_user * @param array $courses - * @return array + * @return array */ function filter_out_user_courses($courses) { diff --git a/plugin/ticket/src/myticket.php b/plugin/ticket/src/myticket.php index 177297fca9..a0e79494e4 100755 --- a/plugin/ticket/src/myticket.php +++ b/plugin/ticket/src/myticket.php @@ -183,7 +183,7 @@ if (isset($_GET['action'])) { ); $data[] = $ticket_rem; } - Export::export_table_xls($data, $plugin->get_lang('Tickets')); + Export::arrayToXls($data, $plugin->get_lang('Tickets')); exit; break; case 'close_tickets': diff --git a/plugin/ticket/src/send_ticket.php b/plugin/ticket/src/send_ticket.php deleted file mode 100755 index fd8d5278a5..0000000000 --- a/plugin/ticket/src/send_ticket.php +++ /dev/null @@ -1,288 +0,0 @@ - -$(document).ready(function(){ - if(document.getElementById("divEmail")){ - document.getElementById("divEmail").style.display="none"; - } -}); -function changeType() { -var selected = document.getElementById("category_id").selectedIndex; -var id = document.getElementById("category_id").options[selected].value ; - document.getElementById("project_id").value= projects[id]; - document.getElementById("other_area").value= other_area[id]; - document.getElementById("email").value= email[id]; - document.getElementById("divEmail").style.display="none"; - if(parseInt(course_required[id]) == 0){ - document.getElementById("divCourse").style.display="none"; - if( id != "CUR"){ - document.getElementById("divEmail").style.display=""; - document.getElementById("personal_email").required="required"; - } - document.getElementById("course_id").disabled=true; - document.getElementById("course_id").value=0; - }else{ - document.getElementById("divCourse").style.display = ""; - document.getElementById("course_id").disabled=false; - document.getElementById("course_id").value=0; - document.getElementById("personal_email").value=""; - } -} - -function validate() { - var re = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; - fckEditor1val = FCKeditorAPI.__Instances["content"].GetHTML(); - document.getElementById("content").value= fckEditor1val; - var selected = document.getElementById("category_id").selectedIndex; - var id = document.getElementById("category_id").options[selected].value; - if( id == 0){ - alert("' . $plugin->get_lang("ValidType") . '"); - return false; - }else if(document.getElementById("subject").value == ""){ - alert("' . $plugin->get_lang("ValidSubject") . '"); - return false; - }else if(parseInt(course_required[id]) == 1 && document.getElementById("course_id").value == 0){ - alert("' . $plugin->get_lang("ValidCourse") . '"); - return false; - }else if(id !="CUR" && parseInt(course_required[id]) != 1 && !re.test(document.getElementById("personal_email").value)){ - alert("' . $plugin->get_lang("ValidEmail") . '"); - return false; - }else if(fckEditor1val ==""){ - alert("' . $plugin->get_lang("ValidMessage") . '"); - return false; - } -} - -var counter_image = 1; -function remove_image_form(id_elem1) { - var elem1 = document.getElementById(id_elem1); - elem1.parentNode.removeChild(elem1); - counter_image = counter_image - 1; -} -function add_image_form() { - // Multiple filepaths for image form - var filepaths = document.getElementById("filepaths"); - if (document.getElementById("filepath_"+counter_image)) { - counter_image = counter_image + 1; - } else { - counter_image = counter_image; - } - var elem1 = document.createElement("div"); - elem1.setAttribute("id","filepath_"+counter_image); - filepaths.appendChild(elem1); - id_elem1 = "filepath_"+counter_image; - id_elem1 = "\'"+id_elem1+"\'"; - document.getElementById("filepath_"+counter_image).innerHTML = " "; - if (filepaths.childNodes.length == 6) { - var link_attach = document.getElementById("link-more-attach"); - if (link_attach) { - link_attach.innerHTML=""; - } - } -} -function show_question(questionid){ - if(document.getElementById("C"+questionid)){ - if(document.getElementById("A"+questionid).style.display == "none"){ - document.getElementById("A"+questionid).style.display = ""; - } - else if(document.getElementById("A"+questionid).style.display == ""){ - document.getElementById("A"+questionid).style.display = "none"; - } - } -} - - -'; -$types = TicketManager::get_all_tickets_categories(); -$htmlHeadXtra[] = ''; -$htmlHeadXtra[] = ''; -$htmlHeadXtra[] = ''; - -/** - * @todo Delete this function, it already exists in report.php - * @param string $s - * @return string - */ - -function js_str($s) -{ - return '"' . addcslashes($s, "\0..\37\"\\") . '"'; -} - -/** - * This is a javascript helper to generate and array - * @param array $array - * @param string $name - * @param integer $key - * @return string - */ -function js_array($array, $name, $key) -{ - $return = "new Array(); "; - foreach ($array as $value) { - $return .= $name . "['" . $value['category_id'] . "'] ='" . $value[$key] . "'; "; - } - return $return; -} - -/** - * - * @global array $types - * @global object $plugin - */ -function show_form_send_ticket() -{ - global $types, $plugin; - $courses_list = CourseManager::get_courses_list_by_user_id(api_get_user_id(), false, true); - echo '
    '; - echo '
    '; - $select_types = '
    -
    ' . get_lang('Category') . ':
    -
    '; - $select_types .= '"; - $select_types .= '
    '; - echo $select_types; - $select_course = '
    -
    ' . get_lang('Course') . ':
    -
    '; - $select_course .= '"; - $select_course .= '
    '; - echo $select_course; - echo '
    ' . get_lang('Subject') . ':
    -
    -
    '; - echo '
    ' . $plugin->get_lang('PersonalEmail') . ':
    -
    -
    '; - echo ''; - echo ''; - echo ''; - echo '
    -
    ' . get_lang('Message') . '
    -
    - - - -
    -
    '; - echo '
    ' . get_lang('Phone') . ' (' . $plugin->get_lang('Optional') . '):
    -
    -
    '; - echo '
    -
    ' . get_lang('FilesAttachment') . '
    -
    - -
    - -
    -
    -
    '; - echo '
    -
    - - ' . get_lang('AddOneMoreFile') . '  - (' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ') -
    -
    '; - echo '
    -
    -
    -
    -
    -
    '; - echo '
    '; -} -/** - * Save ticke function - */ -function save_ticket() -{ - global $plugin; - $category_id = $_POST['category_id']; - $content = $_POST['content']; - if ($_POST['phone'] != "") - $content.= '

     ' . get_lang('Phone') . ': ' . Security::remove_XSS($_POST['phone']). '

    '; - $course_id = $_POST['course_id']; - $project_id = $_POST['project_id']; - $subject = $_POST['subject']; - $other_area = (int) $_POST['other_area']; - $email = $_POST['email']; - $personal_email = $_POST['personal_email']; - $file_attachments = $_FILES; - - if (TicketManager::insert_new_ticket( - $category_id, - $course_id, - $project_id, - $other_area, - $email, - $subject, - $content, - $personal_email, - $file_attachments - ) - ) { - header('location:' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/src/myticket.php?message=success'); - exit; - } else { - Display::display_header(get_lang('ComposeMessage')); - Display::display_error_message($plugin->get_lang('ErrorRegisterMessage')); - } -} - -if (!isset($_POST['compose'])) { - Display::display_header(get_lang('ComposeMessage')); - show_form_send_ticket(); -} else { - save_ticket(); -} - -Display::display_footer(); diff --git a/plugin/ticket/src/tutor.php b/plugin/ticket/src/tutor.php index 91512309f8..84505721b6 100755 --- a/plugin/ticket/src/tutor.php +++ b/plugin/ticket/src/tutor.php @@ -95,7 +95,7 @@ function save() { $course_code = api_get_course_id(); $results = initializeReport($course_code); if (isset($_GET['action'])) { - Export::export_table_xls($results['export'], "COURSE_USER_REPORT" . $course_code); + Export::arrayToXls($results['export'], "COURSE_USER_REPORT" . $course_code); } else { Display::display_header(); api_protect_course_script(); diff --git a/plugin/ticket/src/tutor_report.lib.php b/plugin/ticket/src/tutor_report.lib.php index 3e35da7413..6755d53d2f 100755 --- a/plugin/ticket/src/tutor_report.lib.php +++ b/plugin/ticket/src/tutor_report.lib.php @@ -16,6 +16,7 @@ function initializeReport($course_code) $table_reporte_semanas = Database::get_main_table('rp_reporte_semanas'); $table_students_report = Database::get_main_table('rp_students_report'); $table_semanas_curso = Database::get_main_table('rp_semanas_curso'); + $courseTable = Database::get_main_table(TABLE_MAIN_COURSE); $table_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); $table_post = Database::get_course_table(TABLE_FORUM_POST, $course_info['dbName']); $table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION, $course_info['dbName']); @@ -43,10 +44,13 @@ function initializeReport($course_code) } } + $sql = "REPLACE INTO $table_students_report (user_id, week_report_id, work_ok , thread_ok , quiz_ok , pc_ok) SELECT cu.user_id, rs.id, 0, 0, 0, 0 FROM $table_course_rel_user cu - LEFT JOIN $table_reporte_semanas rs ON cu.course_code = rs.course_code + INNER JOIN $courseTable c + ON (c.id = cu.c_id) + LEFT JOIN $table_reporte_semanas rs ON c.code = rs.course_code WHERE cu.status = 5 AND rs.course_code = '$course_code' ORDER BY cu.user_id, rs.id"; if (!Database::query($sql)) { diff --git a/src/Chamilo/CoreBundle/Entity/AccessUrlRelSession.php b/src/Chamilo/CoreBundle/Entity/AccessUrlRelSession.php new file mode 100644 index 0000000000..0471e2823c --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/AccessUrlRelSession.php @@ -0,0 +1,80 @@ +accessUrlId = $accessUrlId; + + return $this; + } + + /** + * Get accessUrlId + * + * @return integer + */ + public function getAccessUrlId() + { + return $this->accessUrlId; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return AccessUrlRelSession + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/AccessUrlRelUser.php b/src/Chamilo/CoreBundle/Entity/AccessUrlRelUser.php new file mode 100644 index 0000000000..e0431c2fb4 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/AccessUrlRelUser.php @@ -0,0 +1,80 @@ +accessUrlId = $accessUrlId; + + return $this; + } + + /** + * Get accessUrlId + * + * @return integer + */ + public function getAccessUrlId() + { + return $this->accessUrlId; + } + + /** + * Set userId + * + * @param integer $userId + * @return AccessUrlRelUser + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/Admin.php b/src/Chamilo/CoreBundle/Entity/Admin.php new file mode 100644 index 0000000000..ee847af59d --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/Admin.php @@ -0,0 +1,65 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/AnnouncementRelGroup.php b/src/Chamilo/CoreBundle/Entity/AnnouncementRelGroup.php new file mode 100644 index 0000000000..ffdf811db9 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/AnnouncementRelGroup.php @@ -0,0 +1,80 @@ +groupId = $groupId; + + return $this; + } + + /** + * Get groupId + * + * @return integer + */ + public function getGroupId() + { + return $this->groupId; + } + + /** + * Set announcementId + * + * @param integer $announcementId + * @return AnnouncementRelGroup + */ + public function setAnnouncementId($announcementId) + { + $this->announcementId = $announcementId; + + return $this; + } + + /** + * Get announcementId + * + * @return integer + */ + public function getAnnouncementId() + { + return $this->announcementId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/Block.php b/src/Chamilo/CoreBundle/Entity/Block.php new file mode 100644 index 0000000000..0dd4942491 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/Block.php @@ -0,0 +1,185 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set description + * + * @param string $description + * @return Block + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set path + * + * @param string $path + * @return Block + */ + public function setPath($path) + { + $this->path = $path; + + return $this; + } + + /** + * Get path + * + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Set controller + * + * @param string $controller + * @return Block + */ + public function setController($controller) + { + $this->controller = $controller; + + return $this; + } + + /** + * Get controller + * + * @return string + */ + public function getController() + { + return $this->controller; + } + + /** + * Set active + * + * @param boolean $active + * @return Block + */ + public function setActive($active) + { + $this->active = $active; + + return $this; + } + + /** + * Get active + * + * @return boolean + */ + public function getActive() + { + return $this->active; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/Career.php b/src/Chamilo/CoreBundle/Entity/Career.php new file mode 100644 index 0000000000..0ba17f1e5a --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/Career.php @@ -0,0 +1,184 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set description + * + * @param string $description + * @return Career + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set status + * + * @param integer $status + * @return Career + */ + public function setStatus($status) + { + $this->status = $status; + + return $this; + } + + /** + * Get status + * + * @return integer + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set createdAt + * + * @param \DateTime $createdAt + * @return Career + */ + public function setCreatedAt($createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * Get createdAt + * + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Set updatedAt + * + * @param \DateTime $updatedAt + * @return Career + */ + public function setUpdatedAt($updatedAt) + { + $this->updatedAt = $updatedAt; + + return $this; + } + + /** + * Get updatedAt + * + * @return \DateTime + */ + public function getUpdatedAt() + { + return $this->updatedAt; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/Chat.php b/src/Chamilo/CoreBundle/Entity/Chat.php new file mode 100644 index 0000000000..467f91982a --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/Chat.php @@ -0,0 +1,185 @@ +fromUser = $fromUser; + + return $this; + } + + /** + * Get fromUser + * + * @return integer + */ + public function getFromUser() + { + return $this->fromUser; + } + + /** + * Set toUser + * + * @param integer $toUser + * @return Chat + */ + public function setToUser($toUser) + { + $this->toUser = $toUser; + + return $this; + } + + /** + * Get toUser + * + * @return integer + */ + public function getToUser() + { + return $this->toUser; + } + + /** + * Set message + * + * @param string $message + * @return Chat + */ + public function setMessage($message) + { + $this->message = $message; + + return $this; + } + + /** + * Get message + * + * @return string + */ + public function getMessage() + { + return $this->message; + } + + /** + * Set sent + * + * @param \DateTime $sent + * @return Chat + */ + public function setSent($sent) + { + $this->sent = $sent; + + return $this; + } + + /** + * Get sent + * + * @return \DateTime + */ + public function getSent() + { + return $this->sent; + } + + /** + * Set recd + * + * @param integer $recd + * @return Chat + */ + public function setRecd($recd) + { + $this->recd = $recd; + + return $this; + } + + /** + * Get recd + * + * @return integer + */ + public function getRecd() + { + return $this->recd; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/ClassItem.php b/src/Chamilo/CoreBundle/Entity/ClassItem.php new file mode 100644 index 0000000000..300b42e4e4 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/ClassItem.php @@ -0,0 +1,95 @@ +code = $code; + + return $this; + } + + /** + * Get code + * + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * Set name + * + * @param string $name + * @return Class + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + +} diff --git a/src/Chamilo/CoreBundle/Entity/ClassUser.php b/src/Chamilo/CoreBundle/Entity/ClassUser.php new file mode 100644 index 0000000000..ee70a76886 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/ClassUser.php @@ -0,0 +1,80 @@ +classId = $classId; + + return $this; + } + + /** + * Get classId + * + * @return integer + */ + public function getClassId() + { + return $this->classId; + } + + /** + * Set userId + * + * @param integer $userId + * @return ClassUser + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/CourseCategory.php b/src/Chamilo/CoreBundle/Entity/CourseCategory.php new file mode 100644 index 0000000000..ac74713849 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/CourseCategory.php @@ -0,0 +1,245 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set code + * + * @param string $code + * @return CourseCategory + */ + public function setCode($code) + { + $this->code = $code; + + return $this; + } + + /** + * Get code + * + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * Set parentId + * + * @param string $parentId + * @return CourseCategory + */ + public function setParentId($parentId) + { + $this->parentId = $parentId; + + return $this; + } + + /** + * Get parentId + * + * @return string + */ + public function getParentId() + { + return $this->parentId; + } + + /** + * Set treePos + * + * @param integer $treePos + * @return CourseCategory + */ + public function setTreePos($treePos) + { + $this->treePos = $treePos; + + return $this; + } + + /** + * Get treePos + * + * @return integer + */ + public function getTreePos() + { + return $this->treePos; + } + + /** + * Set childrenCount + * + * @param integer $childrenCount + * @return CourseCategory + */ + public function setChildrenCount($childrenCount) + { + $this->childrenCount = $childrenCount; + + return $this; + } + + /** + * Get childrenCount + * + * @return integer + */ + public function getChildrenCount() + { + return $this->childrenCount; + } + + /** + * Set authCourseChild + * + * @param string $authCourseChild + * @return CourseCategory + */ + public function setAuthCourseChild($authCourseChild) + { + $this->authCourseChild = $authCourseChild; + + return $this; + } + + /** + * Get authCourseChild + * + * @return string + */ + public function getAuthCourseChild() + { + return $this->authCourseChild; + } + + /** + * Set authCatChild + * + * @param string $authCatChild + * @return CourseCategory + */ + public function setAuthCatChild($authCatChild) + { + $this->authCatChild = $authCatChild; + + return $this; + } + + /** + * Get authCatChild + * + * @return string + */ + public function getAuthCatChild() + { + return $this->authCatChild; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/CourseField.php b/src/Chamilo/CoreBundle/Entity/CourseField.php new file mode 100644 index 0000000000..421d6bdfe9 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/CourseField.php @@ -0,0 +1,305 @@ +fieldType = $fieldType; + + return $this; + } + + /** + * Get fieldType + * + * @return integer + */ + public function getFieldType() + { + return $this->fieldType; + } + + /** + * Set fieldVariable + * + * @param string $fieldVariable + * @return CourseField + */ + public function setFieldVariable($fieldVariable) + { + $this->fieldVariable = $fieldVariable; + + return $this; + } + + /** + * Get fieldVariable + * + * @return string + */ + public function getFieldVariable() + { + return $this->fieldVariable; + } + + /** + * Set fieldDisplayText + * + * @param string $fieldDisplayText + * @return CourseField + */ + public function setFieldDisplayText($fieldDisplayText) + { + $this->fieldDisplayText = $fieldDisplayText; + + return $this; + } + + /** + * Get fieldDisplayText + * + * @return string + */ + public function getFieldDisplayText() + { + return $this->fieldDisplayText; + } + + /** + * Set fieldDefaultValue + * + * @param string $fieldDefaultValue + * @return CourseField + */ + public function setFieldDefaultValue($fieldDefaultValue) + { + $this->fieldDefaultValue = $fieldDefaultValue; + + return $this; + } + + /** + * Get fieldDefaultValue + * + * @return string + */ + public function getFieldDefaultValue() + { + return $this->fieldDefaultValue; + } + + /** + * Set fieldOrder + * + * @param integer $fieldOrder + * @return CourseField + */ + public function setFieldOrder($fieldOrder) + { + $this->fieldOrder = $fieldOrder; + + return $this; + } + + /** + * Get fieldOrder + * + * @return integer + */ + public function getFieldOrder() + { + return $this->fieldOrder; + } + + /** + * Set fieldVisible + * + * @param boolean $fieldVisible + * @return CourseField + */ + public function setFieldVisible($fieldVisible) + { + $this->fieldVisible = $fieldVisible; + + return $this; + } + + /** + * Get fieldVisible + * + * @return boolean + */ + public function getFieldVisible() + { + return $this->fieldVisible; + } + + /** + * Set fieldChangeable + * + * @param boolean $fieldChangeable + * @return CourseField + */ + public function setFieldChangeable($fieldChangeable) + { + $this->fieldChangeable = $fieldChangeable; + + return $this; + } + + /** + * Get fieldChangeable + * + * @return boolean + */ + public function getFieldChangeable() + { + return $this->fieldChangeable; + } + + /** + * Set fieldFilter + * + * @param boolean $fieldFilter + * @return CourseField + */ + public function setFieldFilter($fieldFilter) + { + $this->fieldFilter = $fieldFilter; + + return $this; + } + + /** + * Get fieldFilter + * + * @return boolean + */ + public function getFieldFilter() + { + return $this->fieldFilter; + } + + /** + * Set tms + * + * @param \DateTime $tms + * @return CourseField + */ + public function setTms($tms) + { + $this->tms = $tms; + + return $this; + } + + /** + * Get tms + * + * @return \DateTime + */ + public function getTms() + { + return $this->tms; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/CourseFieldOptions.php b/src/Chamilo/CoreBundle/Entity/CourseFieldOptions.php new file mode 100644 index 0000000000..b81ee2bbfb --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/CourseFieldOptions.php @@ -0,0 +1,185 @@ +fieldId = $fieldId; + + return $this; + } + + /** + * Get fieldId + * + * @return integer + */ + public function getFieldId() + { + return $this->fieldId; + } + + /** + * Set optionValue + * + * @param string $optionValue + * @return CourseFieldOptions + */ + public function setOptionValue($optionValue) + { + $this->optionValue = $optionValue; + + return $this; + } + + /** + * Get optionValue + * + * @return string + */ + public function getOptionValue() + { + return $this->optionValue; + } + + /** + * Set optionDisplayText + * + * @param string $optionDisplayText + * @return CourseFieldOptions + */ + public function setOptionDisplayText($optionDisplayText) + { + $this->optionDisplayText = $optionDisplayText; + + return $this; + } + + /** + * Get optionDisplayText + * + * @return string + */ + public function getOptionDisplayText() + { + return $this->optionDisplayText; + } + + /** + * Set optionOrder + * + * @param integer $optionOrder + * @return CourseFieldOptions + */ + public function setOptionOrder($optionOrder) + { + $this->optionOrder = $optionOrder; + + return $this; + } + + /** + * Get optionOrder + * + * @return integer + */ + public function getOptionOrder() + { + return $this->optionOrder; + } + + /** + * Set tms + * + * @param \DateTime $tms + * @return CourseFieldOptions + */ + public function setTms($tms) + { + $this->tms = $tms; + + return $this; + } + + /** + * Get tms + * + * @return \DateTime + */ + public function getTms() + { + return $this->tms; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/CourseFieldValues.php b/src/Chamilo/CoreBundle/Entity/CourseFieldValues.php new file mode 100644 index 0000000000..4b604576df --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/CourseFieldValues.php @@ -0,0 +1,185 @@ +courseCode = $courseCode; + + return $this; + } + + /** + * Get courseCode + * + * @return string + */ + public function getCourseCode() + { + return $this->courseCode; + } + + /** + * Set fieldId + * + * @param integer $fieldId + * @return CourseFieldValues + */ + public function setFieldId($fieldId) + { + $this->fieldId = $fieldId; + + return $this; + } + + /** + * Get fieldId + * + * @return integer + */ + public function getFieldId() + { + return $this->fieldId; + } + + /** + * Set fieldValue + * + * @param string $fieldValue + * @return CourseFieldValues + */ + public function setFieldValue($fieldValue) + { + $this->fieldValue = $fieldValue; + + return $this; + } + + /** + * Get fieldValue + * + * @return string + */ + public function getFieldValue() + { + return $this->fieldValue; + } + + /** + * Set tms + * + * @param \DateTime $tms + * @return CourseFieldValues + */ + public function setTms($tms) + { + $this->tms = $tms; + + return $this; + } + + /** + * Get tms + * + * @return \DateTime + */ + public function getTms() + { + return $this->tms; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CAnnouncement + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + +} diff --git a/src/Chamilo/CoreBundle/Entity/CourseModule.php b/src/Chamilo/CoreBundle/Entity/CourseModule.php new file mode 100644 index 0000000000..b50b196956 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/CourseModule.php @@ -0,0 +1,215 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set link + * + * @param string $link + * @return CourseModule + */ + public function setLink($link) + { + $this->link = $link; + + return $this; + } + + /** + * Get link + * + * @return string + */ + public function getLink() + { + return $this->link; + } + + /** + * Set image + * + * @param string $image + * @return CourseModule + */ + public function setImage($image) + { + $this->image = $image; + + return $this; + } + + /** + * Get image + * + * @return string + */ + public function getImage() + { + return $this->image; + } + + /** + * Set row + * + * @param integer $row + * @return CourseModule + */ + public function setRow($row) + { + $this->row = $row; + + return $this; + } + + /** + * Get row + * + * @return integer + */ + public function getRow() + { + return $this->row; + } + + /** + * Set column + * + * @param integer $column + * @return CourseModule + */ + public function setColumn($column) + { + $this->column = $column; + + return $this; + } + + /** + * Get column + * + * @return integer + */ + public function getColumn() + { + return $this->column; + } + + /** + * Set position + * + * @param string $position + * @return CourseModule + */ + public function setPosition($position) + { + $this->position = $position; + + return $this; + } + + /** + * Get position + * + * @return string + */ + public function getPosition() + { + return $this->position; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/CourseRelClass.php b/src/Chamilo/CoreBundle/Entity/CourseRelClass.php new file mode 100644 index 0000000000..c2123d41b5 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/CourseRelClass.php @@ -0,0 +1,80 @@ +courseCode = $courseCode; + + return $this; + } + + /** + * Get courseCode + * + * @return string + */ + public function getCourseCode() + { + return $this->courseCode; + } + + /** + * Set classId + * + * @param integer $classId + * @return CourseRelClass + */ + public function setClassId($classId) + { + $this->classId = $classId; + + return $this; + } + + /** + * Get classId + * + * @return integer + */ + public function getClassId() + { + return $this->classId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/CourseRelUser.php b/src/Chamilo/CoreBundle/Entity/CourseRelUser.php index 914d369c56..0230fdfa2b 100644 --- a/src/Chamilo/CoreBundle/Entity/CourseRelUser.php +++ b/src/Chamilo/CoreBundle/Entity/CourseRelUser.php @@ -3,7 +3,6 @@ namespace Chamilo\CoreBundle\Entity; -use Chamilo\CourseBundle\Entity\CGroupInfo; use Chamilo\UserBundle\Entity\User; use Doctrine\ORM\Mapping as ORM; @@ -47,18 +46,11 @@ class CourseRelUser private $status; /** - * @var string - * @todo this value should be renamed to description - * @ORM\Column(name="role", type="string", length=60, precision=0, scale=0, nullable=true, unique=false) - */ - private $role; - - /** - * @var integer + * @var bool * - * @ORM\Column(name="tutor_id", type="integer", precision=0, scale=0, nullable=true, unique=false) + * @ORM\Column(name="is_tutor", type="boolean", nullable=true, unique=false) */ - private $tutorId; + private $tutor; /** * @var integer @@ -93,13 +85,6 @@ class CourseRelUser */ protected $course; - /** - * - * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CGroupInfo", inversedBy="course", cascade={"persist"}) - * @ORM\JoinColumn(name="group_id", referencedColumnName="iid") - */ - protected $group; - /** * Constructor */ @@ -132,27 +117,6 @@ class CourseRelUser $this->id = $id; } - /** - * @param CGroupInfo $group - * @return $this - */ - public function setGroup(CGroupInfo $group) - { - $this->group = $group; - - return $this; - } - - /** - * Get group - * - * @return CGroupInfo - */ - public function getGroup() - { - return $this->group; - } - /** * @param Course $course * @return $this @@ -241,96 +205,44 @@ class CourseRelUser return $this->status; } - /** - * Set role - * - * @param string $role - * @return CourseRelUser - */ - public function setRole($role) - { - $this->role = $role; - - return $this; - } - - /** - * Get role - * - * @return string - */ - public function getRole() - { - return $this->role; - } - - /** - * Set groupId - * - * @param integer $groupId - * @return CourseRelUser - */ - public function setGroupId($groupId) - { - $this->groupId = $groupId; - - return $this; - } /** - * Get groupId - * - * @return integer - */ - public function getGroupId() - { - return $this->groupId; - } - - /** - * Set tutorId + * Set sort * - * @param integer $tutorId + * @param integer $sort * @return CourseRelUser */ - public function setTutorId($tutorId) + public function setSort($sort) { - $this->tutorId = $tutorId; + $this->sort = $sort; return $this; } /** - * Get tutorId + * Get sort * * @return integer */ - public function getTutorId() + public function getSort() { - return $this->tutorId; + return $this->sort; } /** - * Set sort - * - * @param integer $sort - * @return CourseRelUser + * @return boolean */ - public function setSort($sort) + public function isTutor() { - $this->sort = $sort; - - return $this; + return $this->tutor; } /** - * Get sort - * - * @return integer + * @param boolean $tutor */ - public function getSort() + public function setTutor($tutor) { - return $this->sort; + $this->tutor = $tutor; } /** diff --git a/src/Chamilo/CoreBundle/Entity/CourseRequest.php b/src/Chamilo/CoreBundle/Entity/CourseRequest.php new file mode 100644 index 0000000000..32abdf5c86 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/CourseRequest.php @@ -0,0 +1,515 @@ +code = $code; + + return $this; + } + + /** + * Get code + * + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * Set userId + * + * @param integer $userId + * @return CourseRequest + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set directory + * + * @param string $directory + * @return CourseRequest + */ + public function setDirectory($directory) + { + $this->directory = $directory; + + return $this; + } + + /** + * Get directory + * + * @return string + */ + public function getDirectory() + { + return $this->directory; + } + + /** + * Set dbName + * + * @param string $dbName + * @return CourseRequest + */ + public function setDbName($dbName) + { + $this->dbName = $dbName; + + return $this; + } + + /** + * Get dbName + * + * @return string + */ + public function getDbName() + { + return $this->dbName; + } + + /** + * Set courseLanguage + * + * @param string $courseLanguage + * @return CourseRequest + */ + public function setCourseLanguage($courseLanguage) + { + $this->courseLanguage = $courseLanguage; + + return $this; + } + + /** + * Get courseLanguage + * + * @return string + */ + public function getCourseLanguage() + { + return $this->courseLanguage; + } + + /** + * Set title + * + * @param string $title + * @return CourseRequest + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set description + * + * @param string $description + * @return CourseRequest + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set categoryCode + * + * @param string $categoryCode + * @return CourseRequest + */ + public function setCategoryCode($categoryCode) + { + $this->categoryCode = $categoryCode; + + return $this; + } + + /** + * Get categoryCode + * + * @return string + */ + public function getCategoryCode() + { + return $this->categoryCode; + } + + /** + * Set tutorName + * + * @param string $tutorName + * @return CourseRequest + */ + public function setTutorName($tutorName) + { + $this->tutorName = $tutorName; + + return $this; + } + + /** + * Get tutorName + * + * @return string + */ + public function getTutorName() + { + return $this->tutorName; + } + + /** + * Set visualCode + * + * @param string $visualCode + * @return CourseRequest + */ + public function setVisualCode($visualCode) + { + $this->visualCode = $visualCode; + + return $this; + } + + /** + * Get visualCode + * + * @return string + */ + public function getVisualCode() + { + return $this->visualCode; + } + + /** + * Set requestDate + * + * @param \DateTime $requestDate + * @return CourseRequest + */ + public function setRequestDate($requestDate) + { + $this->requestDate = $requestDate; + + return $this; + } + + /** + * Get requestDate + * + * @return \DateTime + */ + public function getRequestDate() + { + return $this->requestDate; + } + + /** + * Set objetives + * + * @param string $objetives + * @return CourseRequest + */ + public function setObjetives($objetives) + { + $this->objetives = $objetives; + + return $this; + } + + /** + * Get objetives + * + * @return string + */ + public function getObjetives() + { + return $this->objetives; + } + + /** + * Set targetAudience + * + * @param string $targetAudience + * @return CourseRequest + */ + public function setTargetAudience($targetAudience) + { + $this->targetAudience = $targetAudience; + + return $this; + } + + /** + * Get targetAudience + * + * @return string + */ + public function getTargetAudience() + { + return $this->targetAudience; + } + + /** + * Set status + * + * @param integer $status + * @return CourseRequest + */ + public function setStatus($status) + { + $this->status = $status; + + return $this; + } + + /** + * Get status + * + * @return integer + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set info + * + * @param integer $info + * @return CourseRequest + */ + public function setInfo($info) + { + $this->info = $info; + + return $this; + } + + /** + * Get info + * + * @return integer + */ + public function getInfo() + { + return $this->info; + } + + /** + * Set exemplaryContent + * + * @param integer $exemplaryContent + * @return CourseRequest + */ + public function setExemplaryContent($exemplaryContent) + { + $this->exemplaryContent = $exemplaryContent; + + return $this; + } + + /** + * Get exemplaryContent + * + * @return integer + */ + public function getExemplaryContent() + { + return $this->exemplaryContent; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/CourseType.php b/src/Chamilo/CoreBundle/Entity/CourseType.php new file mode 100644 index 0000000000..09e3a88f13 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/CourseType.php @@ -0,0 +1,155 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set translationVar + * + * @param string $translationVar + * @return CourseType + */ + public function setTranslationVar($translationVar) + { + $this->translationVar = $translationVar; + + return $this; + } + + /** + * Get translationVar + * + * @return string + */ + public function getTranslationVar() + { + return $this->translationVar; + } + + /** + * Set description + * + * @param string $description + * @return CourseType + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set props + * + * @param string $props + * @return CourseType + */ + public function setProps($props) + { + $this->props = $props; + + return $this; + } + + /** + * Get props + * + * @return string + */ + public function getProps() + { + return $this->props; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/EventEmailTemplate.php b/src/Chamilo/CoreBundle/Entity/EventEmailTemplate.php new file mode 100644 index 0000000000..6311ed49a4 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/EventEmailTemplate.php @@ -0,0 +1,185 @@ +message = $message; + + return $this; + } + + /** + * Get message + * + * @return string + */ + public function getMessage() + { + return $this->message; + } + + /** + * Set subject + * + * @param string $subject + * @return EventEmailTemplate + */ + public function setSubject($subject) + { + $this->subject = $subject; + + return $this; + } + + /** + * Get subject + * + * @return string + */ + public function getSubject() + { + return $this->subject; + } + + /** + * Set eventTypeName + * + * @param string $eventTypeName + * @return EventEmailTemplate + */ + public function setEventTypeName($eventTypeName) + { + $this->eventTypeName = $eventTypeName; + + return $this; + } + + /** + * Get eventTypeName + * + * @return string + */ + public function getEventTypeName() + { + return $this->eventTypeName; + } + + /** + * Set activated + * + * @param boolean $activated + * @return EventEmailTemplate + */ + public function setActivated($activated) + { + $this->activated = $activated; + + return $this; + } + + /** + * Get activated + * + * @return boolean + */ + public function getActivated() + { + return $this->activated; + } + + /** + * Set languageId + * + * @param integer $languageId + * @return EventEmailTemplate + */ + public function setLanguageId($languageId) + { + $this->languageId = $languageId; + + return $this; + } + + /** + * Get languageId + * + * @return integer + */ + public function getLanguageId() + { + return $this->languageId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/EventSent.php b/src/Chamilo/CoreBundle/Entity/EventSent.php new file mode 100644 index 0000000000..2b606c0a0d --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/EventSent.php @@ -0,0 +1,125 @@ +userFrom = $userFrom; + + return $this; + } + + /** + * Get userFrom + * + * @return integer + */ + public function getUserFrom() + { + return $this->userFrom; + } + + /** + * Set userTo + * + * @param integer $userTo + * @return EventSent + */ + public function setUserTo($userTo) + { + $this->userTo = $userTo; + + return $this; + } + + /** + * Get userTo + * + * @return integer + */ + public function getUserTo() + { + return $this->userTo; + } + + /** + * Set eventTypeName + * + * @param string $eventTypeName + * @return EventSent + */ + public function setEventTypeName($eventTypeName) + { + $this->eventTypeName = $eventTypeName; + + return $this; + } + + /** + * Get eventTypeName + * + * @return string + */ + public function getEventTypeName() + { + return $this->eventTypeName; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/GradeComponents.php b/src/Chamilo/CoreBundle/Entity/GradeComponents.php new file mode 100644 index 0000000000..2be19b22fc --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/GradeComponents.php @@ -0,0 +1,155 @@ +percentage = $percentage; + + return $this; + } + + /** + * Get percentage + * + * @return string + */ + public function getPercentage() + { + return $this->percentage; + } + + /** + * Set title + * + * @param string $title + * @return GradeComponents + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set acronym + * + * @param string $acronym + * @return GradeComponents + */ + public function setAcronym($acronym) + { + $this->acronym = $acronym; + + return $this; + } + + /** + * Get acronym + * + * @return string + */ + public function getAcronym() + { + return $this->acronym; + } + + /** + * Set gradeModelId + * + * @param integer $gradeModelId + * @return GradeComponents + */ + public function setGradeModelId($gradeModelId) + { + $this->gradeModelId = $gradeModelId; + + return $this; + } + + /** + * Get gradeModelId + * + * @return integer + */ + public function getGradeModelId() + { + return $this->gradeModelId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/GradeModel.php b/src/Chamilo/CoreBundle/Entity/GradeModel.php new file mode 100644 index 0000000000..f92c3acbd9 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/GradeModel.php @@ -0,0 +1,185 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set description + * + * @param string $description + * @return GradeModel + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set defaultLowestEvalExclude + * + * @param boolean $defaultLowestEvalExclude + * @return GradeModel + */ + public function setDefaultLowestEvalExclude($defaultLowestEvalExclude) + { + $this->defaultLowestEvalExclude = $defaultLowestEvalExclude; + + return $this; + } + + /** + * Get defaultLowestEvalExclude + * + * @return boolean + */ + public function getDefaultLowestEvalExclude() + { + return $this->defaultLowestEvalExclude; + } + + /** + * Set defaultExternalEval + * + * @param boolean $defaultExternalEval + * @return GradeModel + */ + public function setDefaultExternalEval($defaultExternalEval) + { + $this->defaultExternalEval = $defaultExternalEval; + + return $this; + } + + /** + * Get defaultExternalEval + * + * @return boolean + */ + public function getDefaultExternalEval() + { + return $this->defaultExternalEval; + } + + /** + * Set defaultExternalEvalPrefix + * + * @param string $defaultExternalEvalPrefix + * @return GradeModel + */ + public function setDefaultExternalEvalPrefix($defaultExternalEvalPrefix) + { + $this->defaultExternalEvalPrefix = $defaultExternalEvalPrefix; + + return $this; + } + + /** + * Get defaultExternalEvalPrefix + * + * @return string + */ + public function getDefaultExternalEvalPrefix() + { + return $this->defaultExternalEvalPrefix; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/GradebookCategory.php b/src/Chamilo/CoreBundle/Entity/GradebookCategory.php new file mode 100644 index 0000000000..5b5f80cc3e --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/GradebookCategory.php @@ -0,0 +1,455 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set description + * + * @param string $description + * @return GradebookCategory + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set userId + * + * @param integer $userId + * @return GradebookCategory + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set courseCode + * + * @param string $courseCode + * @return GradebookCategory + */ + public function setCourseCode($courseCode) + { + $this->courseCode = $courseCode; + + return $this; + } + + /** + * Get courseCode + * + * @return string + */ + public function getCourseCode() + { + return $this->courseCode; + } + + /** + * Set parentId + * + * @param integer $parentId + * @return GradebookCategory + */ + public function setParentId($parentId) + { + $this->parentId = $parentId; + + return $this; + } + + /** + * Get parentId + * + * @return integer + */ + public function getParentId() + { + return $this->parentId; + } + + /** + * Set weight + * + * @param float $weight + * @return GradebookCategory + */ + public function setWeight($weight) + { + $this->weight = $weight; + + return $this; + } + + /** + * Get weight + * + * @return float + */ + public function getWeight() + { + return $this->weight; + } + + /** + * Set visible + * + * @param boolean $visible + * @return GradebookCategory + */ + public function setVisible($visible) + { + $this->visible = $visible; + + return $this; + } + + /** + * Get visible + * + * @return boolean + */ + public function getVisible() + { + return $this->visible; + } + + /** + * Set certifMinScore + * + * @param integer $certifMinScore + * @return GradebookCategory + */ + public function setCertifMinScore($certifMinScore) + { + $this->certifMinScore = $certifMinScore; + + return $this; + } + + /** + * Get certifMinScore + * + * @return integer + */ + public function getCertifMinScore() + { + return $this->certifMinScore; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return GradebookCategory + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set documentId + * + * @param integer $documentId + * @return GradebookCategory + */ + public function setDocumentId($documentId) + { + $this->documentId = $documentId; + + return $this; + } + + /** + * Get documentId + * + * @return integer + */ + public function getDocumentId() + { + return $this->documentId; + } + + /** + * Set locked + * + * @param integer $locked + * @return GradebookCategory + */ + public function setLocked($locked) + { + $this->locked = $locked; + + return $this; + } + + /** + * Get locked + * + * @return integer + */ + public function getLocked() + { + return $this->locked; + } + + /** + * Set defaultLowestEvalExclude + * + * @param boolean $defaultLowestEvalExclude + * @return GradebookCategory + */ + public function setDefaultLowestEvalExclude($defaultLowestEvalExclude) + { + $this->defaultLowestEvalExclude = $defaultLowestEvalExclude; + + return $this; + } + + /** + * Get defaultLowestEvalExclude + * + * @return boolean + */ + public function getDefaultLowestEvalExclude() + { + return $this->defaultLowestEvalExclude; + } + + /** + * Set generateCertificates + * + * @param boolean $generateCertificates + * @return GradebookCategory + */ + public function setGenerateCertificates($generateCertificates) + { + $this->generateCertificates = $generateCertificates; + + return $this; + } + + /** + * Get generateCertificates + * + * @return boolean + */ + public function getGenerateCertificates() + { + return $this->generateCertificates; + } + + /** + * Set gradeModelId + * + * @param integer $gradeModelId + * @return GradebookCategory + */ + public function setGradeModelId($gradeModelId) + { + $this->gradeModelId = $gradeModelId; + + return $this; + } + + /** + * Get gradeModelId + * + * @return integer + */ + public function getGradeModelId() + { + return $this->gradeModelId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/GradebookCertificate.php b/src/Chamilo/CoreBundle/Entity/GradebookCertificate.php new file mode 100644 index 0000000000..d26f068016 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/GradebookCertificate.php @@ -0,0 +1,185 @@ +catId = $catId; + + return $this; + } + + /** + * Get catId + * + * @return integer + */ + public function getCatId() + { + return $this->catId; + } + + /** + * Set userId + * + * @param integer $userId + * @return GradebookCertificate + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set scoreCertificate + * + * @param float $scoreCertificate + * @return GradebookCertificate + */ + public function setScoreCertificate($scoreCertificate) + { + $this->scoreCertificate = $scoreCertificate; + + return $this; + } + + /** + * Get scoreCertificate + * + * @return float + */ + public function getScoreCertificate() + { + return $this->scoreCertificate; + } + + /** + * Set createdAt + * + * @param \DateTime $createdAt + * @return GradebookCertificate + */ + public function setCreatedAt($createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * Get createdAt + * + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Set pathCertificate + * + * @param string $pathCertificate + * @return GradebookCertificate + */ + public function setPathCertificate($pathCertificate) + { + $this->pathCertificate = $pathCertificate; + + return $this; + } + + /** + * Get pathCertificate + * + * @return string + */ + public function getPathCertificate() + { + return $this->pathCertificate; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/GradebookEvaluation.php b/src/Chamilo/CoreBundle/Entity/GradebookEvaluation.php new file mode 100644 index 0000000000..67f1cb5856 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/GradebookEvaluation.php @@ -0,0 +1,365 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set description + * + * @param string $description + * @return GradebookEvaluation + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set userId + * + * @param integer $userId + * @return GradebookEvaluation + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set courseCode + * + * @param string $courseCode + * @return GradebookEvaluation + */ + public function setCourseCode($courseCode) + { + $this->courseCode = $courseCode; + + return $this; + } + + /** + * Get courseCode + * + * @return string + */ + public function getCourseCode() + { + return $this->courseCode; + } + + /** + * Set categoryId + * + * @param integer $categoryId + * @return GradebookEvaluation + */ + public function setCategoryId($categoryId) + { + $this->categoryId = $categoryId; + + return $this; + } + + /** + * Get categoryId + * + * @return integer + */ + public function getCategoryId() + { + return $this->categoryId; + } + + /** + * Set createdAt + * + * @param \DateTime $createdAt + * @return GradebookEvaluation + */ + public function setCreatedAt($createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * Get createdAt + * + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Set weight + * + * @param float $weight + * @return GradebookEvaluation + */ + public function setWeight($weight) + { + $this->weight = $weight; + + return $this; + } + + /** + * Get weight + * + * @return float + */ + public function getWeight() + { + return $this->weight; + } + + /** + * Set max + * + * @param float $max + * @return GradebookEvaluation + */ + public function setMax($max) + { + $this->max = $max; + + return $this; + } + + /** + * Get max + * + * @return float + */ + public function getMax() + { + return $this->max; + } + + /** + * Set visible + * + * @param integer $visible + * @return GradebookEvaluation + */ + public function setVisible($visible) + { + $this->visible = $visible; + + return $this; + } + + /** + * Get visible + * + * @return integer + */ + public function getVisible() + { + return $this->visible; + } + + /** + * Set type + * + * @param string $type + * @return GradebookEvaluation + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set locked + * + * @param integer $locked + * @return GradebookEvaluation + */ + public function setLocked($locked) + { + $this->locked = $locked; + + return $this; + } + + /** + * Get locked + * + * @return integer + */ + public function getLocked() + { + return $this->locked; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/GradebookLink.php b/src/Chamilo/CoreBundle/Entity/GradebookLink.php new file mode 100644 index 0000000000..a68e736bf5 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/GradebookLink.php @@ -0,0 +1,305 @@ +type = $type; + + return $this; + } + + /** + * Get type + * + * @return integer + */ + public function getType() + { + return $this->type; + } + + /** + * Set refId + * + * @param integer $refId + * @return GradebookLink + */ + public function setRefId($refId) + { + $this->refId = $refId; + + return $this; + } + + /** + * Get refId + * + * @return integer + */ + public function getRefId() + { + return $this->refId; + } + + /** + * Set userId + * + * @param integer $userId + * @return GradebookLink + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set courseCode + * + * @param string $courseCode + * @return GradebookLink + */ + public function setCourseCode($courseCode) + { + $this->courseCode = $courseCode; + + return $this; + } + + /** + * Get courseCode + * + * @return string + */ + public function getCourseCode() + { + return $this->courseCode; + } + + /** + * Set categoryId + * + * @param integer $categoryId + * @return GradebookLink + */ + public function setCategoryId($categoryId) + { + $this->categoryId = $categoryId; + + return $this; + } + + /** + * Get categoryId + * + * @return integer + */ + public function getCategoryId() + { + return $this->categoryId; + } + + /** + * Set createdAt + * + * @param \DateTime $createdAt + * @return GradebookLink + */ + public function setCreatedAt($createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * Get createdAt + * + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Set weight + * + * @param float $weight + * @return GradebookLink + */ + public function setWeight($weight) + { + $this->weight = $weight; + + return $this; + } + + /** + * Get weight + * + * @return float + */ + public function getWeight() + { + return $this->weight; + } + + /** + * Set visible + * + * @param integer $visible + * @return GradebookLink + */ + public function setVisible($visible) + { + $this->visible = $visible; + + return $this; + } + + /** + * Get visible + * + * @return integer + */ + public function getVisible() + { + return $this->visible; + } + + /** + * Set locked + * + * @param integer $locked + * @return GradebookLink + */ + public function setLocked($locked) + { + $this->locked = $locked; + + return $this; + } + + /** + * Get locked + * + * @return integer + */ + public function getLocked() + { + return $this->locked; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/GradebookLinkevalLog.php b/src/Chamilo/CoreBundle/Entity/GradebookLinkevalLog.php new file mode 100644 index 0000000000..e7a7321bc1 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/GradebookLinkevalLog.php @@ -0,0 +1,275 @@ +idLinkevalLog = $idLinkevalLog; + + return $this; + } + + /** + * Get idLinkevalLog + * + * @return integer + */ + public function getIdLinkevalLog() + { + return $this->idLinkevalLog; + } + + /** + * Set name + * + * @param string $name + * @return GradebookLinkevalLog + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set description + * + * @param string $description + * @return GradebookLinkevalLog + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set createdAt + * + * @param \DateTime $createdAt + * @return GradebookLinkevalLog + */ + public function setCreatedAt($createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * Get createdAt + * + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Set weight + * + * @param integer $weight + * @return GradebookLinkevalLog + */ + public function setWeight($weight) + { + $this->weight = $weight; + + return $this; + } + + /** + * Get weight + * + * @return integer + */ + public function getWeight() + { + return $this->weight; + } + + /** + * Set visible + * + * @param boolean $visible + * @return GradebookLinkevalLog + */ + public function setVisible($visible) + { + $this->visible = $visible; + + return $this; + } + + /** + * Get visible + * + * @return boolean + */ + public function getVisible() + { + return $this->visible; + } + + /** + * Set type + * + * @param string $type + * @return GradebookLinkevalLog + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set userIdLog + * + * @param integer $userIdLog + * @return GradebookLinkevalLog + */ + public function setUserIdLog($userIdLog) + { + $this->userIdLog = $userIdLog; + + return $this; + } + + /** + * Get userIdLog + * + * @return integer + */ + public function getUserIdLog() + { + return $this->userIdLog; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/GradebookResult.php b/src/Chamilo/CoreBundle/Entity/GradebookResult.php new file mode 100644 index 0000000000..c53cf5955c --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/GradebookResult.php @@ -0,0 +1,155 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set evaluationId + * + * @param integer $evaluationId + * @return GradebookResult + */ + public function setEvaluationId($evaluationId) + { + $this->evaluationId = $evaluationId; + + return $this; + } + + /** + * Get evaluationId + * + * @return integer + */ + public function getEvaluationId() + { + return $this->evaluationId; + } + + /** + * Set createdAt + * + * @param \DateTime $createdAt + * @return GradebookResult + */ + public function setCreatedAt($createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * Get createdAt + * + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Set score + * + * @param float $score + * @return GradebookResult + */ + public function setScore($score) + { + $this->score = $score; + + return $this; + } + + /** + * Get score + * + * @return float + */ + public function getScore() + { + return $this->score; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/GradebookResultLog.php b/src/Chamilo/CoreBundle/Entity/GradebookResultLog.php new file mode 100644 index 0000000000..274422c718 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/GradebookResultLog.php @@ -0,0 +1,185 @@ +idResult = $idResult; + + return $this; + } + + /** + * Get idResult + * + * @return integer + */ + public function getIdResult() + { + return $this->idResult; + } + + /** + * Set userId + * + * @param integer $userId + * @return GradebookResultLog + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set evaluationId + * + * @param integer $evaluationId + * @return GradebookResultLog + */ + public function setEvaluationId($evaluationId) + { + $this->evaluationId = $evaluationId; + + return $this; + } + + /** + * Get evaluationId + * + * @return integer + */ + public function getEvaluationId() + { + return $this->evaluationId; + } + + /** + * Set createdAt + * + * @param \DateTime $createdAt + * @return GradebookResultLog + */ + public function setCreatedAt($createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * Get createdAt + * + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Set score + * + * @param float $score + * @return GradebookResultLog + */ + public function setScore($score) + { + $this->score = $score; + + return $this; + } + + /** + * Get score + * + * @return float + */ + public function getScore() + { + return $this->score; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/GradebookScoreDisplay.php b/src/Chamilo/CoreBundle/Entity/GradebookScoreDisplay.php new file mode 100644 index 0000000000..191436383b --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/GradebookScoreDisplay.php @@ -0,0 +1,155 @@ +score = $score; + + return $this; + } + + /** + * Get score + * + * @return float + */ + public function getScore() + { + return $this->score; + } + + /** + * Set display + * + * @param string $display + * @return GradebookScoreDisplay + */ + public function setDisplay($display) + { + $this->display = $display; + + return $this; + } + + /** + * Get display + * + * @return string + */ + public function getDisplay() + { + return $this->display; + } + + /** + * Set categoryId + * + * @param integer $categoryId + * @return GradebookScoreDisplay + */ + public function setCategoryId($categoryId) + { + $this->categoryId = $categoryId; + + return $this; + } + + /** + * Get categoryId + * + * @return integer + */ + public function getCategoryId() + { + return $this->categoryId; + } + + /** + * Set scoreColorPercent + * + * @param float $scoreColorPercent + * @return GradebookScoreDisplay + */ + public function setScoreColorPercent($scoreColorPercent) + { + $this->scoreColorPercent = $scoreColorPercent; + + return $this; + } + + /** + * Get scoreColorPercent + * + * @return float + */ + public function getScoreColorPercent() + { + return $this->scoreColorPercent; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/GroupRelGroup.php b/src/Chamilo/CoreBundle/Entity/GroupRelGroup.php new file mode 100644 index 0000000000..b76c9259c0 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/GroupRelGroup.php @@ -0,0 +1,125 @@ +groupId = $groupId; + + return $this; + } + + /** + * Get groupId + * + * @return integer + */ + public function getGroupId() + { + return $this->groupId; + } + + /** + * Set subgroupId + * + * @param integer $subgroupId + * @return GroupRelGroup + */ + public function setSubgroupId($subgroupId) + { + $this->subgroupId = $subgroupId; + + return $this; + } + + /** + * Get subgroupId + * + * @return integer + */ + public function getSubgroupId() + { + return $this->subgroupId; + } + + /** + * Set relationType + * + * @param integer $relationType + * @return GroupRelGroup + */ + public function setRelationType($relationType) + { + $this->relationType = $relationType; + + return $this; + } + + /** + * Get relationType + * + * @return integer + */ + public function getRelationType() + { + return $this->relationType; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/GroupRelTag.php b/src/Chamilo/CoreBundle/Entity/GroupRelTag.php new file mode 100644 index 0000000000..5e20c11592 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/GroupRelTag.php @@ -0,0 +1,95 @@ +tagId = $tagId; + + return $this; + } + + /** + * Get tagId + * + * @return integer + */ + public function getTagId() + { + return $this->tagId; + } + + /** + * Set groupId + * + * @param integer $groupId + * @return GroupRelTag + */ + public function setGroupId($groupId) + { + $this->groupId = $groupId; + + return $this; + } + + /** + * Get groupId + * + * @return integer + */ + public function getGroupId() + { + return $this->groupId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/GroupRelUser.php b/src/Chamilo/CoreBundle/Entity/GroupRelUser.php new file mode 100644 index 0000000000..5ace8dad76 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/GroupRelUser.php @@ -0,0 +1,125 @@ +groupId = $groupId; + + return $this; + } + + /** + * Get groupId + * + * @return integer + */ + public function getGroupId() + { + return $this->groupId; + } + + /** + * Set userId + * + * @param integer $userId + * @return GroupRelUser + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set relationType + * + * @param integer $relationType + * @return GroupRelUser + */ + public function setRelationType($relationType) + { + $this->relationType = $relationType; + + return $this; + } + + /** + * Get relationType + * + * @return integer + */ + public function getRelationType() + { + return $this->relationType; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/Groups.php b/src/Chamilo/CoreBundle/Entity/Groups.php new file mode 100644 index 0000000000..7c2c9c2b17 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/Groups.php @@ -0,0 +1,245 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set description + * + * @param string $description + * @return Groups + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set pictureUri + * + * @param string $pictureUri + * @return Groups + */ + public function setPictureUri($pictureUri) + { + $this->pictureUri = $pictureUri; + + return $this; + } + + /** + * Get pictureUri + * + * @return string + */ + public function getPictureUri() + { + return $this->pictureUri; + } + + /** + * Set url + * + * @param string $url + * @return Groups + */ + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * Get url + * + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set visibility + * + * @param integer $visibility + * @return Groups + */ + public function setVisibility($visibility) + { + $this->visibility = $visibility; + + return $this; + } + + /** + * Get visibility + * + * @return integer + */ + public function getVisibility() + { + return $this->visibility; + } + + /** + * Set updatedOn + * + * @param string $updatedOn + * @return Groups + */ + public function setUpdatedOn($updatedOn) + { + $this->updatedOn = $updatedOn; + + return $this; + } + + /** + * Get updatedOn + * + * @return string + */ + public function getUpdatedOn() + { + return $this->updatedOn; + } + + /** + * Set createdOn + * + * @param string $createdOn + * @return Groups + */ + public function setCreatedOn($createdOn) + { + $this->createdOn = $createdOn; + + return $this; + } + + /** + * Get createdOn + * + * @return string + */ + public function getCreatedOn() + { + return $this->createdOn; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/HookCall.php b/src/Chamilo/CoreBundle/Entity/HookCall.php new file mode 100644 index 0000000000..760d71f387 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/HookCall.php @@ -0,0 +1,185 @@ +hookEventId = $hookEventId; + + return $this; + } + + /** + * Get hookEventId + * + * @return integer + */ + public function getHookEventId() + { + return $this->hookEventId; + } + + /** + * Set hookObserverId + * + * @param integer $hookObserverId + * @return HookCall + */ + public function setHookObserverId($hookObserverId) + { + $this->hookObserverId = $hookObserverId; + + return $this; + } + + /** + * Get hookObserverId + * + * @return integer + */ + public function getHookObserverId() + { + return $this->hookObserverId; + } + + /** + * Set type + * + * @param boolean $type + * @return HookCall + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return boolean + */ + public function getType() + { + return $this->type; + } + + /** + * Set hookOrder + * + * @param integer $hookOrder + * @return HookCall + */ + public function setHookOrder($hookOrder) + { + $this->hookOrder = $hookOrder; + + return $this; + } + + /** + * Get hookOrder + * + * @return integer + */ + public function getHookOrder() + { + return $this->hookOrder; + } + + /** + * Set enabled + * + * @param boolean $enabled + * @return HookCall + */ + public function setEnabled($enabled) + { + $this->enabled = $enabled; + + return $this; + } + + /** + * Get enabled + * + * @return boolean + */ + public function getEnabled() + { + return $this->enabled; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/HookEvent.php b/src/Chamilo/CoreBundle/Entity/HookEvent.php new file mode 100644 index 0000000000..b1b192988c --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/HookEvent.php @@ -0,0 +1,95 @@ +className = $className; + + return $this; + } + + /** + * Get className + * + * @return string + */ + public function getClassName() + { + return $this->className; + } + + /** + * Set description + * + * @param string $description + * @return HookEvent + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/HookObserver.php b/src/Chamilo/CoreBundle/Entity/HookObserver.php new file mode 100644 index 0000000000..9dc0564a19 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/HookObserver.php @@ -0,0 +1,125 @@ +className = $className; + + return $this; + } + + /** + * Get className + * + * @return string + */ + public function getClassName() + { + return $this->className; + } + + /** + * Set path + * + * @param string $path + * @return HookObserver + */ + public function setPath($path) + { + $this->path = $path; + + return $this; + } + + /** + * Get path + * + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Set pluginName + * + * @param string $pluginName + * @return HookObserver + */ + public function setPluginName($pluginName) + { + $this->pluginName = $pluginName; + + return $this; + } + + /** + * Get pluginName + * + * @return string + */ + public function getPluginName() + { + return $this->pluginName; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/Language.php b/src/Chamilo/CoreBundle/Entity/Language.php new file mode 100644 index 0000000000..70f680bce9 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/Language.php @@ -0,0 +1,214 @@ +originalName = $originalName; + + return $this; + } + + /** + * Get originalName + * + * @return string + */ + public function getOriginalName() + { + return $this->originalName; + } + + /** + * Set englishName + * + * @param string $englishName + * @return Language + */ + public function setEnglishName($englishName) + { + $this->englishName = $englishName; + + return $this; + } + + /** + * Get englishName + * + * @return string + */ + public function getEnglishName() + { + return $this->englishName; + } + + /** + * Set isocode + * + * @param string $isocode + * @return Language + */ + public function setIsocode($isocode) + { + $this->isocode = $isocode; + + return $this; + } + + /** + * Get isocode + * + * @return string + */ + public function getIsocode() + { + return $this->isocode; + } + + /** + * Set dokeosFolder + * + * @param string $dokeosFolder + * @return Language + */ + public function setDokeosFolder($dokeosFolder) + { + $this->dokeosFolder = $dokeosFolder; + + return $this; + } + + /** + * Get dokeosFolder + * + * @return string + */ + public function getDokeosFolder() + { + return $this->dokeosFolder; + } + + /** + * Set available + * + * @param boolean $available + * @return Language + */ + public function setAvailable($available) + { + $this->available = $available; + + return $this; + } + + /** + * Get available + * + * @return boolean + */ + public function getAvailable() + { + return $this->available; + } + + /** + * Set parentId + * + * @param boolean $parentId + * @return Language + */ + public function setParentId($parentId) + { + $this->parentId = $parentId; + + return $this; + } + + /** + * Get parentId + * + * @return boolean + */ + public function getParentId() + { + return $this->parentId; + } + + /** + * Get id + * + * @return boolean + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/Legal.php b/src/Chamilo/CoreBundle/Entity/Legal.php new file mode 100644 index 0000000000..1232dfd034 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/Legal.php @@ -0,0 +1,230 @@ +date = $date; + + return $this; + } + + /** + * Get date + * + * @return integer + */ + public function getDate() + { + return $this->date; + } + + /** + * Set content + * + * @param string $content + * @return Legal + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Set type + * + * @param integer $type + * @return Legal + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return integer + */ + public function getType() + { + return $this->type; + } + + /** + * Set changes + * + * @param string $changes + * @return Legal + */ + public function setChanges($changes) + { + $this->changes = $changes; + + return $this; + } + + /** + * Get changes + * + * @return string + */ + public function getChanges() + { + return $this->changes; + } + + /** + * Set version + * + * @param integer $version + * @return Legal + */ + public function setVersion($version) + { + $this->version = $version; + + return $this; + } + + /** + * Get version + * + * @return integer + */ + public function getVersion() + { + return $this->version; + } + + /** + * Set legalId + * + * @param integer $legalId + * @return Legal + */ + public function setLegalId($legalId) + { + $this->legalId = $legalId; + + return $this; + } + + /** + * Get legalId + * + * @return integer + */ + public function getLegalId() + { + return $this->legalId; + } + + /** + * Set languageId + * + * @param integer $languageId + * @return Legal + */ + public function setLanguageId($languageId) + { + $this->languageId = $languageId; + + return $this; + } + + /** + * Get languageId + * + * @return integer + */ + public function getLanguageId() + { + return $this->languageId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/Message.php b/src/Chamilo/CoreBundle/Entity/Message.php new file mode 100644 index 0000000000..ee3c0cd8ed --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/Message.php @@ -0,0 +1,305 @@ +userSenderId = $userSenderId; + + return $this; + } + + /** + * Get userSenderId + * + * @return integer + */ + public function getUserSenderId() + { + return $this->userSenderId; + } + + /** + * Set userReceiverId + * + * @param integer $userReceiverId + * @return Message + */ + public function setUserReceiverId($userReceiverId) + { + $this->userReceiverId = $userReceiverId; + + return $this; + } + + /** + * Get userReceiverId + * + * @return integer + */ + public function getUserReceiverId() + { + return $this->userReceiverId; + } + + /** + * Set msgStatus + * + * @param boolean $msgStatus + * @return Message + */ + public function setMsgStatus($msgStatus) + { + $this->msgStatus = $msgStatus; + + return $this; + } + + /** + * Get msgStatus + * + * @return boolean + */ + public function getMsgStatus() + { + return $this->msgStatus; + } + + /** + * Set sendDate + * + * @param \DateTime $sendDate + * @return Message + */ + public function setSendDate($sendDate) + { + $this->sendDate = $sendDate; + + return $this; + } + + /** + * Get sendDate + * + * @return \DateTime + */ + public function getSendDate() + { + return $this->sendDate; + } + + /** + * Set title + * + * @param string $title + * @return Message + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set content + * + * @param string $content + * @return Message + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Set groupId + * + * @param integer $groupId + * @return Message + */ + public function setGroupId($groupId) + { + $this->groupId = $groupId; + + return $this; + } + + /** + * Get groupId + * + * @return integer + */ + public function getGroupId() + { + return $this->groupId; + } + + /** + * Set parentId + * + * @param integer $parentId + * @return Message + */ + public function setParentId($parentId) + { + $this->parentId = $parentId; + + return $this; + } + + /** + * Get parentId + * + * @return integer + */ + public function getParentId() + { + return $this->parentId; + } + + /** + * Set updateDate + * + * @param \DateTime $updateDate + * @return Message + */ + public function setUpdateDate($updateDate) + { + $this->updateDate = $updateDate; + + return $this; + } + + /** + * Get updateDate + * + * @return \DateTime + */ + public function getUpdateDate() + { + return $this->updateDate; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/MessageAttachment.php b/src/Chamilo/CoreBundle/Entity/MessageAttachment.php new file mode 100644 index 0000000000..22875563ea --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/MessageAttachment.php @@ -0,0 +1,185 @@ +path = $path; + + return $this; + } + + /** + * Get path + * + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Set comment + * + * @param string $comment + * @return MessageAttachment + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set size + * + * @param integer $size + * @return MessageAttachment + */ + public function setSize($size) + { + $this->size = $size; + + return $this; + } + + /** + * Get size + * + * @return integer + */ + public function getSize() + { + return $this->size; + } + + /** + * Set messageId + * + * @param integer $messageId + * @return MessageAttachment + */ + public function setMessageId($messageId) + { + $this->messageId = $messageId; + + return $this; + } + + /** + * Get messageId + * + * @return integer + */ + public function getMessageId() + { + return $this->messageId; + } + + /** + * Set filename + * + * @param string $filename + * @return MessageAttachment + */ + public function setFilename($filename) + { + $this->filename = $filename; + + return $this; + } + + /** + * Get filename + * + * @return string + */ + public function getFilename() + { + return $this->filename; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/Notification.php b/src/Chamilo/CoreBundle/Entity/Notification.php new file mode 100644 index 0000000000..88c7834310 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/Notification.php @@ -0,0 +1,245 @@ +destUserId = $destUserId; + + return $this; + } + + /** + * Get destUserId + * + * @return integer + */ + public function getDestUserId() + { + return $this->destUserId; + } + + /** + * Set destMail + * + * @param string $destMail + * @return Notification + */ + public function setDestMail($destMail) + { + $this->destMail = $destMail; + + return $this; + } + + /** + * Get destMail + * + * @return string + */ + public function getDestMail() + { + return $this->destMail; + } + + /** + * Set title + * + * @param string $title + * @return Notification + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set content + * + * @param string $content + * @return Notification + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Set sendFreq + * + * @param integer $sendFreq + * @return Notification + */ + public function setSendFreq($sendFreq) + { + $this->sendFreq = $sendFreq; + + return $this; + } + + /** + * Get sendFreq + * + * @return integer + */ + public function getSendFreq() + { + return $this->sendFreq; + } + + /** + * Set createdAt + * + * @param \DateTime $createdAt + * @return Notification + */ + public function setCreatedAt($createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * Get createdAt + * + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Set sentAt + * + * @param \DateTime $sentAt + * @return Notification + */ + public function setSentAt($sentAt) + { + $this->sentAt = $sentAt; + + return $this; + } + + /** + * Get sentAt + * + * @return \DateTime + */ + public function getSentAt() + { + return $this->sentAt; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/OpenidAssociation.php b/src/Chamilo/CoreBundle/Entity/OpenidAssociation.php new file mode 100644 index 0000000000..b59537689f --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/OpenidAssociation.php @@ -0,0 +1,245 @@ +idpEndpointUri = $idpEndpointUri; + + return $this; + } + + /** + * Get idpEndpointUri + * + * @return string + */ + public function getIdpEndpointUri() + { + return $this->idpEndpointUri; + } + + /** + * Set sessionType + * + * @param string $sessionType + * @return OpenidAssociation + */ + public function setSessionType($sessionType) + { + $this->sessionType = $sessionType; + + return $this; + } + + /** + * Get sessionType + * + * @return string + */ + public function getSessionType() + { + return $this->sessionType; + } + + /** + * Set assocHandle + * + * @param string $assocHandle + * @return OpenidAssociation + */ + public function setAssocHandle($assocHandle) + { + $this->assocHandle = $assocHandle; + + return $this; + } + + /** + * Get assocHandle + * + * @return string + */ + public function getAssocHandle() + { + return $this->assocHandle; + } + + /** + * Set assocType + * + * @param string $assocType + * @return OpenidAssociation + */ + public function setAssocType($assocType) + { + $this->assocType = $assocType; + + return $this; + } + + /** + * Get assocType + * + * @return string + */ + public function getAssocType() + { + return $this->assocType; + } + + /** + * Set expiresIn + * + * @param integer $expiresIn + * @return OpenidAssociation + */ + public function setExpiresIn($expiresIn) + { + $this->expiresIn = $expiresIn; + + return $this; + } + + /** + * Get expiresIn + * + * @return integer + */ + public function getExpiresIn() + { + return $this->expiresIn; + } + + /** + * Set macKey + * + * @param string $macKey + * @return OpenidAssociation + */ + public function setMacKey($macKey) + { + $this->macKey = $macKey; + + return $this; + } + + /** + * Get macKey + * + * @return string + */ + public function getMacKey() + { + return $this->macKey; + } + + /** + * Set created + * + * @param integer $created + * @return OpenidAssociation + */ + public function setCreated($created) + { + $this->created = $created; + + return $this; + } + + /** + * Get created + * + * @return integer + */ + public function getCreated() + { + return $this->created; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/PersonalAgenda.php b/src/Chamilo/CoreBundle/Entity/PersonalAgenda.php new file mode 100644 index 0000000000..2f621a8db5 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/PersonalAgenda.php @@ -0,0 +1,275 @@ +user = $user; + + return $this; + } + + /** + * Get user + * + * @return integer + */ + public function getUser() + { + return $this->user; + } + + /** + * Set title + * + * @param string $title + * @return PersonalAgenda + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set text + * + * @param string $text + * @return PersonalAgenda + */ + public function setText($text) + { + $this->text = $text; + + return $this; + } + + /** + * Get text + * + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Set date + * + * @param \DateTime $date + * @return PersonalAgenda + */ + public function setDate($date) + { + $this->date = $date; + + return $this; + } + + /** + * Get date + * + * @return \DateTime + */ + public function getDate() + { + return $this->date; + } + + /** + * Set enddate + * + * @param \DateTime $enddate + * @return PersonalAgenda + */ + public function setEnddate($enddate) + { + $this->enddate = $enddate; + + return $this; + } + + /** + * Get enddate + * + * @return \DateTime + */ + public function getEnddate() + { + return $this->enddate; + } + + /** + * Set course + * + * @param string $course + * @return PersonalAgenda + */ + public function setCourse($course) + { + $this->course = $course; + + return $this; + } + + /** + * Get course + * + * @return string + */ + public function getCourse() + { + return $this->course; + } + + /** + * Set parentEventId + * + * @param integer $parentEventId + * @return PersonalAgenda + */ + public function setParentEventId($parentEventId) + { + $this->parentEventId = $parentEventId; + + return $this; + } + + /** + * Get parentEventId + * + * @return integer + */ + public function getParentEventId() + { + return $this->parentEventId; + } + + /** + * Set allDay + * + * @param integer $allDay + * @return PersonalAgenda + */ + public function setAllDay($allDay) + { + $this->allDay = $allDay; + + return $this; + } + + /** + * Get allDay + * + * @return integer + */ + public function getAllDay() + { + return $this->allDay; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/PersonalAgendaRepeat.php b/src/Chamilo/CoreBundle/Entity/PersonalAgendaRepeat.php new file mode 100644 index 0000000000..39cbb0c0e4 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/PersonalAgendaRepeat.php @@ -0,0 +1,155 @@ +calType = $calType; + + return $this; + } + + /** + * Get calType + * + * @return string + */ + public function getCalType() + { + return $this->calType; + } + + /** + * Set calEnd + * + * @param integer $calEnd + * @return PersonalAgendaRepeat + */ + public function setCalEnd($calEnd) + { + $this->calEnd = $calEnd; + + return $this; + } + + /** + * Get calEnd + * + * @return integer + */ + public function getCalEnd() + { + return $this->calEnd; + } + + /** + * Set calFrequency + * + * @param integer $calFrequency + * @return PersonalAgendaRepeat + */ + public function setCalFrequency($calFrequency) + { + $this->calFrequency = $calFrequency; + + return $this; + } + + /** + * Get calFrequency + * + * @return integer + */ + public function getCalFrequency() + { + return $this->calFrequency; + } + + /** + * Set calDays + * + * @param string $calDays + * @return PersonalAgendaRepeat + */ + public function setCalDays($calDays) + { + $this->calDays = $calDays; + + return $this; + } + + /** + * Get calDays + * + * @return string + */ + public function getCalDays() + { + return $this->calDays; + } + + /** + * Get calId + * + * @return integer + */ + public function getCalId() + { + return $this->calId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/PersonalAgendaRepeatNot.php b/src/Chamilo/CoreBundle/Entity/PersonalAgendaRepeatNot.php new file mode 100644 index 0000000000..99c41c1db8 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/PersonalAgendaRepeatNot.php @@ -0,0 +1,80 @@ +calId = $calId; + + return $this; + } + + /** + * Get calId + * + * @return integer + */ + public function getCalId() + { + return $this->calId; + } + + /** + * Set calDate + * + * @param integer $calDate + * @return PersonalAgendaRepeatNot + */ + public function setCalDate($calDate) + { + $this->calDate = $calDate; + + return $this; + } + + /** + * Get calDate + * + * @return integer + */ + public function getCalDate() + { + return $this->calDate; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/Promotion.php b/src/Chamilo/CoreBundle/Entity/Promotion.php new file mode 100644 index 0000000000..aecd002d8e --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/Promotion.php @@ -0,0 +1,215 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set description + * + * @param string $description + * @return Promotion + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set careerId + * + * @param integer $careerId + * @return Promotion + */ + public function setCareerId($careerId) + { + $this->careerId = $careerId; + + return $this; + } + + /** + * Get careerId + * + * @return integer + */ + public function getCareerId() + { + return $this->careerId; + } + + /** + * Set status + * + * @param integer $status + * @return Promotion + */ + public function setStatus($status) + { + $this->status = $status; + + return $this; + } + + /** + * Get status + * + * @return integer + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set createdAt + * + * @param \DateTime $createdAt + * @return Promotion + */ + public function setCreatedAt($createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * Get createdAt + * + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Set updatedAt + * + * @param \DateTime $updatedAt + * @return Promotion + */ + public function setUpdatedAt($updatedAt) + { + $this->updatedAt = $updatedAt; + + return $this; + } + + /** + * Get updatedAt + * + * @return \DateTime + */ + public function getUpdatedAt() + { + return $this->updatedAt; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SearchEngineRef.php b/src/Chamilo/CoreBundle/Entity/SearchEngineRef.php new file mode 100644 index 0000000000..d7e1395ced --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SearchEngineRef.php @@ -0,0 +1,185 @@ +courseCode = $courseCode; + + return $this; + } + + /** + * Get courseCode + * + * @return string + */ + public function getCourseCode() + { + return $this->courseCode; + } + + /** + * Set toolId + * + * @param string $toolId + * @return SearchEngineRef + */ + public function setToolId($toolId) + { + $this->toolId = $toolId; + + return $this; + } + + /** + * Get toolId + * + * @return string + */ + public function getToolId() + { + return $this->toolId; + } + + /** + * Set refIdHighLevel + * + * @param integer $refIdHighLevel + * @return SearchEngineRef + */ + public function setRefIdHighLevel($refIdHighLevel) + { + $this->refIdHighLevel = $refIdHighLevel; + + return $this; + } + + /** + * Get refIdHighLevel + * + * @return integer + */ + public function getRefIdHighLevel() + { + return $this->refIdHighLevel; + } + + /** + * Set refIdSecondLevel + * + * @param integer $refIdSecondLevel + * @return SearchEngineRef + */ + public function setRefIdSecondLevel($refIdSecondLevel) + { + $this->refIdSecondLevel = $refIdSecondLevel; + + return $this; + } + + /** + * Get refIdSecondLevel + * + * @return integer + */ + public function getRefIdSecondLevel() + { + return $this->refIdSecondLevel; + } + + /** + * Set searchDid + * + * @param integer $searchDid + * @return SearchEngineRef + */ + public function setSearchDid($searchDid) + { + $this->searchDid = $searchDid; + + return $this; + } + + /** + * Get searchDid + * + * @return integer + */ + public function getSearchDid() + { + return $this->searchDid; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/Session.php b/src/Chamilo/CoreBundle/Entity/Session.php index bf89973ad0..a733398598 100644 --- a/src/Chamilo/CoreBundle/Entity/Session.php +++ b/src/Chamilo/CoreBundle/Entity/Session.php @@ -50,6 +50,43 @@ class Session */ private $name; + /** + * @var string + * + * @ORM\Column(name="description", type="text", nullable=true, unique=false) + */ + private $description; + + /** + * @var string + * + * @ORM\Column(name="show_description", type="boolean", nullable=true) + */ + private $showDescription; + + /** + * @var integer + * + * @ORM\Column(name="duration", type="integer", nullable=true) + */ + private $duration; + + /** + * @return int + */ + public function getDuration() + { + return $this->duration; + } + + /** + * @param int $duration + */ + public function setDuration($duration) + { + $this->duration = $duration; + } + /** * @var integer * @@ -71,6 +108,34 @@ class Session */ private $nbrClasses; + /** + * @var \DateTime + * + * @ORM\Column(name="date_start", type="date", nullable=false) + */ + private $dateStart; + + /** + * @var \DateTime + * + * @ORM\Column(name="date_end", type="date", nullable=false) + */ + private $dateEnd; + + /** + * @var boolean + * + * @ORM\Column(name="nb_days_access_before_beginning", type="boolean", nullable=true) + */ + private $nbDaysAccessBeforeBeginning; + + /** + * @var boolean + * + * @ORM\Column(name="nb_days_access_after_end", type="boolean", nullable=true) + */ + private $nbDaysAccessAfterEnd; + /** * @var integer * @@ -196,6 +261,24 @@ class Session $this->courses = new ArrayCollection(); $this->users = new ArrayCollection(); $this->userCourseSubscriptions = new ArrayCollection(); + $this->showDescription = 0; + $this->category = null; + } + + /** + * @return string + */ + public function getShowDescription() + { + return $this->showDescription; + } + + /** + * @param string $showDescription + */ + public function setShowDescription($showDescription) + { + $this->showDescription = $showDescription; } /** @@ -440,6 +523,29 @@ class Session return $this->name; } + /** + * Set description + * + * @param string $description + * @return Groups + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + /** * Set nbrCourses * @@ -509,6 +615,75 @@ class Session return $this->nbrClasses; } + /** + * Set dateStart + * + * @param \DateTime $dateStart + * @return Session + */ + public function setDateStart($dateStart) + { + $this->dateStart = $dateStart; + + return $this; + } + + /** + * Get dateStart + * + * @return \DateTime + */ + public function getDateStart() + { + return $this->dateStart; + } + + /** + * Set dateEnd + * + * @param \DateTime $dateEnd + * @return Session + */ + public function setDateEnd($dateEnd) + { + $this->dateEnd = $dateEnd; + + return $this; + } + + /** + * Get dateEnd + * + * @return \DateTime + */ + public function getDateEnd() + { + return $this->dateEnd; + } + + /** + * Set nbDaysAccessBeforeBeginning + * + * @param boolean $nbDaysAccessBeforeBeginning + * @return Session + */ + public function setNbDaysAccessBeforeBeginning($nbDaysAccessBeforeBeginning) + { + $this->nbDaysAccessBeforeBeginning = $nbDaysAccessBeforeBeginning; + + return $this; + } + + /** + * Get nbDaysAccessBeforeBeginning + * + * @return boolean + */ + public function getNbDaysAccessBeforeBeginning() + { + return $this->nbDaysAccessBeforeBeginning; + } + /** * Set sessionAdminId * diff --git a/src/Chamilo/CoreBundle/Entity/SessionCategory.php b/src/Chamilo/CoreBundle/Entity/SessionCategory.php index d4fa92147e..aa66b011bc 100644 --- a/src/Chamilo/CoreBundle/Entity/SessionCategory.php +++ b/src/Chamilo/CoreBundle/Entity/SessionCategory.php @@ -18,7 +18,7 @@ class SessionCategory * * @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false) * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") + * @ORM\GeneratedValue */ private $id; @@ -54,6 +54,9 @@ class SessionCategory **/ protected $session; + /** + * @return string + */ public function __toString() { return (string) $this->name; diff --git a/src/Chamilo/CoreBundle/Entity/SessionField.php b/src/Chamilo/CoreBundle/Entity/SessionField.php new file mode 100644 index 0000000000..24b734388f --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SessionField.php @@ -0,0 +1,305 @@ +fieldType = $fieldType; + + return $this; + } + + /** + * Get fieldType + * + * @return integer + */ + public function getFieldType() + { + return $this->fieldType; + } + + /** + * Set fieldVariable + * + * @param string $fieldVariable + * @return SessionField + */ + public function setFieldVariable($fieldVariable) + { + $this->fieldVariable = $fieldVariable; + + return $this; + } + + /** + * Get fieldVariable + * + * @return string + */ + public function getFieldVariable() + { + return $this->fieldVariable; + } + + /** + * Set fieldDisplayText + * + * @param string $fieldDisplayText + * @return SessionField + */ + public function setFieldDisplayText($fieldDisplayText) + { + $this->fieldDisplayText = $fieldDisplayText; + + return $this; + } + + /** + * Get fieldDisplayText + * + * @return string + */ + public function getFieldDisplayText() + { + return $this->fieldDisplayText; + } + + /** + * Set fieldDefaultValue + * + * @param string $fieldDefaultValue + * @return SessionField + */ + public function setFieldDefaultValue($fieldDefaultValue) + { + $this->fieldDefaultValue = $fieldDefaultValue; + + return $this; + } + + /** + * Get fieldDefaultValue + * + * @return string + */ + public function getFieldDefaultValue() + { + return $this->fieldDefaultValue; + } + + /** + * Set fieldOrder + * + * @param integer $fieldOrder + * @return SessionField + */ + public function setFieldOrder($fieldOrder) + { + $this->fieldOrder = $fieldOrder; + + return $this; + } + + /** + * Get fieldOrder + * + * @return integer + */ + public function getFieldOrder() + { + return $this->fieldOrder; + } + + /** + * Set fieldVisible + * + * @param boolean $fieldVisible + * @return SessionField + */ + public function setFieldVisible($fieldVisible) + { + $this->fieldVisible = $fieldVisible; + + return $this; + } + + /** + * Get fieldVisible + * + * @return boolean + */ + public function getFieldVisible() + { + return $this->fieldVisible; + } + + /** + * Set fieldChangeable + * + * @param boolean $fieldChangeable + * @return SessionField + */ + public function setFieldChangeable($fieldChangeable) + { + $this->fieldChangeable = $fieldChangeable; + + return $this; + } + + /** + * Get fieldChangeable + * + * @return boolean + */ + public function getFieldChangeable() + { + return $this->fieldChangeable; + } + + /** + * Set fieldFilter + * + * @param boolean $fieldFilter + * @return SessionField + */ + public function setFieldFilter($fieldFilter) + { + $this->fieldFilter = $fieldFilter; + + return $this; + } + + /** + * Get fieldFilter + * + * @return boolean + */ + public function getFieldFilter() + { + return $this->fieldFilter; + } + + /** + * Set tms + * + * @param \DateTime $tms + * @return SessionField + */ + public function setTms($tms) + { + $this->tms = $tms; + + return $this; + } + + /** + * Get tms + * + * @return \DateTime + */ + public function getTms() + { + return $this->tms; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SessionFieldOptions.php b/src/Chamilo/CoreBundle/Entity/SessionFieldOptions.php new file mode 100644 index 0000000000..a73e60fa65 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SessionFieldOptions.php @@ -0,0 +1,185 @@ +fieldId = $fieldId; + + return $this; + } + + /** + * Get fieldId + * + * @return integer + */ + public function getFieldId() + { + return $this->fieldId; + } + + /** + * Set optionValue + * + * @param string $optionValue + * @return SessionFieldOptions + */ + public function setOptionValue($optionValue) + { + $this->optionValue = $optionValue; + + return $this; + } + + /** + * Get optionValue + * + * @return string + */ + public function getOptionValue() + { + return $this->optionValue; + } + + /** + * Set optionDisplayText + * + * @param string $optionDisplayText + * @return SessionFieldOptions + */ + public function setOptionDisplayText($optionDisplayText) + { + $this->optionDisplayText = $optionDisplayText; + + return $this; + } + + /** + * Get optionDisplayText + * + * @return string + */ + public function getOptionDisplayText() + { + return $this->optionDisplayText; + } + + /** + * Set optionOrder + * + * @param integer $optionOrder + * @return SessionFieldOptions + */ + public function setOptionOrder($optionOrder) + { + $this->optionOrder = $optionOrder; + + return $this; + } + + /** + * Get optionOrder + * + * @return integer + */ + public function getOptionOrder() + { + return $this->optionOrder; + } + + /** + * Set tms + * + * @param \DateTime $tms + * @return SessionFieldOptions + */ + public function setTms($tms) + { + $this->tms = $tms; + + return $this; + } + + /** + * Get tms + * + * @return \DateTime + */ + public function getTms() + { + return $this->tms; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SessionFieldValues.php b/src/Chamilo/CoreBundle/Entity/SessionFieldValues.php new file mode 100644 index 0000000000..8e91eab794 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SessionFieldValues.php @@ -0,0 +1,155 @@ +sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set fieldId + * + * @param integer $fieldId + * @return SessionFieldValues + */ + public function setFieldId($fieldId) + { + $this->fieldId = $fieldId; + + return $this; + } + + /** + * Get fieldId + * + * @return integer + */ + public function getFieldId() + { + return $this->fieldId; + } + + /** + * Set fieldValue + * + * @param string $fieldValue + * @return SessionFieldValues + */ + public function setFieldValue($fieldValue) + { + $this->fieldValue = $fieldValue; + + return $this; + } + + /** + * Get fieldValue + * + * @return string + */ + public function getFieldValue() + { + return $this->fieldValue; + } + + /** + * Set tms + * + * @param \DateTime $tms + * @return SessionFieldValues + */ + public function setTms($tms) + { + $this->tms = $tms; + + return $this; + } + + /** + * Get tms + * + * @return \DateTime + */ + public function getTms() + { + return $this->tms; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SessionRelCourse.php b/src/Chamilo/CoreBundle/Entity/SessionRelCourse.php index 275b70cb8c..08ac8e94ec 100644 --- a/src/Chamilo/CoreBundle/Entity/SessionRelCourse.php +++ b/src/Chamilo/CoreBundle/Entity/SessionRelCourse.php @@ -18,7 +18,7 @@ class SessionRelCourse * * @ORM\Column(name="id", type="integer") * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") + * @ORM\GeneratedValue */ protected $id; @@ -31,7 +31,7 @@ class SessionRelCourse /** * @ORM\ManyToOne(targetEntity="Session", inversedBy="courses", cascade={"persist"}) - * @ORM\JoinColumn(name="id_session", referencedColumnName="id") + * @ORM\JoinColumn(name="session_id", referencedColumnName="id") */ protected $session; @@ -41,6 +41,13 @@ class SessionRelCourse */ protected $course; + /** + * @var integer + * + * @ORM\Column(name="position", type="integer", nullable=false) + */ + private $position; + /** * Constructor */ @@ -123,4 +130,21 @@ class SessionRelCourse { return $this->nbrUsers; } + + /** + * @return int + */ + public function getPosition() + { + return $this->position; + } + + /** + * @param int $position + */ + public function setPosition($position) + { + $this->position = $position; + } + } diff --git a/src/Chamilo/CoreBundle/Entity/SessionRelCourseRelUser.php b/src/Chamilo/CoreBundle/Entity/SessionRelCourseRelUser.php index e2f9bcafa8..34374af092 100644 --- a/src/Chamilo/CoreBundle/Entity/SessionRelCourseRelUser.php +++ b/src/Chamilo/CoreBundle/Entity/SessionRelCourseRelUser.php @@ -12,7 +12,7 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Table( * name="session_rel_course_rel_user", * indexes={ - * @ORM\Index(name="idx_session_rel_course_rel_user_id_user", columns={"id_user"}), + * @ORM\Index(name="idx_session_rel_course_rel_user_id_user", columns={"user_id"}), * @ORM\Index(name="idx_session_rel_course_rel_user_course_id", columns={"c_id"}) * } * ) @@ -30,7 +30,7 @@ class SessionRelCourseRelUser * * @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false) * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") + * @ORM\GeneratedValue */ private $id; @@ -58,14 +58,14 @@ class SessionRelCourseRelUser /** * @var User * @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User", inversedBy="sessionCourseSubscriptions", cascade={"persist"}) - * @ORM\JoinColumn(name="id_user", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id") */ protected $user; /** * @var Session * @ORM\ManyToOne(targetEntity="Session", inversedBy="userCourseSubscriptions", cascade={"persist"}) - * @ORM\JoinColumn(name="id_session", referencedColumnName="id") + * @ORM\JoinColumn(name="session_id", referencedColumnName="id") */ protected $session; diff --git a/src/Chamilo/CoreBundle/Entity/SessionRelUser.php b/src/Chamilo/CoreBundle/Entity/SessionRelUser.php index cef2749903..83d207fe08 100644 --- a/src/Chamilo/CoreBundle/Entity/SessionRelUser.php +++ b/src/Chamilo/CoreBundle/Entity/SessionRelUser.php @@ -12,13 +12,22 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Table( * name="session_rel_user", * indexes={ - * @ORM\Index(name="idx_session_rel_user_id_user_moved", columns={"id_user", "moved_to"}) + * @ORM\Index(name="idx_session_rel_user_id_user_moved", columns={"user_id", "moved_to"}) * } * ) * @ORM\Entity */ class SessionRelUser { + /** + * @var integer + * + * @ORM\Column(name="id", type="integer") + * @ORM\Id + * @ORM\GeneratedValue + */ + private $iid; + public $relationTypeList = array( 0 => 'student', 1 => 'drh' @@ -26,22 +35,20 @@ class SessionRelUser /** * @ORM\ManyToOne(targetEntity="Session", inversedBy="users", cascade={"persist"}) - * @ORM\JoinColumn(name="id_session", referencedColumnName="id") + * @ORM\JoinColumn(name="session_id", referencedColumnName="id") */ private $session; /** * @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User", inversedBy="users", cascade={"persist"}) - * @ORM\JoinColumn(name="id_user", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id") */ private $user; /** * @var integer * - * @ORM\Column(name="relation_type", type="integer", precision=0, scale=0, nullable=false, unique=false) - * @ORM\Id - * @ORM\GeneratedValue(strategy="NONE") + * @ORM\Column(name="relation_type", type="integer", nullable=false, unique=false) */ private $relationType; diff --git a/src/Chamilo/CoreBundle/Entity/SettingsCurrent.php b/src/Chamilo/CoreBundle/Entity/SettingsCurrent.php new file mode 100644 index 0000000000..4c0398678e --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SettingsCurrent.php @@ -0,0 +1,394 @@ +variable = $variable; + + return $this; + } + + /** + * Get variable + * + * @return string + */ + public function getVariable() + { + return $this->variable; + } + + /** + * Set subkey + * + * @param string $subkey + * @return SettingsCurrent + */ + public function setSubkey($subkey) + { + $this->subkey = $subkey; + + return $this; + } + + /** + * Get subkey + * + * @return string + */ + public function getSubkey() + { + return $this->subkey; + } + + /** + * Set type + * + * @param string $type + * @return SettingsCurrent + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set category + * + * @param string $category + * @return SettingsCurrent + */ + public function setCategory($category) + { + $this->category = $category; + + return $this; + } + + /** + * Get category + * + * @return string + */ + public function getCategory() + { + return $this->category; + } + + /** + * Set selectedValue + * + * @param string $selectedValue + * @return SettingsCurrent + */ + public function setSelectedValue($selectedValue) + { + $this->selectedValue = $selectedValue; + + return $this; + } + + /** + * Get selectedValue + * + * @return string + */ + public function getSelectedValue() + { + return $this->selectedValue; + } + + /** + * Set title + * + * @param string $title + * @return SettingsCurrent + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set comment + * + * @param string $comment + * @return SettingsCurrent + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set scope + * + * @param string $scope + * @return SettingsCurrent + */ + public function setScope($scope) + { + $this->scope = $scope; + + return $this; + } + + /** + * Get scope + * + * @return string + */ + public function getScope() + { + return $this->scope; + } + + /** + * Set subkeytext + * + * @param string $subkeytext + * @return SettingsCurrent + */ + public function setSubkeytext($subkeytext) + { + $this->subkeytext = $subkeytext; + + return $this; + } + + /** + * Get subkeytext + * + * @return string + */ + public function getSubkeytext() + { + return $this->subkeytext; + } + + /** + * Set accessUrl + * + * @param integer $accessUrl + * @return SettingsCurrent + */ + public function setAccessUrl($accessUrl) + { + $this->accessUrl = $accessUrl; + + return $this; + } + + /** + * Get accessUrl + * + * @return integer + */ + public function getAccessUrl() + { + return $this->accessUrl; + } + + /** + * Set accessUrlChangeable + * + * @param integer $accessUrlChangeable + * @return SettingsCurrent + */ + public function setAccessUrlChangeable($accessUrlChangeable) + { + $this->accessUrlChangeable = $accessUrlChangeable; + + return $this; + } + + /** + * Get accessUrlChangeable + * + * @return integer + */ + public function getAccessUrlChangeable() + { + return $this->accessUrlChangeable; + } + + /** + * Set accessUrlLocked + * + * @param integer $accessUrlLocked + * @return SettingsCurrent + */ + public function setAccessUrlLocked($accessUrlLocked) + { + $this->accessUrlLocked = $accessUrlLocked; + + return $this; + } + + /** + * Get accessUrlLocked + * + * @return integer + */ + public function getAccessUrlLocked() + { + return $this->accessUrlLocked; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SettingsOptions.php b/src/Chamilo/CoreBundle/Entity/SettingsOptions.php new file mode 100644 index 0000000000..093a3153da --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SettingsOptions.php @@ -0,0 +1,125 @@ +variable = $variable; + + return $this; + } + + /** + * Get variable + * + * @return string + */ + public function getVariable() + { + return $this->variable; + } + + /** + * Set value + * + * @param string $value + * @return SettingsOptions + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Set displayText + * + * @param string $displayText + * @return SettingsOptions + */ + public function setDisplayText($displayText) + { + $this->displayText = $displayText; + + return $this; + } + + /** + * Get displayText + * + * @return string + */ + public function getDisplayText() + { + return $this->displayText; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SharedSurvey.php b/src/Chamilo/CoreBundle/Entity/SharedSurvey.php new file mode 100644 index 0000000000..b214834b44 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SharedSurvey.php @@ -0,0 +1,335 @@ +code = $code; + + return $this; + } + + /** + * Get code + * + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * Set title + * + * @param string $title + * @return SharedSurvey + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set subtitle + * + * @param string $subtitle + * @return SharedSurvey + */ + public function setSubtitle($subtitle) + { + $this->subtitle = $subtitle; + + return $this; + } + + /** + * Get subtitle + * + * @return string + */ + public function getSubtitle() + { + return $this->subtitle; + } + + /** + * Set author + * + * @param string $author + * @return SharedSurvey + */ + public function setAuthor($author) + { + $this->author = $author; + + return $this; + } + + /** + * Get author + * + * @return string + */ + public function getAuthor() + { + return $this->author; + } + + /** + * Set lang + * + * @param string $lang + * @return SharedSurvey + */ + public function setLang($lang) + { + $this->lang = $lang; + + return $this; + } + + /** + * Get lang + * + * @return string + */ + public function getLang() + { + return $this->lang; + } + + /** + * Set template + * + * @param string $template + * @return SharedSurvey + */ + public function setTemplate($template) + { + $this->template = $template; + + return $this; + } + + /** + * Get template + * + * @return string + */ + public function getTemplate() + { + return $this->template; + } + + /** + * Set intro + * + * @param string $intro + * @return SharedSurvey + */ + public function setIntro($intro) + { + $this->intro = $intro; + + return $this; + } + + /** + * Get intro + * + * @return string + */ + public function getIntro() + { + return $this->intro; + } + + /** + * Set surveythanks + * + * @param string $surveythanks + * @return SharedSurvey + */ + public function setSurveythanks($surveythanks) + { + $this->surveythanks = $surveythanks; + + return $this; + } + + /** + * Get surveythanks + * + * @return string + */ + public function getSurveythanks() + { + return $this->surveythanks; + } + + /** + * Set creationDate + * + * @param \DateTime $creationDate + * @return SharedSurvey + */ + public function setCreationDate($creationDate) + { + $this->creationDate = $creationDate; + + return $this; + } + + /** + * Get creationDate + * + * @return \DateTime + */ + public function getCreationDate() + { + return $this->creationDate; + } + + /** + * Set courseCode + * + * @param string $courseCode + * @return SharedSurvey + */ + public function setCourseCode($courseCode) + { + $this->courseCode = $courseCode; + + return $this; + } + + /** + * Get courseCode + * + * @return string + */ + public function getCourseCode() + { + return $this->courseCode; + } + + /** + * Get surveyId + * + * @return integer + */ + public function getSurveyId() + { + return $this->surveyId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SharedSurveyQuestion.php b/src/Chamilo/CoreBundle/Entity/SharedSurveyQuestion.php new file mode 100644 index 0000000000..e3b96170a1 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SharedSurveyQuestion.php @@ -0,0 +1,275 @@ +surveyId = $surveyId; + + return $this; + } + + /** + * Get surveyId + * + * @return integer + */ + public function getSurveyId() + { + return $this->surveyId; + } + + /** + * Set surveyQuestion + * + * @param string $surveyQuestion + * @return SharedSurveyQuestion + */ + public function setSurveyQuestion($surveyQuestion) + { + $this->surveyQuestion = $surveyQuestion; + + return $this; + } + + /** + * Get surveyQuestion + * + * @return string + */ + public function getSurveyQuestion() + { + return $this->surveyQuestion; + } + + /** + * Set surveyQuestionComment + * + * @param string $surveyQuestionComment + * @return SharedSurveyQuestion + */ + public function setSurveyQuestionComment($surveyQuestionComment) + { + $this->surveyQuestionComment = $surveyQuestionComment; + + return $this; + } + + /** + * Get surveyQuestionComment + * + * @return string + */ + public function getSurveyQuestionComment() + { + return $this->surveyQuestionComment; + } + + /** + * Set type + * + * @param string $type + * @return SharedSurveyQuestion + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set display + * + * @param string $display + * @return SharedSurveyQuestion + */ + public function setDisplay($display) + { + $this->display = $display; + + return $this; + } + + /** + * Get display + * + * @return string + */ + public function getDisplay() + { + return $this->display; + } + + /** + * Set sort + * + * @param integer $sort + * @return SharedSurveyQuestion + */ + public function setSort($sort) + { + $this->sort = $sort; + + return $this; + } + + /** + * Get sort + * + * @return integer + */ + public function getSort() + { + return $this->sort; + } + + /** + * Set code + * + * @param string $code + * @return SharedSurveyQuestion + */ + public function setCode($code) + { + $this->code = $code; + + return $this; + } + + /** + * Get code + * + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * Set maxValue + * + * @param integer $maxValue + * @return SharedSurveyQuestion + */ + public function setMaxValue($maxValue) + { + $this->maxValue = $maxValue; + + return $this; + } + + /** + * Get maxValue + * + * @return integer + */ + public function getMaxValue() + { + return $this->maxValue; + } + + /** + * Get questionId + * + * @return integer + */ + public function getQuestionId() + { + return $this->questionId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SharedSurveyQuestionOption.php b/src/Chamilo/CoreBundle/Entity/SharedSurveyQuestionOption.php new file mode 100644 index 0000000000..36a005d7b5 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SharedSurveyQuestionOption.php @@ -0,0 +1,155 @@ +questionId = $questionId; + + return $this; + } + + /** + * Get questionId + * + * @return integer + */ + public function getQuestionId() + { + return $this->questionId; + } + + /** + * Set surveyId + * + * @param integer $surveyId + * @return SharedSurveyQuestionOption + */ + public function setSurveyId($surveyId) + { + $this->surveyId = $surveyId; + + return $this; + } + + /** + * Get surveyId + * + * @return integer + */ + public function getSurveyId() + { + return $this->surveyId; + } + + /** + * Set optionText + * + * @param string $optionText + * @return SharedSurveyQuestionOption + */ + public function setOptionText($optionText) + { + $this->optionText = $optionText; + + return $this; + } + + /** + * Get optionText + * + * @return string + */ + public function getOptionText() + { + return $this->optionText; + } + + /** + * Set sort + * + * @param integer $sort + * @return SharedSurveyQuestionOption + */ + public function setSort($sort) + { + $this->sort = $sort; + + return $this; + } + + /** + * Get sort + * + * @return integer + */ + public function getSort() + { + return $this->sort; + } + + /** + * Get questionOptionId + * + * @return integer + */ + public function getQuestionOptionId() + { + return $this->questionOptionId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/Skill.php b/src/Chamilo/CoreBundle/Entity/Skill.php new file mode 100644 index 0000000000..a4f410a3fe --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/Skill.php @@ -0,0 +1,215 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set shortCode + * + * @param string $shortCode + * @return Skill + */ + public function setShortCode($shortCode) + { + $this->shortCode = $shortCode; + + return $this; + } + + /** + * Get shortCode + * + * @return string + */ + public function getShortCode() + { + return $this->shortCode; + } + + /** + * Set description + * + * @param string $description + * @return Skill + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set accessUrlId + * + * @param integer $accessUrlId + * @return Skill + */ + public function setAccessUrlId($accessUrlId) + { + $this->accessUrlId = $accessUrlId; + + return $this; + } + + /** + * Get accessUrlId + * + * @return integer + */ + public function getAccessUrlId() + { + return $this->accessUrlId; + } + + /** + * Set icon + * + * @param string $icon + * @return Skill + */ + public function setIcon($icon) + { + $this->icon = $icon; + + return $this; + } + + /** + * Get icon + * + * @return string + */ + public function getIcon() + { + return $this->icon; + } + + /** + * Set criteria + * + * @param string $criteria + * @return Skill + */ + public function setCriteria($criteria) + { + $this->criteria = $criteria; + + return $this; + } + + /** + * Get criteria + * + * @return string + */ + public function getCriteria() + { + return $this->criteria; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SkillProfile.php b/src/Chamilo/CoreBundle/Entity/SkillProfile.php new file mode 100644 index 0000000000..6bbf42bced --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SkillProfile.php @@ -0,0 +1,95 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set description + * + * @param string $description + * @return SkillProfile + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SkillRelGradebook.php b/src/Chamilo/CoreBundle/Entity/SkillRelGradebook.php new file mode 100644 index 0000000000..3271ff3cab --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SkillRelGradebook.php @@ -0,0 +1,125 @@ +gradebookId = $gradebookId; + + return $this; + } + + /** + * Get gradebookId + * + * @return integer + */ + public function getGradebookId() + { + return $this->gradebookId; + } + + /** + * Set skillId + * + * @param integer $skillId + * @return SkillRelGradebook + */ + public function setSkillId($skillId) + { + $this->skillId = $skillId; + + return $this; + } + + /** + * Get skillId + * + * @return integer + */ + public function getSkillId() + { + return $this->skillId; + } + + /** + * Set type + * + * @param string $type + * @return SkillRelGradebook + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SkillRelProfile.php b/src/Chamilo/CoreBundle/Entity/SkillRelProfile.php new file mode 100644 index 0000000000..1b11e36a91 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SkillRelProfile.php @@ -0,0 +1,95 @@ +skillId = $skillId; + + return $this; + } + + /** + * Get skillId + * + * @return integer + */ + public function getSkillId() + { + return $this->skillId; + } + + /** + * Set profileId + * + * @param integer $profileId + * @return SkillRelProfile + */ + public function setProfileId($profileId) + { + $this->profileId = $profileId; + + return $this; + } + + /** + * Get profileId + * + * @return integer + */ + public function getProfileId() + { + return $this->profileId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SkillRelSkill.php b/src/Chamilo/CoreBundle/Entity/SkillRelSkill.php new file mode 100644 index 0000000000..9506468d84 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SkillRelSkill.php @@ -0,0 +1,155 @@ +skillId = $skillId; + + return $this; + } + + /** + * Get skillId + * + * @return integer + */ + public function getSkillId() + { + return $this->skillId; + } + + /** + * Set parentId + * + * @param integer $parentId + * @return SkillRelSkill + */ + public function setParentId($parentId) + { + $this->parentId = $parentId; + + return $this; + } + + /** + * Get parentId + * + * @return integer + */ + public function getParentId() + { + return $this->parentId; + } + + /** + * Set relationType + * + * @param integer $relationType + * @return SkillRelSkill + */ + public function setRelationType($relationType) + { + $this->relationType = $relationType; + + return $this; + } + + /** + * Get relationType + * + * @return integer + */ + public function getRelationType() + { + return $this->relationType; + } + + /** + * Set level + * + * @param integer $level + * @return SkillRelSkill + */ + public function setLevel($level) + { + $this->level = $level; + + return $this; + } + + /** + * Get level + * + * @return integer + */ + public function getLevel() + { + return $this->level; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SkillRelUser.php b/src/Chamilo/CoreBundle/Entity/SkillRelUser.php new file mode 100644 index 0000000000..9146df32e6 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SkillRelUser.php @@ -0,0 +1,215 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set skillId + * + * @param integer $skillId + * @return SkillRelUser + */ + public function setSkillId($skillId) + { + $this->skillId = $skillId; + + return $this; + } + + /** + * Get skillId + * + * @return integer + */ + public function getSkillId() + { + return $this->skillId; + } + + /** + * Set acquiredSkillAt + * + * @param \DateTime $acquiredSkillAt + * @return SkillRelUser + */ + public function setAcquiredSkillAt($acquiredSkillAt) + { + $this->acquiredSkillAt = $acquiredSkillAt; + + return $this; + } + + /** + * Get acquiredSkillAt + * + * @return \DateTime + */ + public function getAcquiredSkillAt() + { + return $this->acquiredSkillAt; + } + + /** + * Set assignedBy + * + * @param integer $assignedBy + * @return SkillRelUser + */ + public function setAssignedBy($assignedBy) + { + $this->assignedBy = $assignedBy; + + return $this; + } + + /** + * Get assignedBy + * + * @return integer + */ + public function getAssignedBy() + { + return $this->assignedBy; + } + + /** + * Set courseId + * + * @param integer $courseId + * @return SkillRelUser + */ + public function setCourseId($courseId) + { + $this->courseId = $courseId; + + return $this; + } + + /** + * Get courseId + * + * @return integer + */ + public function getCourseId() + { + return $this->courseId; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return SkillRelUser + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SpecificField.php b/src/Chamilo/CoreBundle/Entity/SpecificField.php new file mode 100644 index 0000000000..2b996510fc --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SpecificField.php @@ -0,0 +1,95 @@ +code = $code; + + return $this; + } + + /** + * Get code + * + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * Set name + * + * @param string $name + * @return SpecificField + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SpecificFieldValues.php b/src/Chamilo/CoreBundle/Entity/SpecificFieldValues.php new file mode 100644 index 0000000000..25b728f4f4 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SpecificFieldValues.php @@ -0,0 +1,185 @@ +courseCode = $courseCode; + + return $this; + } + + /** + * Get courseCode + * + * @return string + */ + public function getCourseCode() + { + return $this->courseCode; + } + + /** + * Set toolId + * + * @param string $toolId + * @return SpecificFieldValues + */ + public function setToolId($toolId) + { + $this->toolId = $toolId; + + return $this; + } + + /** + * Get toolId + * + * @return string + */ + public function getToolId() + { + return $this->toolId; + } + + /** + * Set refId + * + * @param integer $refId + * @return SpecificFieldValues + */ + public function setRefId($refId) + { + $this->refId = $refId; + + return $this; + } + + /** + * Get refId + * + * @return integer + */ + public function getRefId() + { + return $this->refId; + } + + /** + * Set fieldId + * + * @param integer $fieldId + * @return SpecificFieldValues + */ + public function setFieldId($fieldId) + { + $this->fieldId = $fieldId; + + return $this; + } + + /** + * Get fieldId + * + * @return integer + */ + public function getFieldId() + { + return $this->fieldId; + } + + /** + * Set value + * + * @param string $value + * @return SpecificFieldValues + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SysAnnouncement.php b/src/Chamilo/CoreBundle/Entity/SysAnnouncement.php new file mode 100644 index 0000000000..ca830d7501 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SysAnnouncement.php @@ -0,0 +1,305 @@ +dateStart = $dateStart; + + return $this; + } + + /** + * Get dateStart + * + * @return \DateTime + */ + public function getDateStart() + { + return $this->dateStart; + } + + /** + * Set dateEnd + * + * @param \DateTime $dateEnd + * @return SysAnnouncement + */ + public function setDateEnd($dateEnd) + { + $this->dateEnd = $dateEnd; + + return $this; + } + + /** + * Get dateEnd + * + * @return \DateTime + */ + public function getDateEnd() + { + return $this->dateEnd; + } + + /** + * Set visibleTeacher + * + * @param boolean $visibleTeacher + * @return SysAnnouncement + */ + public function setVisibleTeacher($visibleTeacher) + { + $this->visibleTeacher = $visibleTeacher; + + return $this; + } + + /** + * Get visibleTeacher + * + * @return boolean + */ + public function getVisibleTeacher() + { + return $this->visibleTeacher; + } + + /** + * Set visibleStudent + * + * @param boolean $visibleStudent + * @return SysAnnouncement + */ + public function setVisibleStudent($visibleStudent) + { + $this->visibleStudent = $visibleStudent; + + return $this; + } + + /** + * Get visibleStudent + * + * @return boolean + */ + public function getVisibleStudent() + { + return $this->visibleStudent; + } + + /** + * Set visibleGuest + * + * @param boolean $visibleGuest + * @return SysAnnouncement + */ + public function setVisibleGuest($visibleGuest) + { + $this->visibleGuest = $visibleGuest; + + return $this; + } + + /** + * Get visibleGuest + * + * @return boolean + */ + public function getVisibleGuest() + { + return $this->visibleGuest; + } + + /** + * Set title + * + * @param string $title + * @return SysAnnouncement + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set content + * + * @param string $content + * @return SysAnnouncement + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Set lang + * + * @param string $lang + * @return SysAnnouncement + */ + public function setLang($lang) + { + $this->lang = $lang; + + return $this; + } + + /** + * Get lang + * + * @return string + */ + public function getLang() + { + return $this->lang; + } + + /** + * Set accessUrlId + * + * @param integer $accessUrlId + * @return SysAnnouncement + */ + public function setAccessUrlId($accessUrlId) + { + $this->accessUrlId = $accessUrlId; + + return $this; + } + + /** + * Get accessUrlId + * + * @return integer + */ + public function getAccessUrlId() + { + return $this->accessUrlId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SysCalendar.php b/src/Chamilo/CoreBundle/Entity/SysCalendar.php new file mode 100644 index 0000000000..135178ff99 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SysCalendar.php @@ -0,0 +1,215 @@ +title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set content + * + * @param string $content + * @return SysCalendar + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Set startDate + * + * @param \DateTime $startDate + * @return SysCalendar + */ + public function setStartDate($startDate) + { + $this->startDate = $startDate; + + return $this; + } + + /** + * Get startDate + * + * @return \DateTime + */ + public function getStartDate() + { + return $this->startDate; + } + + /** + * Set endDate + * + * @param \DateTime $endDate + * @return SysCalendar + */ + public function setEndDate($endDate) + { + $this->endDate = $endDate; + + return $this; + } + + /** + * Get endDate + * + * @return \DateTime + */ + public function getEndDate() + { + return $this->endDate; + } + + /** + * Set accessUrlId + * + * @param integer $accessUrlId + * @return SysCalendar + */ + public function setAccessUrlId($accessUrlId) + { + $this->accessUrlId = $accessUrlId; + + return $this; + } + + /** + * Get accessUrlId + * + * @return integer + */ + public function getAccessUrlId() + { + return $this->accessUrlId; + } + + /** + * Set allDay + * + * @param integer $allDay + * @return SysCalendar + */ + public function setAllDay($allDay) + { + $this->allDay = $allDay; + + return $this; + } + + /** + * Get allDay + * + * @return integer + */ + public function getAllDay() + { + return $this->allDay; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/SystemTemplate.php b/src/Chamilo/CoreBundle/Entity/SystemTemplate.php new file mode 100644 index 0000000000..93f8c95568 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SystemTemplate.php @@ -0,0 +1,155 @@ +title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set comment + * + * @param string $comment + * @return SystemTemplate + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set image + * + * @param string $image + * @return SystemTemplate + */ + public function setImage($image) + { + $this->image = $image; + + return $this; + } + + /** + * Get image + * + * @return string + */ + public function getImage() + { + return $this->image; + } + + /** + * Set content + * + * @param string $content + * @return SystemTemplate + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/Tag.php b/src/Chamilo/CoreBundle/Entity/Tag.php new file mode 100644 index 0000000000..cd549603f1 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/Tag.php @@ -0,0 +1,125 @@ +tag = $tag; + + return $this; + } + + /** + * Get tag + * + * @return string + */ + public function getTag() + { + return $this->tag; + } + + /** + * Set fieldId + * + * @param integer $fieldId + * @return Tag + */ + public function setFieldId($fieldId) + { + $this->fieldId = $fieldId; + + return $this; + } + + /** + * Get fieldId + * + * @return integer + */ + public function getFieldId() + { + return $this->fieldId; + } + + /** + * Set count + * + * @param integer $count + * @return Tag + */ + public function setCount($count) + { + $this->count = $count; + + return $this; + } + + /** + * Get count + * + * @return integer + */ + public function getCount() + { + return $this->count; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/Templates.php b/src/Chamilo/CoreBundle/Entity/Templates.php new file mode 100644 index 0000000000..8937b99648 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/Templates.php @@ -0,0 +1,215 @@ +title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set description + * + * @param string $description + * @return Templates + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set courseCode + * + * @param string $courseCode + * @return Templates + */ + public function setCourseCode($courseCode) + { + $this->courseCode = $courseCode; + + return $this; + } + + /** + * Get courseCode + * + * @return string + */ + public function getCourseCode() + { + return $this->courseCode; + } + + /** + * Set userId + * + * @param integer $userId + * @return Templates + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set refDoc + * + * @param integer $refDoc + * @return Templates + */ + public function setRefDoc($refDoc) + { + $this->refDoc = $refDoc; + + return $this; + } + + /** + * Get refDoc + * + * @return integer + */ + public function getRefDoc() + { + return $this->refDoc; + } + + /** + * Set image + * + * @param string $image + * @return Templates + */ + public function setImage($image) + { + $this->image = $image; + + return $this; + } + + /** + * Get image + * + * @return string + */ + public function getImage() + { + return $this->image; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackCourseRanking.php b/src/Chamilo/CoreBundle/Entity/TrackCourseRanking.php new file mode 100644 index 0000000000..39ed7de4c8 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackCourseRanking.php @@ -0,0 +1,245 @@ +cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return TrackCourseRanking + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set urlId + * + * @param integer $urlId + * @return TrackCourseRanking + */ + public function setUrlId($urlId) + { + $this->urlId = $urlId; + + return $this; + } + + /** + * Get urlId + * + * @return integer + */ + public function getUrlId() + { + return $this->urlId; + } + + /** + * Set accesses + * + * @param integer $accesses + * @return TrackCourseRanking + */ + public function setAccesses($accesses) + { + $this->accesses = $accesses; + + return $this; + } + + /** + * Get accesses + * + * @return integer + */ + public function getAccesses() + { + return $this->accesses; + } + + /** + * Set totalScore + * + * @param integer $totalScore + * @return TrackCourseRanking + */ + public function setTotalScore($totalScore) + { + $this->totalScore = $totalScore; + + return $this; + } + + /** + * Get totalScore + * + * @return integer + */ + public function getTotalScore() + { + return $this->totalScore; + } + + /** + * Set users + * + * @param integer $users + * @return TrackCourseRanking + */ + public function setUsers($users) + { + $this->users = $users; + + return $this; + } + + /** + * Get users + * + * @return integer + */ + public function getUsers() + { + return $this->users; + } + + /** + * Set creationDate + * + * @param \DateTime $creationDate + * @return TrackCourseRanking + */ + public function setCreationDate($creationDate) + { + $this->creationDate = $creationDate; + + return $this; + } + + /** + * Get creationDate + * + * @return \DateTime + */ + public function getCreationDate() + { + return $this->creationDate; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackEAccess.php b/src/Chamilo/CoreBundle/Entity/TrackEAccess.php new file mode 100644 index 0000000000..1ef32790da --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackEAccess.php @@ -0,0 +1,215 @@ +accessUserId = $accessUserId; + + return $this; + } + + /** + * Get accessUserId + * + * @return integer + */ + public function getAccessUserId() + { + return $this->accessUserId; + } + + /** + * Set accessDate + * + * @param \DateTime $accessDate + * @return TrackEAccess + */ + public function setAccessDate($accessDate) + { + $this->accessDate = $accessDate; + + return $this; + } + + /** + * Get accessDate + * + * @return \DateTime + */ + public function getAccessDate() + { + return $this->accessDate; + } + + /** + * Set cId + * + * @param integer $cId + * @return TrackEAccess + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set accessTool + * + * @param string $accessTool + * @return TrackEAccess + */ + public function setAccessTool($accessTool) + { + $this->accessTool = $accessTool; + + return $this; + } + + /** + * Get accessTool + * + * @return string + */ + public function getAccessTool() + { + return $this->accessTool; + } + + /** + * Set accessSessionId + * + * @param integer $accessSessionId + * @return TrackEAccess + */ + public function setAccessSessionId($accessSessionId) + { + $this->accessSessionId = $accessSessionId; + + return $this; + } + + /** + * Get accessSessionId + * + * @return integer + */ + public function getAccessSessionId() + { + return $this->accessSessionId; + } + + /** + * Set userIp + * + * @param string $userIp + * @return TrackEAccess + */ + public function setUserIp($userIp) + { + $this->userIp = $userIp; + + return $this; + } + + /** + * Get userIp + * + * @return string + */ + public function getUserIp() + { + return $this->userIp; + } + + /** + * Get accessId + * + * @return integer + */ + public function getAccessId() + { + return $this->accessId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackEAttempt.php b/src/Chamilo/CoreBundle/Entity/TrackEAttempt.php new file mode 100644 index 0000000000..5d0c46d9c4 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackEAttempt.php @@ -0,0 +1,395 @@ +exeId = $exeId; + + return $this; + } + + /** + * Get exeId + * + * @return integer + */ + public function getExeId() + { + return $this->exeId; + } + + /** + * Set userId + * + * @param integer $userId + * @return TrackEAttempt + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set questionId + * + * @param integer $questionId + * @return TrackEAttempt + */ + public function setQuestionId($questionId) + { + $this->questionId = $questionId; + + return $this; + } + + /** + * Get questionId + * + * @return integer + */ + public function getQuestionId() + { + return $this->questionId; + } + + /** + * Set answer + * + * @param string $answer + * @return TrackEAttempt + */ + public function setAnswer($answer) + { + $this->answer = $answer; + + return $this; + } + + /** + * Get answer + * + * @return string + */ + public function getAnswer() + { + return $this->answer; + } + + /** + * Set teacherComment + * + * @param string $teacherComment + * @return TrackEAttempt + */ + public function setTeacherComment($teacherComment) + { + $this->teacherComment = $teacherComment; + + return $this; + } + + /** + * Get teacherComment + * + * @return string + */ + public function getTeacherComment() + { + return $this->teacherComment; + } + + /** + * Set marks + * + * @param float $marks + * @return TrackEAttempt + */ + public function setMarks($marks) + { + $this->marks = $marks; + + return $this; + } + + /** + * Get marks + * + * @return float + */ + public function getMarks() + { + return $this->marks; + } + + /** + * Set courseCode + * + * @param string $courseCode + * @return TrackEAttempt + */ + public function setCourseCode($courseCode) + { + $this->courseCode = $courseCode; + + return $this; + } + + /** + * Get courseCode + * + * @return string + */ + public function getCourseCode() + { + return $this->courseCode; + } + + /** + * Set cId + * + * @param integer $cId + * @return TrackEAttempt + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set position + * + * @param integer $position + * @return TrackEAttempt + */ + public function setPosition($position) + { + $this->position = $position; + + return $this; + } + + /** + * Get position + * + * @return integer + */ + public function getPosition() + { + return $this->position; + } + + /** + * Set tms + * + * @param \DateTime $tms + * @return TrackEAttempt + */ + public function setTms($tms) + { + $this->tms = $tms; + + return $this; + } + + /** + * Get tms + * + * @return \DateTime + */ + public function getTms() + { + return $this->tms; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return TrackEAttempt + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set filename + * + * @param string $filename + * @return TrackEAttempt + */ + public function setFilename($filename) + { + $this->filename = $filename; + + return $this; + } + + /** + * Get filename + * + * @return string + */ + public function getFilename() + { + return $this->filename; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackEAttemptCoeff.php b/src/Chamilo/CoreBundle/Entity/TrackEAttemptCoeff.php new file mode 100644 index 0000000000..929ef2b851 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackEAttemptCoeff.php @@ -0,0 +1,95 @@ +attemptId = $attemptId; + + return $this; + } + + /** + * Get attemptId + * + * @return integer + */ + public function getAttemptId() + { + return $this->attemptId; + } + + /** + * Set marksCoeff + * + * @param float $marksCoeff + * @return TrackEAttemptCoeff + */ + public function setMarksCoeff($marksCoeff) + { + $this->marksCoeff = $marksCoeff; + + return $this; + } + + /** + * Get marksCoeff + * + * @return float + */ + public function getMarksCoeff() + { + return $this->marksCoeff; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackEAttemptRecording.php b/src/Chamilo/CoreBundle/Entity/TrackEAttemptRecording.php new file mode 100644 index 0000000000..d8b5c8189b --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackEAttemptRecording.php @@ -0,0 +1,245 @@ +exeId = $exeId; + + return $this; + } + + /** + * Get exeId + * + * @return integer + */ + public function getExeId() + { + return $this->exeId; + } + + /** + * Set questionId + * + * @param integer $questionId + * @return TrackEAttemptRecording + */ + public function setQuestionId($questionId) + { + $this->questionId = $questionId; + + return $this; + } + + /** + * Get questionId + * + * @return integer + */ + public function getQuestionId() + { + return $this->questionId; + } + + /** + * Set marks + * + * @param integer $marks + * @return TrackEAttemptRecording + */ + public function setMarks($marks) + { + $this->marks = $marks; + + return $this; + } + + /** + * Get marks + * + * @return integer + */ + public function getMarks() + { + return $this->marks; + } + + /** + * Set insertDate + * + * @param \DateTime $insertDate + * @return TrackEAttemptRecording + */ + public function setInsertDate($insertDate) + { + $this->insertDate = $insertDate; + + return $this; + } + + /** + * Get insertDate + * + * @return \DateTime + */ + public function getInsertDate() + { + return $this->insertDate; + } + + /** + * Set author + * + * @param integer $author + * @return TrackEAttemptRecording + */ + public function setAuthor($author) + { + $this->author = $author; + + return $this; + } + + /** + * Get author + * + * @return integer + */ + public function getAuthor() + { + return $this->author; + } + + /** + * Set teacherComment + * + * @param string $teacherComment + * @return TrackEAttemptRecording + */ + public function setTeacherComment($teacherComment) + { + $this->teacherComment = $teacherComment; + + return $this; + } + + /** + * Get teacherComment + * + * @return string + */ + public function getTeacherComment() + { + return $this->teacherComment; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return TrackEAttemptRecording + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackECourseAccess.php b/src/Chamilo/CoreBundle/Entity/TrackECourseAccess.php new file mode 100644 index 0000000000..8349c1cd46 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackECourseAccess.php @@ -0,0 +1,245 @@ +cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set userId + * + * @param integer $userId + * @return TrackECourseAccess + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set loginCourseDate + * + * @param \DateTime $loginCourseDate + * @return TrackECourseAccess + */ + public function setLoginCourseDate($loginCourseDate) + { + $this->loginCourseDate = $loginCourseDate; + + return $this; + } + + /** + * Get loginCourseDate + * + * @return \DateTime + */ + public function getLoginCourseDate() + { + return $this->loginCourseDate; + } + + /** + * Set logoutCourseDate + * + * @param \DateTime $logoutCourseDate + * @return TrackECourseAccess + */ + public function setLogoutCourseDate($logoutCourseDate) + { + $this->logoutCourseDate = $logoutCourseDate; + + return $this; + } + + /** + * Get logoutCourseDate + * + * @return \DateTime + */ + public function getLogoutCourseDate() + { + return $this->logoutCourseDate; + } + + /** + * Set counter + * + * @param integer $counter + * @return TrackECourseAccess + */ + public function setCounter($counter) + { + $this->counter = $counter; + + return $this; + } + + /** + * Get counter + * + * @return integer + */ + public function getCounter() + { + return $this->counter; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return TrackECourseAccess + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set userIp + * + * @param string $userIp + * @return TrackECourseAccess + */ + public function setUserIp($userIp) + { + $this->userIp = $userIp; + + return $this; + } + + /** + * Get userIp + * + * @return string + */ + public function getUserIp() + { + return $this->userIp; + } + + /** + * Get courseAccessId + * + * @return integer + */ + public function getCourseAccessId() + { + return $this->courseAccessId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackEDefault.php b/src/Chamilo/CoreBundle/Entity/TrackEDefault.php new file mode 100644 index 0000000000..18086d1f45 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackEDefault.php @@ -0,0 +1,245 @@ +defaultUserId = $defaultUserId; + + return $this; + } + + /** + * Get defaultUserId + * + * @return integer + */ + public function getDefaultUserId() + { + return $this->defaultUserId; + } + + /** + * Set cId + * + * @param integer $cId + * @return TrackEDefault + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set defaultDate + * + * @param \DateTime $defaultDate + * @return TrackEDefault + */ + public function setDefaultDate($defaultDate) + { + $this->defaultDate = $defaultDate; + + return $this; + } + + /** + * Get defaultDate + * + * @return \DateTime + */ + public function getDefaultDate() + { + return $this->defaultDate; + } + + /** + * Set defaultEventType + * + * @param string $defaultEventType + * @return TrackEDefault + */ + public function setDefaultEventType($defaultEventType) + { + $this->defaultEventType = $defaultEventType; + + return $this; + } + + /** + * Get defaultEventType + * + * @return string + */ + public function getDefaultEventType() + { + return $this->defaultEventType; + } + + /** + * Set defaultValueType + * + * @param string $defaultValueType + * @return TrackEDefault + */ + public function setDefaultValueType($defaultValueType) + { + $this->defaultValueType = $defaultValueType; + + return $this; + } + + /** + * Get defaultValueType + * + * @return string + */ + public function getDefaultValueType() + { + return $this->defaultValueType; + } + + /** + * Set defaultValue + * + * @param string $defaultValue + * @return TrackEDefault + */ + public function setDefaultValue($defaultValue) + { + $this->defaultValue = $defaultValue; + + return $this; + } + + /** + * Get defaultValue + * + * @return string + */ + public function getDefaultValue() + { + return $this->defaultValue; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return TrackEDefault + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Get defaultId + * + * @return integer + */ + public function getDefaultId() + { + return $this->defaultId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackEDownloads.php b/src/Chamilo/CoreBundle/Entity/TrackEDownloads.php new file mode 100644 index 0000000000..ce151df67f --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackEDownloads.php @@ -0,0 +1,185 @@ +downUserId = $downUserId; + + return $this; + } + + /** + * Get downUserId + * + * @return integer + */ + public function getDownUserId() + { + return $this->downUserId; + } + + /** + * Set downDate + * + * @param \DateTime $downDate + * @return TrackEDownloads + */ + public function setDownDate($downDate) + { + $this->downDate = $downDate; + + return $this; + } + + /** + * Get downDate + * + * @return \DateTime + */ + public function getDownDate() + { + return $this->downDate; + } + + /** + * Set cId + * + * @param integer $cId + * @return TrackEDownloads + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set downDocPath + * + * @param string $downDocPath + * @return TrackEDownloads + */ + public function setDownDocPath($downDocPath) + { + $this->downDocPath = $downDocPath; + + return $this; + } + + /** + * Get downDocPath + * + * @return string + */ + public function getDownDocPath() + { + return $this->downDocPath; + } + + /** + * Set downSessionId + * + * @param integer $downSessionId + * @return TrackEDownloads + */ + public function setDownSessionId($downSessionId) + { + $this->downSessionId = $downSessionId; + + return $this; + } + + /** + * Get downSessionId + * + * @return integer + */ + public function getDownSessionId() + { + return $this->downSessionId; + } + + /** + * Get downId + * + * @return integer + */ + public function getDownId() + { + return $this->downId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackEExercises.php b/src/Chamilo/CoreBundle/Entity/TrackEExercises.php new file mode 100644 index 0000000000..13067f6a3f --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackEExercises.php @@ -0,0 +1,575 @@ +exeUserId = $exeUserId; + + return $this; + } + + /** + * Get exeUserId + * + * @return integer + */ + public function getExeUserId() + { + return $this->exeUserId; + } + + /** + * Set exeDate + * + * @param \DateTime $exeDate + * @return TrackEExercises + */ + public function setExeDate($exeDate) + { + $this->exeDate = $exeDate; + + return $this; + } + + /** + * Get exeDate + * + * @return \DateTime + */ + public function getExeDate() + { + return $this->exeDate; + } + + /** + * Set cId + * + * @param integer $cId + * @return TrackEExercises + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set exeExoId + * + * @param integer $exeExoId + * @return TrackEExercises + */ + public function setExeExoId($exeExoId) + { + $this->exeExoId = $exeExoId; + + return $this; + } + + /** + * Get exeExoId + * + * @return integer + */ + public function getExeExoId() + { + return $this->exeExoId; + } + + /** + * Set exeResult + * + * @param float $exeResult + * @return TrackEExercises + */ + public function setExeResult($exeResult) + { + $this->exeResult = $exeResult; + + return $this; + } + + /** + * Get exeResult + * + * @return float + */ + public function getExeResult() + { + return $this->exeResult; + } + + /** + * Set exeWeighting + * + * @param float $exeWeighting + * @return TrackEExercises + */ + public function setExeWeighting($exeWeighting) + { + $this->exeWeighting = $exeWeighting; + + return $this; + } + + /** + * Get exeWeighting + * + * @return float + */ + public function getExeWeighting() + { + return $this->exeWeighting; + } + + /** + * Set userIp + * + * @param string $userIp + * @return TrackEExercises + */ + public function setUserIp($userIp) + { + $this->userIp = $userIp; + + return $this; + } + + /** + * Get userIp + * + * @return string + */ + public function getUserIp() + { + return $this->userIp; + } + + /** + * Set status + * + * @param string $status + * @return TrackEExercises + */ + public function setStatus($status) + { + $this->status = $status; + + return $this; + } + + /** + * Get status + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set dataTracking + * + * @param string $dataTracking + * @return TrackEExercises + */ + public function setDataTracking($dataTracking) + { + $this->dataTracking = $dataTracking; + + return $this; + } + + /** + * Get dataTracking + * + * @return string + */ + public function getDataTracking() + { + return $this->dataTracking; + } + + /** + * Set startDate + * + * @param \DateTime $startDate + * @return TrackEExercises + */ + public function setStartDate($startDate) + { + $this->startDate = $startDate; + + return $this; + } + + /** + * Get startDate + * + * @return \DateTime + */ + public function getStartDate() + { + return $this->startDate; + } + + /** + * Set stepsCounter + * + * @param integer $stepsCounter + * @return TrackEExercises + */ + public function setStepsCounter($stepsCounter) + { + $this->stepsCounter = $stepsCounter; + + return $this; + } + + /** + * Get stepsCounter + * + * @return integer + */ + public function getStepsCounter() + { + return $this->stepsCounter; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return TrackEExercises + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set origLpId + * + * @param integer $origLpId + * @return TrackEExercises + */ + public function setOrigLpId($origLpId) + { + $this->origLpId = $origLpId; + + return $this; + } + + /** + * Get origLpId + * + * @return integer + */ + public function getOrigLpId() + { + return $this->origLpId; + } + + /** + * Set origLpItemId + * + * @param integer $origLpItemId + * @return TrackEExercises + */ + public function setOrigLpItemId($origLpItemId) + { + $this->origLpItemId = $origLpItemId; + + return $this; + } + + /** + * Get origLpItemId + * + * @return integer + */ + public function getOrigLpItemId() + { + return $this->origLpItemId; + } + + /** + * Set exeDuration + * + * @param integer $exeDuration + * @return TrackEExercises + */ + public function setExeDuration($exeDuration) + { + $this->exeDuration = $exeDuration; + + return $this; + } + + /** + * Get exeDuration + * + * @return integer + */ + public function getExeDuration() + { + return $this->exeDuration; + } + + /** + * Set expiredTimeControl + * + * @param \DateTime $expiredTimeControl + * @return TrackEExercises + */ + public function setExpiredTimeControl($expiredTimeControl) + { + $this->expiredTimeControl = $expiredTimeControl; + + return $this; + } + + /** + * Get expiredTimeControl + * + * @return \DateTime + */ + public function getExpiredTimeControl() + { + return $this->expiredTimeControl; + } + + /** + * Set origLpItemViewId + * + * @param integer $origLpItemViewId + * @return TrackEExercises + */ + public function setOrigLpItemViewId($origLpItemViewId) + { + $this->origLpItemViewId = $origLpItemViewId; + + return $this; + } + + /** + * Get origLpItemViewId + * + * @return integer + */ + public function getOrigLpItemViewId() + { + return $this->origLpItemViewId; + } + + /** + * Set questionsToCheck + * + * @param string $questionsToCheck + * @return TrackEExercises + */ + public function setQuestionsToCheck($questionsToCheck) + { + $this->questionsToCheck = $questionsToCheck; + + return $this; + } + + /** + * Get questionsToCheck + * + * @return string + */ + public function getQuestionsToCheck() + { + return $this->questionsToCheck; + } + + /** + * Get exeId + * + * @return integer + */ + public function getExeId() + { + return $this->exeId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackEHotpotatoes.php b/src/Chamilo/CoreBundle/Entity/TrackEHotpotatoes.php new file mode 100644 index 0000000000..081d4a97a2 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackEHotpotatoes.php @@ -0,0 +1,215 @@ +exeName = $exeName; + + return $this; + } + + /** + * Get exeName + * + * @return string + */ + public function getExeName() + { + return $this->exeName; + } + + /** + * Set exeUserId + * + * @param integer $exeUserId + * @return TrackEHotpotatoes + */ + public function setExeUserId($exeUserId) + { + $this->exeUserId = $exeUserId; + + return $this; + } + + /** + * Get exeUserId + * + * @return integer + */ + public function getExeUserId() + { + return $this->exeUserId; + } + + /** + * Set exeDate + * + * @param \DateTime $exeDate + * @return TrackEHotpotatoes + */ + public function setExeDate($exeDate) + { + $this->exeDate = $exeDate; + + return $this; + } + + /** + * Get exeDate + * + * @return \DateTime + */ + public function getExeDate() + { + return $this->exeDate; + } + + /** + * Set cId + * + * @param integer $cId + * @return TrackEHotpotatoes + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set exeResult + * + * @param integer $exeResult + * @return TrackEHotpotatoes + */ + public function setExeResult($exeResult) + { + $this->exeResult = $exeResult; + + return $this; + } + + /** + * Get exeResult + * + * @return integer + */ + public function getExeResult() + { + return $this->exeResult; + } + + /** + * Set exeWeighting + * + * @param integer $exeWeighting + * @return TrackEHotpotatoes + */ + public function setExeWeighting($exeWeighting) + { + $this->exeWeighting = $exeWeighting; + + return $this; + } + + /** + * Get exeWeighting + * + * @return integer + */ + public function getExeWeighting() + { + return $this->exeWeighting; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackEHotspot.php b/src/Chamilo/CoreBundle/Entity/TrackEHotspot.php new file mode 100644 index 0000000000..02d0a6c698 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackEHotspot.php @@ -0,0 +1,275 @@ +hotspotUserId = $hotspotUserId; + + return $this; + } + + /** + * Get hotspotUserId + * + * @return integer + */ + public function getHotspotUserId() + { + return $this->hotspotUserId; + } + + /** + * Set hotspotCourseCode + * + * @param string $hotspotCourseCode + * @return TrackEHotspot + */ + public function setHotspotCourseCode($hotspotCourseCode) + { + $this->hotspotCourseCode = $hotspotCourseCode; + + return $this; + } + + /** + * Get hotspotCourseCode + * + * @return string + */ + public function getHotspotCourseCode() + { + return $this->hotspotCourseCode; + } + + /** + * Set cId + * + * @param integer $cId + * @return TrackEHotspot + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set hotspotExeId + * + * @param integer $hotspotExeId + * @return TrackEHotspot + */ + public function setHotspotExeId($hotspotExeId) + { + $this->hotspotExeId = $hotspotExeId; + + return $this; + } + + /** + * Get hotspotExeId + * + * @return integer + */ + public function getHotspotExeId() + { + return $this->hotspotExeId; + } + + /** + * Set hotspotQuestionId + * + * @param integer $hotspotQuestionId + * @return TrackEHotspot + */ + public function setHotspotQuestionId($hotspotQuestionId) + { + $this->hotspotQuestionId = $hotspotQuestionId; + + return $this; + } + + /** + * Get hotspotQuestionId + * + * @return integer + */ + public function getHotspotQuestionId() + { + return $this->hotspotQuestionId; + } + + /** + * Set hotspotAnswerId + * + * @param integer $hotspotAnswerId + * @return TrackEHotspot + */ + public function setHotspotAnswerId($hotspotAnswerId) + { + $this->hotspotAnswerId = $hotspotAnswerId; + + return $this; + } + + /** + * Get hotspotAnswerId + * + * @return integer + */ + public function getHotspotAnswerId() + { + return $this->hotspotAnswerId; + } + + /** + * Set hotspotCorrect + * + * @param boolean $hotspotCorrect + * @return TrackEHotspot + */ + public function setHotspotCorrect($hotspotCorrect) + { + $this->hotspotCorrect = $hotspotCorrect; + + return $this; + } + + /** + * Get hotspotCorrect + * + * @return boolean + */ + public function getHotspotCorrect() + { + return $this->hotspotCorrect; + } + + /** + * Set hotspotCoordinate + * + * @param string $hotspotCoordinate + * @return TrackEHotspot + */ + public function setHotspotCoordinate($hotspotCoordinate) + { + $this->hotspotCoordinate = $hotspotCoordinate; + + return $this; + } + + /** + * Get hotspotCoordinate + * + * @return string + */ + public function getHotspotCoordinate() + { + return $this->hotspotCoordinate; + } + + /** + * Get hotspotId + * + * @return integer + */ + public function getHotspotId() + { + return $this->hotspotId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackEItemProperty.php b/src/Chamilo/CoreBundle/Entity/TrackEItemProperty.php new file mode 100644 index 0000000000..e378bd8682 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackEItemProperty.php @@ -0,0 +1,275 @@ +courseId = $courseId; + + return $this; + } + + /** + * Get courseId + * + * @return integer + */ + public function getCourseId() + { + return $this->courseId; + } + + /** + * Set itemPropertyId + * + * @param integer $itemPropertyId + * @return TrackEItemProperty + */ + public function setItemPropertyId($itemPropertyId) + { + $this->itemPropertyId = $itemPropertyId; + + return $this; + } + + /** + * Get itemPropertyId + * + * @return integer + */ + public function getItemPropertyId() + { + return $this->itemPropertyId; + } + + /** + * Set title + * + * @param string $title + * @return TrackEItemProperty + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set content + * + * @param string $content + * @return TrackEItemProperty + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Set progress + * + * @param integer $progress + * @return TrackEItemProperty + */ + public function setProgress($progress) + { + $this->progress = $progress; + + return $this; + } + + /** + * Get progress + * + * @return integer + */ + public function getProgress() + { + return $this->progress; + } + + /** + * Set lasteditDate + * + * @param \DateTime $lasteditDate + * @return TrackEItemProperty + */ + public function setLasteditDate($lasteditDate) + { + $this->lasteditDate = $lasteditDate; + + return $this; + } + + /** + * Get lasteditDate + * + * @return \DateTime + */ + public function getLasteditDate() + { + return $this->lasteditDate; + } + + /** + * Set lasteditUserId + * + * @param integer $lasteditUserId + * @return TrackEItemProperty + */ + public function setLasteditUserId($lasteditUserId) + { + $this->lasteditUserId = $lasteditUserId; + + return $this; + } + + /** + * Get lasteditUserId + * + * @return integer + */ + public function getLasteditUserId() + { + return $this->lasteditUserId; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return TrackEItemProperty + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackELastaccess.php b/src/Chamilo/CoreBundle/Entity/TrackELastaccess.php new file mode 100644 index 0000000000..d4be8cd5e0 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackELastaccess.php @@ -0,0 +1,185 @@ +accessUserId = $accessUserId; + + return $this; + } + + /** + * Get accessUserId + * + * @return integer + */ + public function getAccessUserId() + { + return $this->accessUserId; + } + + /** + * Set accessDate + * + * @param \DateTime $accessDate + * @return TrackELastaccess + */ + public function setAccessDate($accessDate) + { + $this->accessDate = $accessDate; + + return $this; + } + + /** + * Get accessDate + * + * @return \DateTime + */ + public function getAccessDate() + { + return $this->accessDate; + } + + /** + * Set cId + * + * @param integer $cId + * @return TrackELastaccess + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set accessTool + * + * @param string $accessTool + * @return TrackELastaccess + */ + public function setAccessTool($accessTool) + { + $this->accessTool = $accessTool; + + return $this; + } + + /** + * Get accessTool + * + * @return string + */ + public function getAccessTool() + { + return $this->accessTool; + } + + /** + * Set accessSessionId + * + * @param integer $accessSessionId + * @return TrackELastaccess + */ + public function setAccessSessionId($accessSessionId) + { + $this->accessSessionId = $accessSessionId; + + return $this; + } + + /** + * Get accessSessionId + * + * @return integer + */ + public function getAccessSessionId() + { + return $this->accessSessionId; + } + + /** + * Get accessId + * + * @return integer + */ + public function getAccessId() + { + return $this->accessId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackELinks.php b/src/Chamilo/CoreBundle/Entity/TrackELinks.php new file mode 100644 index 0000000000..ed6a1086ad --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackELinks.php @@ -0,0 +1,185 @@ +linksUserId = $linksUserId; + + return $this; + } + + /** + * Get linksUserId + * + * @return integer + */ + public function getLinksUserId() + { + return $this->linksUserId; + } + + /** + * Set linksDate + * + * @param \DateTime $linksDate + * @return TrackELinks + */ + public function setLinksDate($linksDate) + { + $this->linksDate = $linksDate; + + return $this; + } + + /** + * Get linksDate + * + * @return \DateTime + */ + public function getLinksDate() + { + return $this->linksDate; + } + + /** + * Set cId + * + * @param integer $cId + * @return TrackELinks + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set linksLinkId + * + * @param integer $linksLinkId + * @return TrackELinks + */ + public function setLinksLinkId($linksLinkId) + { + $this->linksLinkId = $linksLinkId; + + return $this; + } + + /** + * Get linksLinkId + * + * @return integer + */ + public function getLinksLinkId() + { + return $this->linksLinkId; + } + + /** + * Set linksSessionId + * + * @param integer $linksSessionId + * @return TrackELinks + */ + public function setLinksSessionId($linksSessionId) + { + $this->linksSessionId = $linksSessionId; + + return $this; + } + + /** + * Get linksSessionId + * + * @return integer + */ + public function getLinksSessionId() + { + return $this->linksSessionId; + } + + /** + * Get linksId + * + * @return integer + */ + public function getLinksId() + { + return $this->linksId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackELogin.php b/src/Chamilo/CoreBundle/Entity/TrackELogin.php new file mode 100644 index 0000000000..82053c0f46 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackELogin.php @@ -0,0 +1,155 @@ +loginUserId = $loginUserId; + + return $this; + } + + /** + * Get loginUserId + * + * @return integer + */ + public function getLoginUserId() + { + return $this->loginUserId; + } + + /** + * Set loginDate + * + * @param \DateTime $loginDate + * @return TrackELogin + */ + public function setLoginDate($loginDate) + { + $this->loginDate = $loginDate; + + return $this; + } + + /** + * Get loginDate + * + * @return \DateTime + */ + public function getLoginDate() + { + return $this->loginDate; + } + + /** + * Set userIp + * + * @param string $userIp + * @return TrackELogin + */ + public function setUserIp($userIp) + { + $this->userIp = $userIp; + + return $this; + } + + /** + * Get userIp + * + * @return string + */ + public function getUserIp() + { + return $this->userIp; + } + + /** + * Set logoutDate + * + * @param \DateTime $logoutDate + * @return TrackELogin + */ + public function setLogoutDate($logoutDate) + { + $this->logoutDate = $logoutDate; + + return $this; + } + + /** + * Get logoutDate + * + * @return \DateTime + */ + public function getLogoutDate() + { + return $this->logoutDate; + } + + /** + * Get loginId + * + * @return integer + */ + public function getLoginId() + { + return $this->loginId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackEOnline.php b/src/Chamilo/CoreBundle/Entity/TrackEOnline.php new file mode 100644 index 0000000000..3d9a767ee5 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackEOnline.php @@ -0,0 +1,215 @@ +loginUserId = $loginUserId; + + return $this; + } + + /** + * Get loginUserId + * + * @return integer + */ + public function getLoginUserId() + { + return $this->loginUserId; + } + + /** + * Set loginDate + * + * @param \DateTime $loginDate + * @return TrackEOnline + */ + public function setLoginDate($loginDate) + { + $this->loginDate = $loginDate; + + return $this; + } + + /** + * Get loginDate + * + * @return \DateTime + */ + public function getLoginDate() + { + return $this->loginDate; + } + + /** + * Set userIp + * + * @param string $userIp + * @return TrackEOnline + */ + public function setUserIp($userIp) + { + $this->userIp = $userIp; + + return $this; + } + + /** + * Get userIp + * + * @return string + */ + public function getUserIp() + { + return $this->userIp; + } + + /** + * Set cId + * + * @param integer $cId + * @return TrackEOnline + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return TrackEOnline + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set accessUrlId + * + * @param integer $accessUrlId + * @return TrackEOnline + */ + public function setAccessUrlId($accessUrlId) + { + $this->accessUrlId = $accessUrlId; + + return $this; + } + + /** + * Get accessUrlId + * + * @return integer + */ + public function getAccessUrlId() + { + return $this->accessUrlId; + } + + /** + * Get loginId + * + * @return integer + */ + public function getLoginId() + { + return $this->loginId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackEOpen.php b/src/Chamilo/CoreBundle/Entity/TrackEOpen.php new file mode 100644 index 0000000000..c863a5e799 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackEOpen.php @@ -0,0 +1,155 @@ +openRemoteHost = $openRemoteHost; + + return $this; + } + + /** + * Get openRemoteHost + * + * @return string + */ + public function getOpenRemoteHost() + { + return $this->openRemoteHost; + } + + /** + * Set openAgent + * + * @param string $openAgent + * @return TrackEOpen + */ + public function setOpenAgent($openAgent) + { + $this->openAgent = $openAgent; + + return $this; + } + + /** + * Get openAgent + * + * @return string + */ + public function getOpenAgent() + { + return $this->openAgent; + } + + /** + * Set openReferer + * + * @param string $openReferer + * @return TrackEOpen + */ + public function setOpenReferer($openReferer) + { + $this->openReferer = $openReferer; + + return $this; + } + + /** + * Get openReferer + * + * @return string + */ + public function getOpenReferer() + { + return $this->openReferer; + } + + /** + * Set openDate + * + * @param \DateTime $openDate + * @return TrackEOpen + */ + public function setOpenDate($openDate) + { + $this->openDate = $openDate; + + return $this; + } + + /** + * Get openDate + * + * @return \DateTime + */ + public function getOpenDate() + { + return $this->openDate; + } + + /** + * Get openId + * + * @return integer + */ + public function getOpenId() + { + return $this->openId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackEUploads.php b/src/Chamilo/CoreBundle/Entity/TrackEUploads.php new file mode 100644 index 0000000000..572f9b96bc --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackEUploads.php @@ -0,0 +1,215 @@ +uploadUserId = $uploadUserId; + + return $this; + } + + /** + * Get uploadUserId + * + * @return integer + */ + public function getUploadUserId() + { + return $this->uploadUserId; + } + + /** + * Set uploadDate + * + * @param \DateTime $uploadDate + * @return TrackEUploads + */ + public function setUploadDate($uploadDate) + { + $this->uploadDate = $uploadDate; + + return $this; + } + + /** + * Get uploadDate + * + * @return \DateTime + */ + public function getUploadDate() + { + return $this->uploadDate; + } + + /** + * Set uploadCoursId + * + * @param string $uploadCoursId + * @return TrackEUploads + */ + public function setUploadCoursId($uploadCoursId) + { + $this->uploadCoursId = $uploadCoursId; + + return $this; + } + + /** + * Get uploadCoursId + * + * @return string + */ + public function getUploadCoursId() + { + return $this->uploadCoursId; + } + + /** + * Set cId + * + * @param integer $cId + * @return TrackEUploads + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set uploadWorkId + * + * @param integer $uploadWorkId + * @return TrackEUploads + */ + public function setUploadWorkId($uploadWorkId) + { + $this->uploadWorkId = $uploadWorkId; + + return $this; + } + + /** + * Get uploadWorkId + * + * @return integer + */ + public function getUploadWorkId() + { + return $this->uploadWorkId; + } + + /** + * Set uploadSessionId + * + * @param integer $uploadSessionId + * @return TrackEUploads + */ + public function setUploadSessionId($uploadSessionId) + { + $this->uploadSessionId = $uploadSessionId; + + return $this; + } + + /** + * Get uploadSessionId + * + * @return integer + */ + public function getUploadSessionId() + { + return $this->uploadSessionId; + } + + /** + * Get uploadId + * + * @return integer + */ + public function getUploadId() + { + return $this->uploadId; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackStoredValues.php b/src/Chamilo/CoreBundle/Entity/TrackStoredValues.php new file mode 100644 index 0000000000..4a36748671 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackStoredValues.php @@ -0,0 +1,185 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set scoId + * + * @param integer $scoId + * @return TrackStoredValues + */ + public function setScoId($scoId) + { + $this->scoId = $scoId; + + return $this; + } + + /** + * Get scoId + * + * @return integer + */ + public function getScoId() + { + return $this->scoId; + } + + /** + * Set courseId + * + * @param string $courseId + * @return TrackStoredValues + */ + public function setCourseId($courseId) + { + $this->courseId = $courseId; + + return $this; + } + + /** + * Get courseId + * + * @return string + */ + public function getCourseId() + { + return $this->courseId; + } + + /** + * Set svKey + * + * @param string $svKey + * @return TrackStoredValues + */ + public function setSvKey($svKey) + { + $this->svKey = $svKey; + + return $this; + } + + /** + * Get svKey + * + * @return string + */ + public function getSvKey() + { + return $this->svKey; + } + + /** + * Set svValue + * + * @param string $svValue + * @return TrackStoredValues + */ + public function setSvValue($svValue) + { + $this->svValue = $svValue; + + return $this; + } + + /** + * Get svValue + * + * @return string + */ + public function getSvValue() + { + return $this->svValue; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/TrackStoredValuesStack.php b/src/Chamilo/CoreBundle/Entity/TrackStoredValuesStack.php new file mode 100644 index 0000000000..2c952cbb52 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/TrackStoredValuesStack.php @@ -0,0 +1,215 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set scoId + * + * @param integer $scoId + * @return TrackStoredValuesStack + */ + public function setScoId($scoId) + { + $this->scoId = $scoId; + + return $this; + } + + /** + * Get scoId + * + * @return integer + */ + public function getScoId() + { + return $this->scoId; + } + + /** + * Set stackOrder + * + * @param integer $stackOrder + * @return TrackStoredValuesStack + */ + public function setStackOrder($stackOrder) + { + $this->stackOrder = $stackOrder; + + return $this; + } + + /** + * Get stackOrder + * + * @return integer + */ + public function getStackOrder() + { + return $this->stackOrder; + } + + /** + * Set courseId + * + * @param string $courseId + * @return TrackStoredValuesStack + */ + public function setCourseId($courseId) + { + $this->courseId = $courseId; + + return $this; + } + + /** + * Get courseId + * + * @return string + */ + public function getCourseId() + { + return $this->courseId; + } + + /** + * Set svKey + * + * @param string $svKey + * @return TrackStoredValuesStack + */ + public function setSvKey($svKey) + { + $this->svKey = $svKey; + + return $this; + } + + /** + * Get svKey + * + * @return string + */ + public function getSvKey() + { + return $this->svKey; + } + + /** + * Set svValue + * + * @param string $svValue + * @return TrackStoredValuesStack + */ + public function setSvValue($svValue) + { + $this->svValue = $svValue; + + return $this; + } + + /** + * Get svValue + * + * @return string + */ + public function getSvValue() + { + return $this->svValue; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/UserApiKey.php b/src/Chamilo/CoreBundle/Entity/UserApiKey.php new file mode 100644 index 0000000000..3d0360eb03 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/UserApiKey.php @@ -0,0 +1,275 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set apiKey + * + * @param string $apiKey + * @return UserApiKey + */ + public function setApiKey($apiKey) + { + $this->apiKey = $apiKey; + + return $this; + } + + /** + * Get apiKey + * + * @return string + */ + public function getApiKey() + { + return $this->apiKey; + } + + /** + * Set apiService + * + * @param string $apiService + * @return UserApiKey + */ + public function setApiService($apiService) + { + $this->apiService = $apiService; + + return $this; + } + + /** + * Get apiService + * + * @return string + */ + public function getApiService() + { + return $this->apiService; + } + + /** + * Set apiEndPoint + * + * @param string $apiEndPoint + * @return UserApiKey + */ + public function setApiEndPoint($apiEndPoint) + { + $this->apiEndPoint = $apiEndPoint; + + return $this; + } + + /** + * Get apiEndPoint + * + * @return string + */ + public function getApiEndPoint() + { + return $this->apiEndPoint; + } + + /** + * Set createdDate + * + * @param \DateTime $createdDate + * @return UserApiKey + */ + public function setCreatedDate($createdDate) + { + $this->createdDate = $createdDate; + + return $this; + } + + /** + * Get createdDate + * + * @return \DateTime + */ + public function getCreatedDate() + { + return $this->createdDate; + } + + /** + * Set validityStartDate + * + * @param \DateTime $validityStartDate + * @return UserApiKey + */ + public function setValidityStartDate($validityStartDate) + { + $this->validityStartDate = $validityStartDate; + + return $this; + } + + /** + * Get validityStartDate + * + * @return \DateTime + */ + public function getValidityStartDate() + { + return $this->validityStartDate; + } + + /** + * Set validityEndDate + * + * @param \DateTime $validityEndDate + * @return UserApiKey + */ + public function setValidityEndDate($validityEndDate) + { + $this->validityEndDate = $validityEndDate; + + return $this; + } + + /** + * Get validityEndDate + * + * @return \DateTime + */ + public function getValidityEndDate() + { + return $this->validityEndDate; + } + + /** + * Set description + * + * @param string $description + * @return UserApiKey + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/UserCourseCategory.php b/src/Chamilo/CoreBundle/Entity/UserCourseCategory.php new file mode 100644 index 0000000000..ec390f8877 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/UserCourseCategory.php @@ -0,0 +1,125 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set title + * + * @param string $title + * @return UserCourseCategory + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set sort + * + * @param integer $sort + * @return UserCourseCategory + */ + public function setSort($sort) + { + $this->sort = $sort; + + return $this; + } + + /** + * Get sort + * + * @return integer + */ + public function getSort() + { + return $this->sort; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/UserField.php b/src/Chamilo/CoreBundle/Entity/UserField.php new file mode 100644 index 0000000000..c8cafb4a1d --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/UserField.php @@ -0,0 +1,305 @@ +fieldType = $fieldType; + + return $this; + } + + /** + * Get fieldType + * + * @return integer + */ + public function getFieldType() + { + return $this->fieldType; + } + + /** + * Set fieldVariable + * + * @param string $fieldVariable + * @return UserField + */ + public function setFieldVariable($fieldVariable) + { + $this->fieldVariable = $fieldVariable; + + return $this; + } + + /** + * Get fieldVariable + * + * @return string + */ + public function getFieldVariable() + { + return $this->fieldVariable; + } + + /** + * Set fieldDisplayText + * + * @param string $fieldDisplayText + * @return UserField + */ + public function setFieldDisplayText($fieldDisplayText) + { + $this->fieldDisplayText = $fieldDisplayText; + + return $this; + } + + /** + * Get fieldDisplayText + * + * @return string + */ + public function getFieldDisplayText() + { + return $this->fieldDisplayText; + } + + /** + * Set fieldDefaultValue + * + * @param string $fieldDefaultValue + * @return UserField + */ + public function setFieldDefaultValue($fieldDefaultValue) + { + $this->fieldDefaultValue = $fieldDefaultValue; + + return $this; + } + + /** + * Get fieldDefaultValue + * + * @return string + */ + public function getFieldDefaultValue() + { + return $this->fieldDefaultValue; + } + + /** + * Set fieldOrder + * + * @param integer $fieldOrder + * @return UserField + */ + public function setFieldOrder($fieldOrder) + { + $this->fieldOrder = $fieldOrder; + + return $this; + } + + /** + * Get fieldOrder + * + * @return integer + */ + public function getFieldOrder() + { + return $this->fieldOrder; + } + + /** + * Set fieldVisible + * + * @param boolean $fieldVisible + * @return UserField + */ + public function setFieldVisible($fieldVisible) + { + $this->fieldVisible = $fieldVisible; + + return $this; + } + + /** + * Get fieldVisible + * + * @return boolean + */ + public function getFieldVisible() + { + return $this->fieldVisible; + } + + /** + * Set fieldChangeable + * + * @param boolean $fieldChangeable + * @return UserField + */ + public function setFieldChangeable($fieldChangeable) + { + $this->fieldChangeable = $fieldChangeable; + + return $this; + } + + /** + * Get fieldChangeable + * + * @return boolean + */ + public function getFieldChangeable() + { + return $this->fieldChangeable; + } + + /** + * Set fieldFilter + * + * @param boolean $fieldFilter + * @return UserField + */ + public function setFieldFilter($fieldFilter) + { + $this->fieldFilter = $fieldFilter; + + return $this; + } + + /** + * Get fieldFilter + * + * @return boolean + */ + public function getFieldFilter() + { + return $this->fieldFilter; + } + + /** + * Set tms + * + * @param \DateTime $tms + * @return UserField + */ + public function setTms($tms) + { + $this->tms = $tms; + + return $this; + } + + /** + * Get tms + * + * @return \DateTime + */ + public function getTms() + { + return $this->tms; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/UserFieldOptions.php b/src/Chamilo/CoreBundle/Entity/UserFieldOptions.php new file mode 100644 index 0000000000..cc3642bb3c --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/UserFieldOptions.php @@ -0,0 +1,185 @@ +fieldId = $fieldId; + + return $this; + } + + /** + * Get fieldId + * + * @return integer + */ + public function getFieldId() + { + return $this->fieldId; + } + + /** + * Set optionValue + * + * @param string $optionValue + * @return UserFieldOptions + */ + public function setOptionValue($optionValue) + { + $this->optionValue = $optionValue; + + return $this; + } + + /** + * Get optionValue + * + * @return string + */ + public function getOptionValue() + { + return $this->optionValue; + } + + /** + * Set optionDisplayText + * + * @param string $optionDisplayText + * @return UserFieldOptions + */ + public function setOptionDisplayText($optionDisplayText) + { + $this->optionDisplayText = $optionDisplayText; + + return $this; + } + + /** + * Get optionDisplayText + * + * @return string + */ + public function getOptionDisplayText() + { + return $this->optionDisplayText; + } + + /** + * Set optionOrder + * + * @param integer $optionOrder + * @return UserFieldOptions + */ + public function setOptionOrder($optionOrder) + { + $this->optionOrder = $optionOrder; + + return $this; + } + + /** + * Get optionOrder + * + * @return integer + */ + public function getOptionOrder() + { + return $this->optionOrder; + } + + /** + * Set tms + * + * @param \DateTime $tms + * @return UserFieldOptions + */ + public function setTms($tms) + { + $this->tms = $tms; + + return $this; + } + + /** + * Get tms + * + * @return \DateTime + */ + public function getTms() + { + return $this->tms; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/UserFieldValues.php b/src/Chamilo/CoreBundle/Entity/UserFieldValues.php new file mode 100644 index 0000000000..57d135cc57 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/UserFieldValues.php @@ -0,0 +1,155 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set fieldId + * + * @param integer $fieldId + * @return UserFieldValues + */ + public function setFieldId($fieldId) + { + $this->fieldId = $fieldId; + + return $this; + } + + /** + * Get fieldId + * + * @return integer + */ + public function getFieldId() + { + return $this->fieldId; + } + + /** + * Set fieldValue + * + * @param string $fieldValue + * @return UserFieldValues + */ + public function setFieldValue($fieldValue) + { + $this->fieldValue = $fieldValue; + + return $this; + } + + /** + * Get fieldValue + * + * @return string + */ + public function getFieldValue() + { + return $this->fieldValue; + } + + /** + * Set tms + * + * @param \DateTime $tms + * @return UserFieldValues + */ + public function setTms($tms) + { + $this->tms = $tms; + + return $this; + } + + /** + * Get tms + * + * @return \DateTime + */ + public function getTms() + { + return $this->tms; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/UserFriendRelationType.php b/src/Chamilo/CoreBundle/Entity/UserFriendRelationType.php new file mode 100644 index 0000000000..17ebf0cd36 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/UserFriendRelationType.php @@ -0,0 +1,65 @@ +title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/UserRelCourseVote.php b/src/Chamilo/CoreBundle/Entity/UserRelCourseVote.php new file mode 100644 index 0000000000..4b96b92896 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/UserRelCourseVote.php @@ -0,0 +1,185 @@ +cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set userId + * + * @param integer $userId + * @return UserRelCourseVote + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return UserRelCourseVote + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set urlId + * + * @param integer $urlId + * @return UserRelCourseVote + */ + public function setUrlId($urlId) + { + $this->urlId = $urlId; + + return $this; + } + + /** + * Get urlId + * + * @return integer + */ + public function getUrlId() + { + return $this->urlId; + } + + /** + * Set vote + * + * @param integer $vote + * @return UserRelCourseVote + */ + public function setVote($vote) + { + $this->vote = $vote; + + return $this; + } + + /** + * Get vote + * + * @return integer + */ + public function getVote() + { + return $this->vote; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/UserRelEventType.php b/src/Chamilo/CoreBundle/Entity/UserRelEventType.php new file mode 100644 index 0000000000..d473437103 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/UserRelEventType.php @@ -0,0 +1,95 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set eventTypeName + * + * @param string $eventTypeName + * @return UserRelEventType + */ + public function setEventTypeName($eventTypeName) + { + $this->eventTypeName = $eventTypeName; + + return $this; + } + + /** + * Get eventTypeName + * + * @return string + */ + public function getEventTypeName() + { + return $this->eventTypeName; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/UserRelTag.php b/src/Chamilo/CoreBundle/Entity/UserRelTag.php new file mode 100644 index 0000000000..3effff4c32 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/UserRelTag.php @@ -0,0 +1,95 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set tagId + * + * @param integer $tagId + * @return UserRelTag + */ + public function setTagId($tagId) + { + $this->tagId = $tagId; + + return $this; + } + + /** + * Get tagId + * + * @return integer + */ + public function getTagId() + { + return $this->tagId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/UserRelUser.php b/src/Chamilo/CoreBundle/Entity/UserRelUser.php new file mode 100644 index 0000000000..0858c10d63 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/UserRelUser.php @@ -0,0 +1,155 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set friendUserId + * + * @param integer $friendUserId + * @return UserRelUser + */ + public function setFriendUserId($friendUserId) + { + $this->friendUserId = $friendUserId; + + return $this; + } + + /** + * Get friendUserId + * + * @return integer + */ + public function getFriendUserId() + { + return $this->friendUserId; + } + + /** + * Set relationType + * + * @param integer $relationType + * @return UserRelUser + */ + public function setRelationType($relationType) + { + $this->relationType = $relationType; + + return $this; + } + + /** + * Get relationType + * + * @return integer + */ + public function getRelationType() + { + return $this->relationType; + } + + /** + * Set lastEdit + * + * @param \DateTime $lastEdit + * @return UserRelUser + */ + public function setLastEdit($lastEdit) + { + $this->lastEdit = $lastEdit; + + return $this; + } + + /** + * Get lastEdit + * + * @return \DateTime + */ + public function getLastEdit() + { + return $this->lastEdit; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/UsergroupRelCourse.php b/src/Chamilo/CoreBundle/Entity/UsergroupRelCourse.php new file mode 100644 index 0000000000..f6ce1b0886 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/UsergroupRelCourse.php @@ -0,0 +1,95 @@ +usergroupId = $usergroupId; + + return $this; + } + + /** + * Get usergroupId + * + * @return integer + */ + public function getUsergroupId() + { + return $this->usergroupId; + } + + /** + * Set courseId + * + * @param integer $courseId + * @return UsergroupRelCourse + */ + public function setCourseId($courseId) + { + $this->courseId = $courseId; + + return $this; + } + + /** + * Get courseId + * + * @return integer + */ + public function getCourseId() + { + return $this->courseId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/UsergroupRelQuestion.php b/src/Chamilo/CoreBundle/Entity/UsergroupRelQuestion.php new file mode 100644 index 0000000000..d144db3f94 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/UsergroupRelQuestion.php @@ -0,0 +1,155 @@ +cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set questionId + * + * @param integer $questionId + * @return UsergroupRelQuestion + */ + public function setQuestionId($questionId) + { + $this->questionId = $questionId; + + return $this; + } + + /** + * Get questionId + * + * @return integer + */ + public function getQuestionId() + { + return $this->questionId; + } + + /** + * Set usergroupId + * + * @param integer $usergroupId + * @return UsergroupRelQuestion + */ + public function setUsergroupId($usergroupId) + { + $this->usergroupId = $usergroupId; + + return $this; + } + + /** + * Get usergroupId + * + * @return integer + */ + public function getUsergroupId() + { + return $this->usergroupId; + } + + /** + * Set coefficient + * + * @param float $coefficient + * @return UsergroupRelQuestion + */ + public function setCoefficient($coefficient) + { + $this->coefficient = $coefficient; + + return $this; + } + + /** + * Get coefficient + * + * @return float + */ + public function getCoefficient() + { + return $this->coefficient; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Entity/UsergroupRelSession.php b/src/Chamilo/CoreBundle/Entity/UsergroupRelSession.php new file mode 100644 index 0000000000..ac525844e2 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/UsergroupRelSession.php @@ -0,0 +1,95 @@ +usergroupId = $usergroupId; + + return $this; + } + + /** + * Get usergroupId + * + * @return integer + */ + public function getUsergroupId() + { + return $this->usergroupId; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return UsergroupRelSession + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CoreBundle/Migrations/AbstractMigrationChamilo.php b/src/Chamilo/CoreBundle/Migrations/AbstractMigrationChamilo.php new file mode 100644 index 0000000000..53c7fe92a0 --- /dev/null +++ b/src/Chamilo/CoreBundle/Migrations/AbstractMigrationChamilo.php @@ -0,0 +1,31 @@ +manager = $manager; + } + + /** + * @return EntityManager + */ + public function getEntityManager() + { + return $this->manager; + } +} diff --git a/src/Chamilo/CoreBundle/Migrations/Schema/v1/Version110.php b/src/Chamilo/CoreBundle/Migrations/Schema/v1/Version110.php new file mode 100644 index 0000000000..0558da3d0f --- /dev/null +++ b/src/Chamilo/CoreBundle/Migrations/Schema/v1/Version110.php @@ -0,0 +1,634 @@ +createTable + + $this->addSql("CREATE TABLE IF NOT EXISTS course_field_options (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, field_id INT NOT NULL, option_value TEXT, option_display_text VARCHAR(64), option_order INT, tms DATETIME)"); + $this->addSql("CREATE TABLE IF NOT EXISTS session_field_options (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, field_id INT NOT NULL, option_value TEXT, option_display_text VARCHAR(64), option_order INT, tms DATETIME)"); + $this->addSql("CREATE TABLE IF NOT EXISTS hook_observer( id int UNSIGNED NOT NULL AUTO_INCREMENT, class_name varchar(255) UNIQUE, path varchar(255) NOT NULL, plugin_name varchar(255) NULL, PRIMARY KEY PK_hook_management_hook_observer(id))"); + $this->addSql("CREATE TABLE IF NOT EXISTS hook_event( id int UNSIGNED NOT NULL AUTO_INCREMENT, class_name varchar(255) UNIQUE, description varchar(255), PRIMARY KEY PK_hook_management_hook_event(id))"); + $this->addSql("CREATE TABLE IF NOT EXISTS hook_call( id int UNSIGNED NOT NULL AUTO_INCREMENT, hook_event_id int UNSIGNED NOT NULL, hook_observer_id int UNSIGNED NOT NULL, type tinyint NOT NULL, hook_order int UNSIGNED NOT NULL, enabled tinyint NOT NULL, PRIMARY KEY PK_hook_management_hook_call(id))"); + $this->addSql("CREATE TABLE IF NOT EXISTS c_student_publication_rel_document (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, work_id INT NOT NULL, document_id INT NOT NULL, c_id INT NOT NULL)"); + $this->addSql("CREATE TABLE IF NOT EXISTS c_student_publication_rel_user (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, work_id INT NOT NULL, user_id INT NOT NULL, c_id INT NOT NULL)"); + $this->addSql("CREATE TABLE IF NOT EXISTS c_student_publication_comment (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, work_id INT NOT NULL, c_id INT NOT NULL, comment text, file VARCHAR(255), user_id int NOT NULL, sent_at datetime NOT NULL)"); + $this->addSql("CREATE TABLE IF NOT EXISTS c_attendance_calendar_rel_group (id int NOT NULL auto_increment PRIMARY KEY, c_id INT NOT NULL, group_id INT NOT NULL, calendar_id INT NOT NULL)"); + + //$this->addSql("ALTER TABLE skill_rel_user ADD COLUMN course_id INT NOT NULL DEFAULT 0 AFTER id"); + //$this->addSql("ALTER TABLE skill_rel_user ADD COLUMN session_id INT NOT NULL DEFAULT 0 AFTER course_id"); + //$this->addSql("ALTER TABLE skill_rel_user ADD INDEX idx_select_cs (course_id, session_id)"); + + $table = $schema->getTable('session'); + if (!$table->hasColumn('description')) { + $table->addColumn( + 'description', + 'text', + array('default' => 'NULL') + ); + } + + if (!$table->hasColumn('show_description')) { + $table->addColumn( + 'show_description', + 'smallint', + array('default' => 0, 'unsigned' => true) + ); + } + + $this->addSql("ALTER TABLE session ADD COLUMN duration int"); + $this->addSql("ALTER TABLE session_rel_user ADD COLUMN duration int"); + $this->addSql("ALTER TABLE skill ADD COLUMN criteria text DEFAULT ''"); + $this->addSql("ALTER TABLE gradebook_category ADD COLUMN generate_certificates TINYINT NOT NULL DEFAULT 0"); + $this->addSql("ALTER TABLE track_e_access ADD COLUMN c_id int NOT NULL"); + + $this->addSql("ALTER TABLE track_e_lastaccess ADD COLUMN c_id int NOT NULL"); + $this->addSql("ALTER TABLE track_e_exercices ADD COLUMN c_id int NOT NULL"); + $this->addSql("ALTER TABLE track_e_downloads ADD COLUMN c_id int NOT NULL"); + $this->addSql("ALTER TABLE track_e_hotpotatoes ADD COLUMN c_id int NOT NULL"); + $this->addSql("ALTER TABLE track_e_links ADD COLUMN c_id int NOT NULL"); + $this->addSql("ALTER TABLE track_e_course_access ADD COLUMN c_id int NOT NULL"); + $this->addSql("ALTER TABLE track_e_online ADD COLUMN c_id int NOT NULL"); + $this->addSql("ALTER TABLE track_e_attempt ADD COLUMN c_id int NOT NULL"); + $this->addSql("ALTER TABLE track_e_default ADD COLUMN session_id int NOT NULL"); + $this->addSql("ALTER TABLE track_e_access ADD COLUMN user_ip varchar(39) NOT NULL default ''"); + $this->addSql("ALTER TABLE track_e_exercices ADD COLUMN user_ip varchar(39) NOT NULL default ''"); + $this->addSql("ALTER TABLE track_e_course_access ADD COLUMN user_ip varchar(39) NOT NULL default ''"); + $this->addSql("ALTER TABLE track_e_online CHANGE COLUMN login_ip user_ip varchar(39) NOT NULL DEFAULT ''"); + $this->addSql("ALTER TABLE track_e_login CHANGE COLUMN login_ip user_ip varchar(39) NOT NULL DEFAULT ''"); + + $this->addSql("ALTER TABLE user MODIFY COLUMN user_id int unsigned DEFAULT null"); + $this->addSql("ALTER TABLE user DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE user ADD COLUMN id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT AFTER user_id"); + $this->addSql("ALTER TABLE user MODIFY COLUMN chatcall_date datetime default NULL"); + $this->addSql("ALTER TABLE user MODIFY COLUMN chatcall_text varchar(50) default NULL"); + $this->addSql("ALTER TABLE user MODIFY COLUMN chatcall_user_id int unsigned default 0"); + $this->addSql("ALTER TABLE user MODIFY COLUMN expiration_date datetime default NULL"); + $this->addSql("ALTER TABLE user MODIFY COLUMN registration_date datetime NOT NULL"); + + $this->addSql("ALTER TABLE course ADD COLUMN add_teachers_to_sessions_courses tinyint NOT NULL default 0"); + $this->addSql("ALTER TABLE session MODIFY COLUMN name char(100) NOT NULL DEFAULT ''"); + $this->addSql("ALTER TABLE course_rel_user ADD COLUMN c_id int default NULL"); + $this->addSql("ALTER TABLE course_field_values ADD COLUMN c_id int default NULL"); + + $this->addSql("ALTER TABLE session_rel_course_rel_user ADD COLUMN c_id int default NULL"); + $this->addSql("ALTER TABLE session_rel_course_rel_user CHANGE id_session session_id int"); + $this->addSql("ALTER TABLE session_rel_course_rel_user CHANGE id_user user_id int"); + + $this->addSql("ALTER TABLE access_url_rel_course ADD COLUMN c_id int"); + + $this->addSql("ALTER TABLE session_rel_course ADD COLUMN position int NOT NULL default 0"); + $this->addSql("ALTER TABLE session_rel_course ADD COLUMN category varchar(255) default ''"); + $this->addSql("ALTER TABLE session_rel_course ADD COLUMN c_id int unsigned"); + $this->addSql("ALTER TABLE session_rel_course CHANGE id_session session_id int"); + + $this->addSql("UPDATE course_rel_user SET c_id = (SELECT id FROM course WHERE code = course_code)"); + + // Add iid + $tables = [ + 'c_announcement', + 'c_announcement_attachment', + 'c_attendance', + 'c_attendance_calendar', + 'c_attendance_calendar_rel_group', + 'c_attendance_result', + //'c_attendance_sheet', + 'c_attendance_sheet_log', + //'c_blog', + 'c_blog_attachment', + //'c_blog_comment', + //'c_blog_post', + //'c_blog_rating', + //'c_blog_rel_user', + //'c_blog_task', + //'c_blog_task_rel_user', + 'c_calendar_event', + 'c_calendar_event_attachment', + //'c_calendar_event_repeat', + //'c_calendar_event_repeat_not', + 'c_chat_connected', + 'c_course_description', + 'c_course_setting', + 'c_document', + //'c_dropbox_category', + //'c_dropbox_feedback', + 'c_dropbox_file', + //'c_dropbox_person', + //'c_dropbox_post', + 'c_forum_attachment', + //'c_forum_category', + //'c_forum_forum', + 'c_forum_mailcue', + 'c_forum_notification', + //'c_forum_post', + //'c_forum_thread', + 'c_forum_thread_qualify', + 'c_forum_thread_qualify_log', + //'c_glossary', + 'c_group_category', + //'c_group_info', + 'c_group_rel_tutor', + 'c_group_rel_user', + 'c_item_property', + 'c_link', + 'c_link_category', + 'c_lp', + 'c_lp_item', + 'c_lp_item_view', + 'c_lp_iv_interaction', + 'c_lp_iv_objective', + 'c_lp_view', + //'c_notebook', + //'c_online_connected', + 'c_online_link', + 'c_permission_group', + 'c_permission_task', + 'c_permission_user', + 'c_quiz', + //'c_quiz_answer', + 'c_quiz_question', + 'c_quiz_question_category', + 'c_quiz_question_option', + //'c_quiz_question_rel_category', + //'c_quiz_rel_question', + 'c_resource', + //'c_role', + 'c_role_group', + 'c_role_permissions', + //'c_role_user', + 'c_student_publication', + 'c_student_publication_assignment', + 'c_student_publication_comment', + 'c_student_publication_rel_document', + 'c_student_publication_rel_user', + //'c_survey', + //'c_survey_answer', + 'c_survey_group', + //'c_survey_invitation', + //'c_survey_question', + //'c_survey_question_option', + 'c_thematic', + 'c_thematic_advance', + 'c_thematic_plan', + 'c_tool', + 'c_tool_intro', + 'c_userinfo_content', + 'c_userinfo_def', + 'c_wiki', + //'c_wiki_conf', + 'c_wiki_discuss', + 'c_wiki_mailcue' + ]; + + foreach ($tables as $table) { + $this->addSql("ALTER TABLE $table MODIFY COLUMN id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE $table MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE $table DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE $table ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + } + + $this->addSql("ALTER TABLE c_attendance_sheet MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_attendance_sheet DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_attendance_sheet ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_blog MODIFY COLUMN blog_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_blog ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_blog_comment MODIFY COLUMN comment_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog_comment MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog_comment DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_blog_comment ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_blog_post MODIFY COLUMN post_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog_post MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog_post DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_blog_post ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_blog_rating MODIFY COLUMN rating_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog_rating MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog_rating DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_blog_rating ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_blog_rel_user MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog_rel_user MODIFY COLUMN blog_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog_rel_user MODIFY COLUMN user_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog_rel_user DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_blog_rel_user ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_blog_task MODIFY COLUMN task_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog_task MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog_task DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_blog_task ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_blog_task_rel_user MODIFY COLUMN blog_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog_task_rel_user MODIFY COLUMN user_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog_task_rel_user MODIFY COLUMN task_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_blog_task_rel_user DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_blog_task_rel_user ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_calendar_event_repeat MODIFY COLUMN cal_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_calendar_event_repeat MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_calendar_event_repeat DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_calendar_event_repeat ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_calendar_event_repeat_not MODIFY COLUMN cal_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_calendar_event_repeat_not MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_calendar_event_repeat_not DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_calendar_event_repeat_not ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_dropbox_category MODIFY COLUMN cat_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_dropbox_category MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_dropbox_category DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_dropbox_category ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_dropbox_feedback MODIFY COLUMN feedback_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_dropbox_feedback MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_dropbox_feedback DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_dropbox_feedback ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_dropbox_person MODIFY COLUMN file_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_dropbox_person MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_dropbox_person DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_dropbox_person ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_dropbox_post MODIFY COLUMN file_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_dropbox_post MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_dropbox_post DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_dropbox_post ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_forum_category MODIFY COLUMN cat_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_forum_category MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_forum_category DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_forum_category ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_forum_forum MODIFY COLUMN forum_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_forum_forum MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_forum_forum DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_forum_forum ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_forum_post MODIFY COLUMN post_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_forum_post MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_forum_post DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_forum_post ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_forum_thread MODIFY COLUMN forum_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_forum_thread MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_forum_thread MODIFY COLUMN thread_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_forum_thread DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_forum_thread ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_glossary MODIFY COLUMN glossary_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_glossary MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_glossary DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_glossary ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_notebook MODIFY COLUMN notebook_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_notebook MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_notebook DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_notebook ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_online_connected MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_online_connected DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_online_connected ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_quiz_answer MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_quiz_answer MODIFY COLUMN id_auto int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_quiz_answer DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_quiz_answer MODIFY COLUMN id_auto int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_quiz_question_rel_category MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_quiz_question_rel_category MODIFY COLUMN question_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_quiz_question_rel_category DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_quiz_question_rel_category ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE session_rel_user MODIFY COLUMN id_session int unsigned"); + $this->addSql("ALTER TABLE session_rel_user MODIFY COLUMN id_user int unsigned"); + $this->addSql("ALTER TABLE session_rel_user MODIFY COLUMN relation_type int unsigned DEFAULT 0"); + $this->addSql("ALTER TABLE session_rel_user DROP PRIMARY KEY"); + + $this->addSql("ALTER TABLE session_rel_user CHANGE id_session session_id int unsigned"); + $this->addSql("ALTER TABLE session_rel_user CHANGE id_user user_id int unsigned"); + $this->addSql("ALTER TABLE session_rel_user ADD COLUMN id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + + $this->addSql("ALTER TABLE c_item_property CHANGE id_session session_id int"); + $this->addSql("ALTER TABLE course_rel_user CHANGE tutor_id is_tutor int"); + + $this->addSql("ALTER TABLE c_quiz_rel_question MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_quiz_rel_question MODIFY COLUMN question_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_quiz_rel_question MODIFY COLUMN exercice_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_quiz_rel_question DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_quiz_rel_question ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_role MODIFY COLUMN role_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_role MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_role DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_role ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_role_user MODIFY COLUMN role_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_role_user MODIFY COLUMN user_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_role_user MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_role_user DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_role_user ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_survey MODIFY COLUMN survey_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_survey MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_survey DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_survey ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_survey_answer MODIFY COLUMN answer_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_survey_answer MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_survey_answer DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_survey_answer ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_survey_invitation MODIFY COLUMN survey_invitation_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_survey_invitation MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_survey_invitation DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_survey_invitation ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_survey_question MODIFY COLUMN question_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_survey_question MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_survey_question DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_survey_question ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_survey_question_option MODIFY COLUMN question_option_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_survey_question_option MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_survey_question_option DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_survey_question_option ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + $this->addSql("ALTER TABLE c_wiki_conf MODIFY COLUMN page_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_wiki_conf MODIFY COLUMN c_id int unsigned DEFAULT NULL"); + $this->addSql("ALTER TABLE c_wiki_conf DROP PRIMARY KEY"); + $this->addSql("ALTER TABLE c_wiki_conf ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT"); + + // Course + $this->addSql("ALTER TABLE c_survey ADD COLUMN visible_results INT UNSIGNED DEFAULT 0"); + $this->addSql("ALTER TABLE c_survey_invitation ADD COLUMN group_id INT NOT NULL"); + $this->addSql("ALTER TABLE c_lp_item ADD COLUMN prerequisite_min_score float"); + $this->addSql("ALTER TABLE c_lp_item ADD COLUMN prerequisite_max_score float"); + $this->addSql("ALTER TABLE c_group_info ADD COLUMN status tinyint DEFAULT 1"); + $this->addSql("ALTER TABLE c_student_publication ADD COLUMN document_id int DEFAULT 0"); + $this->addSql("ALTER TABLE c_lp_item MODIFY COLUMN description VARCHAR(511) DEFAULT ''"); + $this->addSql("ALTER TABLE course_category MODIFY COLUMN auth_course_child VARCHAR(40) DEFAULT 'TRUE' "); + $this->addSql("ALTER TABLE course_category MODIFY COLUMN auth_cat_child VARCHAR(40) DEFAULT 'TRUE'"); + $this->addSql("ALTER TABLE c_quiz_answer MODIFY COLUMN hotspot_type varchar(40) default NULL"); + $this->addSql("ALTER TABLE c_tool MODIFY COLUMN target varchar(20) NOT NULL default '_self' "); + $this->addSql("ALTER TABLE c_link MODIFY COLUMN on_homepage char(10) NOT NULL default '0' "); + $this->addSql("ALTER TABLE c_blog_rating MODIFY COLUMN rating_type char(40) NOT NULL default 'post' "); + $this->addSql("ALTER TABLE c_survey MODIFY COLUMN anonymous char(10) NOT NULL default '0'"); + $this->addSql("ALTER TABLE c_course_setting MODIFY COLUMN value varchar(255) default ''"); + + $this->addSql("UPDATE user SET id = user_id"); + $this->addSql("UPDATE course_field SET field_type = 1 WHERE field_variable = 'special_course'"); + $this->addSql("UPDATE user SET registration_date = NULL WHERE registration_date = '0000-00-00 00:00:00'"); + $this->addSql("UPDATE user SET expiration_date = NULL WHERE expiration_date = '0000-00-00 00:00:00'"); + $this->addSql("UPDATE track_e_default SET default_date = NULL WHERE default_date = '0000-00-00 00:00:00'"); + $this->addSql("UPDATE track_e_lastaccess SET access_date = NULL WHERE access_date = '0000-00-00 00:00:00'"); + $this->addSql("UPDATE track_e_downloads SET down_date = NULL WHERE down_date = '0000-00-00 00:00:00'"); + $this->addSql("UPDATE track_e_access SET access_date = NULL WHERE access_date = '0000-00-00 00:00:00'"); + $this->addSql("UPDATE track_e_access SET c_id = (SELECT id FROM course WHERE code = access_cours_code)"); + $this->addSql("UPDATE track_e_default SET c_id = (SELECT id FROM course WHERE code = default_cours_code)"); + $this->addSql("UPDATE track_e_lastaccess SET c_id = (SELECT id FROM course WHERE code = access_cours_code)"); + $this->addSql("UPDATE track_e_exercices SET c_id = (SELECT id FROM course WHERE code = exe_cours_id)"); + $this->addSql("UPDATE track_e_downloads SET c_id = (SELECT id FROM course WHERE code = down_cours_id)"); + $this->addSql("UPDATE track_e_hotpotatoes SET c_id = (SELECT id FROM course WHERE code = exe_cours_id)"); + $this->addSql("UPDATE track_e_links SET c_id = (SELECT id FROM course WHERE code = links_cours_id)"); + $this->addSql("UPDATE track_e_course_access SET c_id = (SELECT id FROM course WHERE code = course_code)"); + $this->addSql("UPDATE track_e_online SET c_id = (SELECT id FROM course WHERE code = course)"); + $this->addSql("UPDATE track_e_attempt SET c_id = (SELECT id FROM course WHERE code = course_code)"); + $this->addSql("UPDATE course_field_values SET c_id = (SELECT id FROM course WHERE code = course_code)"); + $this->addSql("UPDATE session_rel_course_rel_user SET c_id = (SELECT id FROM course WHERE code = course_code)"); + $this->addSql("UPDATE session_rel_course SET c_id = (SELECT id FROM course WHERE code = course_code)"); + + $this->addSql("UPDATE access_url_rel_course SET c_id = (SELECT id FROM course WHERE code = course_code)"); + + $this->addSql("DELETE FROM settings_current WHERE variable = 'wcag_anysurfer_public_pages'"); + $this->addSql("DELETE FROM settings_options WHERE variable = 'wcag_anysurfer_public_pages'"); + $this->addSql("DELETE FROM settings_current WHERE variable = 'advanced_filemanager'"); + $this->addSql("DELETE FROM settings_options WHERE variable = 'advanced_filemanager'"); + + $this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('prevent_session_admins_to_manage_all_users', NULL, 'radio', 'Session', 'false', 'PreventSessionAdminsToManageAllUsersTitle', 'PreventSessionAdminsToManageAllUsersComment', NULL, NULL, 1)"); + $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('prevent_session_admins_to_manage_all_users', 'true', 'Yes'), ('prevent_session_admins_to_manage_all_users', 'false', 'No')"); + $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'none', 'None')"); + $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'exercise', 'Exercise')"); + $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'lp', 'Learning path')"); + $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'exercise_and_lp', 'ExerciseAndLearningPath')"); + $this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('documents_default_visibility_defined_in_course', NULL,'radio','Tools','false','DocumentsDefaultVisibilityDefinedInCourseTitle','DocumentsDefaultVisibilityDefinedInCourseComment',NULL, NULL, 1)"); + $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('documents_default_visibility_defined_in_course', 'true', 'Yes')"); + $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('documents_default_visibility_defined_in_course', 'false', 'No')"); + $this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enabled_mathjax', NULL, 'radio', 'Editor', 'false', 'EnableMathJaxTitle', 'EnableMathJaxComment', NULL, NULL, 0)"); + $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'true', 'Yes')"); + $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'false', 'No')"); + + $this->addSql("INSERT INTO language (original_name, english_name, isocode, dokeos_folder, available) VALUES ('Føroyskt', 'faroese', 'fo', 'faroese', 0), ('Tagalog', 'tagalog', 'tl', 'tagalog',1), ('Tibetan', 'tibetan', 'bo', 'tibetan', 0), ('isiXhosa', 'xhosa', 'xh', 'xhosa', 0)"); + $this->addSql("DELETE FROM settings_options WHERE variable = 'show_glossary_in_extra_tools'"); + + //$schema->renameTable('track_e_exercices', 'track_e_exercises'); + + $this->addSql("UPDATE c_student_publication SET date_of_qualification = NULL WHERE date_of_qualification = '0000-00-00 00:00:00'"); + $this->addSql("UPDATE c_student_publication SET sent_date = NULL WHERE sent_date = '0000-00-00 00:00:00'"); + + $this->addSql("UPDATE c_student_publication_assignment SET expires_on = NULL WHERE expires_on = '0000-00-00 00:00:00'"); + $this->addSql("UPDATE c_student_publication_assignment SET ends_on = NULL WHERE ends_on = '0000-00-00 00:00:00'"); + } + + public function postUp(Schema $schema) + { + $this->addSql("ALTER TABLE track_e_access DROP COLUMN access_cours_code"); + $this->addSql("ALTER TABLE track_e_default DROP COLUMN default_cours_code"); + $this->addSql("ALTER TABLE track_e_lastaccess DROP COLUMN access_cours_code"); + $this->addSql("ALTER TABLE track_e_exercises DROP COLUMN exe_cours_id"); + $this->addSql("ALTER TABLE track_e_downloads DROP COLUMN down_cours_id"); + $this->addSql("ALTER TABLE track_e_hotpotatoes DROP COLUMN exe_cours_id"); + $this->addSql("ALTER TABLE track_e_links DROP COLUMN links_cours_id"); + $this->addSql("ALTER TABLE track_e_course_access DROP COLUMN course_code"); + $this->addSql("ALTER TABLE track_e_online DROP COLUMN course"); + $this->addSql("ALTER TABLE track_e_attempt DROP COLUMN course_code"); + + $this->addSql("ALTER TABLE course_rel_user DROP COLUMN group_id"); + $this->addSql("ALTER TABLE course_rel_user DROP COLUMN role"); + + $this->addSql("DROP TABLE track_c_countries"); + $this->addSql("DROP TABLE track_c_browsers"); + $this->addSql("DROP TABLE track_c_os"); + $this->addSql("DROP TABLE track_c_providers"); + $this->addSql("DROP TABLE track_c_referers"); + + // Fix ids + /* + // Fix c_lp_item + $connection = $this->connection; + + $sql = "SELECT * FROM c_lp_item"; + $result = $connection->fetchAll($sql); + foreach ($result as $item) { + $courseId = $item['c_id']; + $iid = $item['iid']; + $ref = $item['ref']; + $sql = null; + + switch ($item['item_type']) { + case TOOL_LINK: + $sql = "SELECT * c_link WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + case TOOL_STUDENTPUBLICATION: + $sql = "SELECT * c_student_publication WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + case TOOL_QUIZ: + $sql = "SELECT * c_quiz WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + case TOOL_DOCUMENT: + $sql = "SELECT * c_document WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + case TOOL_FORUM: + $sql = "SELECT * c_forum_forum WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + case 'thread': + $sql = "SELECT * c_forum_thread WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + } + + if (!empty($sql)) { + $sql = "UPDATE c_lp_item SET ref = $newId WHERE iid = $iid"; + $connection->executeQuery($sql); + } + } + + // Fix c_item_property + + $sql = "SELECT * FROM c_item_property"; + $result = $connection->fetchAll($sql); + foreach ($result as $item) { + $courseId = $item['c_id']; + $sessionId = intval($item['session_id']); + $iid = $item['iid']; + $ref = $item['ref']; + $sql = null; + + switch ($item['tool']) { + case TOOL_LINK: + $sql = "SELECT * c_link WHERE c_id = $courseId AND id = $ref "; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + case TOOL_STUDENTPUBLICATION: + $sql = "SELECT * c_student_publication WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + case TOOL_QUIZ: + $sql = "SELECT * c_quiz WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + case TOOL_DOCUMENT: + $sql = "SELECT * c_document WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + case TOOL_FORUM: + $sql = "SELECT * c_forum_forum WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + case 'thread': + $sql = "SELECT * c_forum_thread WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + } + + if (!empty($sql)) { + $sql = "UPDATE c_item_property SET ref = $newId WHERE iid = $iid"; + $connection->executeQuery($sql); + } + } + + // Fix gradebook_link + $sql = "SELECT * FROM gradebook_link"; + $result = $connection->fetchAll($sql); + foreach ($result as $item) { + $courseId = $item['c_id']; + $ref = $item['ref_id']; + $sql = null; + + switch ($item['tool']) { + case TOOL_LINK: + $sql = "SELECT * c_link WHERE c_id = $courseId AND id = $ref "; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + case TOOL_STUDENTPUBLICATION: + $sql = "SELECT * c_student_publication WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + case TOOL_QUIZ: + $sql = "SELECT * c_quiz WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + case TOOL_DOCUMENT: + $sql = "SELECT * c_document WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + case TOOL_FORUM: + $sql = "SELECT * c_forum_forum WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + case 'thread': + $sql = "SELECT * c_forum_thread WHERE c_id = $courseId AND id = $ref"; + $data = $connection->fetchArray($sql); + $newId = $data['iid']; + break; + } + + if (!empty($sql)) { + $sql = "UPDATE c_item_property SET ref_id = $newId WHERE iid = $iid"; + $connection->executeQuery($sql); + } + } + + + */ + + //$this->addSql('ALTER TABLE user DROP COLUMN user_id'); + + //$this->addSql("UPDATE settings_current SET selected_value = '1.10.0.35' WHERE variable = 'chamilo_database_version'"); + } + + public function down(Schema $schema) + { + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CAnnouncement.php b/src/Chamilo/CourseBundle/Entity/CAnnouncement.php new file mode 100644 index 0000000000..3732728abb --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CAnnouncement.php @@ -0,0 +1,264 @@ +title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set content + * + * @param string $content + * @return CAnnouncement + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Set endDate + * + * @param \DateTime $endDate + * @return CAnnouncement + */ + public function setEndDate($endDate) + { + $this->endDate = $endDate; + + return $this; + } + + /** + * Get endDate + * + * @return \DateTime + */ + public function getEndDate() + { + return $this->endDate; + } + + /** + * Set displayOrder + * + * @param integer $displayOrder + * @return CAnnouncement + */ + public function setDisplayOrder($displayOrder) + { + $this->displayOrder = $displayOrder; + + return $this; + } + + /** + * Get displayOrder + * + * @return integer + */ + public function getDisplayOrder() + { + return $this->displayOrder; + } + + /** + * Set emailSent + * + * @param boolean $emailSent + * @return CAnnouncement + */ + public function setEmailSent($emailSent) + { + $this->emailSent = $emailSent; + + return $this; + } + + /** + * Get emailSent + * + * @return boolean + */ + public function getEmailSent() + { + return $this->emailSent; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CAnnouncement + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set id + * + * @param integer $id + * @return CAnnouncement + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CAnnouncement + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CAnnouncementAttachment.php b/src/Chamilo/CourseBundle/Entity/CAnnouncementAttachment.php new file mode 100644 index 0000000000..85e24641e0 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CAnnouncementAttachment.php @@ -0,0 +1,234 @@ +path = $path; + + return $this; + } + + /** + * Get path + * + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Set comment + * + * @param string $comment + * @return CAnnouncementAttachment + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set size + * + * @param integer $size + * @return CAnnouncementAttachment + */ + public function setSize($size) + { + $this->size = $size; + + return $this; + } + + /** + * Get size + * + * @return integer + */ + public function getSize() + { + return $this->size; + } + + /** + * Set announcementId + * + * @param integer $announcementId + * @return CAnnouncementAttachment + */ + public function setAnnouncementId($announcementId) + { + $this->announcementId = $announcementId; + + return $this; + } + + /** + * Get announcementId + * + * @return integer + */ + public function getAnnouncementId() + { + return $this->announcementId; + } + + /** + * Set filename + * + * @param string $filename + * @return CAnnouncementAttachment + */ + public function setFilename($filename) + { + $this->filename = $filename; + + return $this; + } + + /** + * Get filename + * + * @return string + */ + public function getFilename() + { + return $this->filename; + } + + /** + * Set id + * + * @param integer $id + * @return CAnnouncementAttachment + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CAnnouncementAttachment + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CAttendance.php b/src/Chamilo/CourseBundle/Entity/CAttendance.php new file mode 100644 index 0000000000..8edf4534e2 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CAttendance.php @@ -0,0 +1,324 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set description + * + * @param string $description + * @return CAttendance + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set active + * + * @param boolean $active + * @return CAttendance + */ + public function setActive($active) + { + $this->active = $active; + + return $this; + } + + /** + * Get active + * + * @return boolean + */ + public function getActive() + { + return $this->active; + } + + /** + * Set attendanceQualifyTitle + * + * @param string $attendanceQualifyTitle + * @return CAttendance + */ + public function setAttendanceQualifyTitle($attendanceQualifyTitle) + { + $this->attendanceQualifyTitle = $attendanceQualifyTitle; + + return $this; + } + + /** + * Get attendanceQualifyTitle + * + * @return string + */ + public function getAttendanceQualifyTitle() + { + return $this->attendanceQualifyTitle; + } + + /** + * Set attendanceQualifyMax + * + * @param integer $attendanceQualifyMax + * @return CAttendance + */ + public function setAttendanceQualifyMax($attendanceQualifyMax) + { + $this->attendanceQualifyMax = $attendanceQualifyMax; + + return $this; + } + + /** + * Get attendanceQualifyMax + * + * @return integer + */ + public function getAttendanceQualifyMax() + { + return $this->attendanceQualifyMax; + } + + /** + * Set attendanceWeight + * + * @param float $attendanceWeight + * @return CAttendance + */ + public function setAttendanceWeight($attendanceWeight) + { + $this->attendanceWeight = $attendanceWeight; + + return $this; + } + + /** + * Get attendanceWeight + * + * @return float + */ + public function getAttendanceWeight() + { + return $this->attendanceWeight; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CAttendance + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set locked + * + * @param integer $locked + * @return CAttendance + */ + public function setLocked($locked) + { + $this->locked = $locked; + + return $this; + } + + /** + * Get locked + * + * @return integer + */ + public function getLocked() + { + return $this->locked; + } + + /** + * Set id + * + * @param integer $id + * @return CAttendance + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CAttendance + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CAttendanceCalendar.php b/src/Chamilo/CourseBundle/Entity/CAttendanceCalendar.php new file mode 100644 index 0000000000..e5fc345ca1 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CAttendanceCalendar.php @@ -0,0 +1,174 @@ +attendanceId = $attendanceId; + + return $this; + } + + /** + * Get attendanceId + * + * @return integer + */ + public function getAttendanceId() + { + return $this->attendanceId; + } + + /** + * Set dateTime + * + * @param \DateTime $dateTime + * @return CAttendanceCalendar + */ + public function setDateTime($dateTime) + { + $this->dateTime = $dateTime; + + return $this; + } + + /** + * Get dateTime + * + * @return \DateTime + */ + public function getDateTime() + { + return $this->dateTime; + } + + /** + * Set doneAttendance + * + * @param boolean $doneAttendance + * @return CAttendanceCalendar + */ + public function setDoneAttendance($doneAttendance) + { + $this->doneAttendance = $doneAttendance; + + return $this; + } + + /** + * Get doneAttendance + * + * @return boolean + */ + public function getDoneAttendance() + { + return $this->doneAttendance; + } + + /** + * Set id + * + * @param integer $id + * @return CAttendanceCalendar + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CAttendanceCalendar + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CAttendanceCalendarRelGroup.php b/src/Chamilo/CourseBundle/Entity/CAttendanceCalendarRelGroup.php new file mode 100644 index 0000000000..c2c6222472 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CAttendanceCalendarRelGroup.php @@ -0,0 +1,131 @@ +cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set groupId + * + * @param integer $groupId + * @return CAttendanceCalendarRelGroup + */ + public function setGroupId($groupId) + { + $this->groupId = $groupId; + + return $this; + } + + /** + * Get groupId + * + * @return integer + */ + public function getGroupId() + { + return $this->groupId; + } + + /** + * Set calendarId + * + * @param integer $calendarId + * @return CAttendanceCalendarRelGroup + */ + public function setCalendarId($calendarId) + { + $this->calendarId = $calendarId; + + return $this; + } + + /** + * Get calendarId + * + * @return integer + */ + public function getCalendarId() + { + return $this->calendarId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CAttendanceResult.php b/src/Chamilo/CourseBundle/Entity/CAttendanceResult.php new file mode 100644 index 0000000000..4755539b33 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CAttendanceResult.php @@ -0,0 +1,174 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set attendanceId + * + * @param integer $attendanceId + * @return CAttendanceResult + */ + public function setAttendanceId($attendanceId) + { + $this->attendanceId = $attendanceId; + + return $this; + } + + /** + * Get attendanceId + * + * @return integer + */ + public function getAttendanceId() + { + return $this->attendanceId; + } + + /** + * Set score + * + * @param integer $score + * @return CAttendanceResult + */ + public function setScore($score) + { + $this->score = $score; + + return $this; + } + + /** + * Get score + * + * @return integer + */ + public function getScore() + { + return $this->score; + } + + /** + * Set id + * + * @param integer $id + * @return CAttendanceResult + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CAttendanceResult + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CAttendanceSheet.php b/src/Chamilo/CourseBundle/Entity/CAttendanceSheet.php new file mode 100644 index 0000000000..15743592b3 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CAttendanceSheet.php @@ -0,0 +1,148 @@ +presence = $presence; + + return $this; + } + + /** + * Get presence + * + * @return boolean + */ + public function getPresence() + { + return $this->presence; + } + + /** + * Set cId + * + * @param integer $cId + * @return CAttendanceSheet + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set userId + * + * @param integer $userId + * @return CAttendanceSheet + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set attendanceCalendarId + * + * @param integer $attendanceCalendarId + * @return CAttendanceSheet + */ + public function setAttendanceCalendarId($attendanceCalendarId) + { + $this->attendanceCalendarId = $attendanceCalendarId; + + return $this; + } + + /** + * Get attendanceCalendarId + * + * @return integer + */ + public function getAttendanceCalendarId() + { + return $this->attendanceCalendarId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CAttendanceSheetLog.php b/src/Chamilo/CourseBundle/Entity/CAttendanceSheetLog.php new file mode 100644 index 0000000000..de630d1e12 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CAttendanceSheetLog.php @@ -0,0 +1,234 @@ +attendanceId = $attendanceId; + + return $this; + } + + /** + * Get attendanceId + * + * @return integer + */ + public function getAttendanceId() + { + return $this->attendanceId; + } + + /** + * Set lasteditDate + * + * @param \DateTime $lasteditDate + * @return CAttendanceSheetLog + */ + public function setLasteditDate($lasteditDate) + { + $this->lasteditDate = $lasteditDate; + + return $this; + } + + /** + * Get lasteditDate + * + * @return \DateTime + */ + public function getLasteditDate() + { + return $this->lasteditDate; + } + + /** + * Set lasteditType + * + * @param string $lasteditType + * @return CAttendanceSheetLog + */ + public function setLasteditType($lasteditType) + { + $this->lasteditType = $lasteditType; + + return $this; + } + + /** + * Get lasteditType + * + * @return string + */ + public function getLasteditType() + { + return $this->lasteditType; + } + + /** + * Set lasteditUserId + * + * @param integer $lasteditUserId + * @return CAttendanceSheetLog + */ + public function setLasteditUserId($lasteditUserId) + { + $this->lasteditUserId = $lasteditUserId; + + return $this; + } + + /** + * Get lasteditUserId + * + * @return integer + */ + public function getLasteditUserId() + { + return $this->lasteditUserId; + } + + /** + * Set calendarDateValue + * + * @param \DateTime $calendarDateValue + * @return CAttendanceSheetLog + */ + public function setCalendarDateValue($calendarDateValue) + { + $this->calendarDateValue = $calendarDateValue; + + return $this; + } + + /** + * Get calendarDateValue + * + * @return \DateTime + */ + public function getCalendarDateValue() + { + return $this->calendarDateValue; + } + + /** + * Set id + * + * @param integer $id + * @return CAttendanceSheetLog + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CAttendanceSheetLog + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CBlog.php b/src/Chamilo/CourseBundle/Entity/CBlog.php new file mode 100644 index 0000000000..d0425a92b0 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CBlog.php @@ -0,0 +1,236 @@ +blogName = $blogName; + + return $this; + } + + /** + * Get blogName + * + * @return string + */ + public function getBlogName() + { + return $this->blogName; + } + + /** + * Set blogSubtitle + * + * @param string $blogSubtitle + * @return CBlog + */ + public function setBlogSubtitle($blogSubtitle) + { + $this->blogSubtitle = $blogSubtitle; + + return $this; + } + + /** + * Get blogSubtitle + * + * @return string + */ + public function getBlogSubtitle() + { + return $this->blogSubtitle; + } + + /** + * Set dateCreation + * + * @param \DateTime $dateCreation + * @return CBlog + */ + public function setDateCreation($dateCreation) + { + $this->dateCreation = $dateCreation; + + return $this; + } + + /** + * Get dateCreation + * + * @return \DateTime + */ + public function getDateCreation() + { + return $this->dateCreation; + } + + /** + * Set visibility + * + * @param boolean $visibility + * @return CBlog + */ + public function setVisibility($visibility) + { + $this->visibility = $visibility; + + return $this; + } + + /** + * Get visibility + * + * @return boolean + */ + public function getVisibility() + { + return $this->visibility; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CBlog + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set blogId + * + * @param integer $blogId + * @return CBlog + */ + public function setBlogId($blogId) + { + $this->blogId = $blogId; + + return $this; + } + + /** + * Get blogId + * + * @return integer + */ + public function getBlogId() + { + return $this->blogId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CBlog + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CBlogAttachment.php b/src/Chamilo/CourseBundle/Entity/CBlogAttachment.php new file mode 100644 index 0000000000..2d5d8ce202 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CBlogAttachment.php @@ -0,0 +1,295 @@ +path = $path; + + return $this; + } + + /** + * Get path + * + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Set comment + * + * @param string $comment + * @return CBlogAttachment + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set size + * + * @param integer $size + * @return CBlogAttachment + */ + public function setSize($size) + { + $this->size = $size; + + return $this; + } + + /** + * Get size + * + * @return integer + */ + public function getSize() + { + return $this->size; + } + + /** + * Set postId + * + * @param integer $postId + * @return CBlogAttachment + */ + public function setPostId($postId) + { + $this->postId = $postId; + + return $this; + } + + /** + * Get postId + * + * @return integer + */ + public function getPostId() + { + return $this->postId; + } + + /** + * Set filename + * + * @param string $filename + * @return CBlogAttachment + */ + public function setFilename($filename) + { + $this->filename = $filename; + + return $this; + } + + /** + * Get filename + * + * @return string + */ + public function getFilename() + { + return $this->filename; + } + + /** + * Set blogId + * + * @param integer $blogId + * @return CBlogAttachment + */ + public function setBlogId($blogId) + { + $this->blogId = $blogId; + + return $this; + } + + /** + * Get blogId + * + * @return integer + */ + public function getBlogId() + { + return $this->blogId; + } + + /** + * Set commentId + * + * @param integer $commentId + * @return CBlogAttachment + */ + public function setCommentId($commentId) + { + $this->commentId = $commentId; + + return $this; + } + + /** + * Get commentId + * + * @return integer + */ + public function getCommentId() + { + return $this->commentId; + } + + /** + * Set id + * + * @param integer $id + * @return CBlogAttachment + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CBlogAttachment + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CBlogComment.php b/src/Chamilo/CourseBundle/Entity/CBlogComment.php new file mode 100644 index 0000000000..68fbdff09b --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CBlogComment.php @@ -0,0 +1,324 @@ +title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set comment + * + * @param string $comment + * @return CBlogComment + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set authorId + * + * @param integer $authorId + * @return CBlogComment + */ + public function setAuthorId($authorId) + { + $this->authorId = $authorId; + + return $this; + } + + /** + * Get authorId + * + * @return integer + */ + public function getAuthorId() + { + return $this->authorId; + } + + /** + * Set dateCreation + * + * @param \DateTime $dateCreation + * @return CBlogComment + */ + public function setDateCreation($dateCreation) + { + $this->dateCreation = $dateCreation; + + return $this; + } + + /** + * Get dateCreation + * + * @return \DateTime + */ + public function getDateCreation() + { + return $this->dateCreation; + } + + /** + * Set blogId + * + * @param integer $blogId + * @return CBlogComment + */ + public function setBlogId($blogId) + { + $this->blogId = $blogId; + + return $this; + } + + /** + * Get blogId + * + * @return integer + */ + public function getBlogId() + { + return $this->blogId; + } + + /** + * Set postId + * + * @param integer $postId + * @return CBlogComment + */ + public function setPostId($postId) + { + $this->postId = $postId; + + return $this; + } + + /** + * Get postId + * + * @return integer + */ + public function getPostId() + { + return $this->postId; + } + + /** + * Set taskId + * + * @param integer $taskId + * @return CBlogComment + */ + public function setTaskId($taskId) + { + $this->taskId = $taskId; + + return $this; + } + + /** + * Get taskId + * + * @return integer + */ + public function getTaskId() + { + return $this->taskId; + } + + /** + * Set parentCommentId + * + * @param integer $parentCommentId + * @return CBlogComment + */ + public function setParentCommentId($parentCommentId) + { + $this->parentCommentId = $parentCommentId; + + return $this; + } + + /** + * Get parentCommentId + * + * @return integer + */ + public function getParentCommentId() + { + return $this->parentCommentId; + } + + /** + * Set commentId + * + * @param integer $commentId + * @return CBlogComment + */ + public function setCommentId($commentId) + { + $this->commentId = $commentId; + + return $this; + } + + /** + * Get commentId + * + * @return integer + */ + public function getCommentId() + { + return $this->commentId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CBlogComment + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CBlogPost.php b/src/Chamilo/CourseBundle/Entity/CBlogPost.php new file mode 100644 index 0000000000..37a1811d4c --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CBlogPost.php @@ -0,0 +1,233 @@ +title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set fullText + * + * @param string $fullText + * @return CBlogPost + */ + public function setFullText($fullText) + { + $this->fullText = $fullText; + + return $this; + } + + /** + * Get fullText + * + * @return string + */ + public function getFullText() + { + return $this->fullText; + } + + /** + * Set dateCreation + * + * @param \DateTime $dateCreation + * @return CBlogPost + */ + public function setDateCreation($dateCreation) + { + $this->dateCreation = $dateCreation; + + return $this; + } + + /** + * Get dateCreation + * + * @return \DateTime + */ + public function getDateCreation() + { + return $this->dateCreation; + } + + /** + * Set blogId + * + * @param integer $blogId + * @return CBlogPost + */ + public function setBlogId($blogId) + { + $this->blogId = $blogId; + + return $this; + } + + /** + * Get blogId + * + * @return integer + */ + public function getBlogId() + { + return $this->blogId; + } + + /** + * Set authorId + * + * @param integer $authorId + * @return CBlogPost + */ + public function setAuthorId($authorId) + { + $this->authorId = $authorId; + + return $this; + } + + /** + * Get authorId + * + * @return integer + */ + public function getAuthorId() + { + return $this->authorId; + } + + /** + * Set postId + * + * @param integer $postId + * @return CBlogPost + */ + public function setPostId($postId) + { + $this->postId = $postId; + + return $this; + } + + /** + * Get postId + * + * @return integer + */ + public function getPostId() + { + return $this->postId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CBlogPost + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CBlogRating.php b/src/Chamilo/CourseBundle/Entity/CBlogRating.php new file mode 100644 index 0000000000..0d2c9eae3b --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CBlogRating.php @@ -0,0 +1,234 @@ +blogId = $blogId; + + return $this; + } + + /** + * Get blogId + * + * @return integer + */ + public function getBlogId() + { + return $this->blogId; + } + + /** + * Set ratingType + * + * @param string $ratingType + * @return CBlogRating + */ + public function setRatingType($ratingType) + { + $this->ratingType = $ratingType; + + return $this; + } + + /** + * Get ratingType + * + * @return string + */ + public function getRatingType() + { + return $this->ratingType; + } + + /** + * Set itemId + * + * @param integer $itemId + * @return CBlogRating + */ + public function setItemId($itemId) + { + $this->itemId = $itemId; + + return $this; + } + + /** + * Get itemId + * + * @return integer + */ + public function getItemId() + { + return $this->itemId; + } + + /** + * Set userId + * + * @param integer $userId + * @return CBlogRating + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set rating + * + * @param integer $rating + * @return CBlogRating + */ + public function setRating($rating) + { + $this->rating = $rating; + + return $this; + } + + /** + * Get rating + * + * @return integer + */ + public function getRating() + { + return $this->rating; + } + + /** + * Set ratingId + * + * @param integer $ratingId + * @return CBlogRating + */ + public function setRatingId($ratingId) + { + $this->ratingId = $ratingId; + + return $this; + } + + /** + * Get ratingId + * + * @return integer + */ + public function getRatingId() + { + return $this->ratingId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CBlogRating + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CBlogRelUser.php b/src/Chamilo/CourseBundle/Entity/CBlogRelUser.php new file mode 100644 index 0000000000..274b9ed9b1 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CBlogRelUser.php @@ -0,0 +1,115 @@ +cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set blogId + * + * @param integer $blogId + * @return CBlogRelUser + */ + public function setBlogId($blogId) + { + $this->blogId = $blogId; + + return $this; + } + + /** + * Get blogId + * + * @return integer + */ + public function getBlogId() + { + return $this->blogId; + } + + /** + * Set userId + * + * @param integer $userId + * @return CBlogRelUser + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CBlogTask.php b/src/Chamilo/CourseBundle/Entity/CBlogTask.php new file mode 100644 index 0000000000..8ee358cc16 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CBlogTask.php @@ -0,0 +1,235 @@ +blogId = $blogId; + + return $this; + } + + /** + * Get blogId + * + * @return integer + */ + public function getBlogId() + { + return $this->blogId; + } + + /** + * Set title + * + * @param string $title + * @return CBlogTask + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set description + * + * @param string $description + * @return CBlogTask + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set color + * + * @param string $color + * @return CBlogTask + */ + public function setColor($color) + { + $this->color = $color; + + return $this; + } + + /** + * Get color + * + * @return string + */ + public function getColor() + { + return $this->color; + } + + /** + * Set systemTask + * + * @param boolean $systemTask + * @return CBlogTask + */ + public function setSystemTask($systemTask) + { + $this->systemTask = $systemTask; + + return $this; + } + + /** + * Get systemTask + * + * @return boolean + */ + public function getSystemTask() + { + return $this->systemTask; + } + + /** + * Set taskId + * + * @param integer $taskId + * @return CBlogTask + */ + public function setTaskId($taskId) + { + $this->taskId = $taskId; + + return $this; + } + + /** + * Get taskId + * + * @return integer + */ + public function getTaskId() + { + return $this->taskId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CBlogTask + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CBlogTaskRelUser.php b/src/Chamilo/CourseBundle/Entity/CBlogTaskRelUser.php new file mode 100644 index 0000000000..63080b0778 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CBlogTaskRelUser.php @@ -0,0 +1,174 @@ +targetDate = $targetDate; + + return $this; + } + + /** + * Get targetDate + * + * @return \DateTime + */ + public function getTargetDate() + { + return $this->targetDate; + } + + /** + * Set cId + * + * @param integer $cId + * @return CBlogTaskRelUser + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set blogId + * + * @param integer $blogId + * @return CBlogTaskRelUser + */ + public function setBlogId($blogId) + { + $this->blogId = $blogId; + + return $this; + } + + /** + * Get blogId + * + * @return integer + */ + public function getBlogId() + { + return $this->blogId; + } + + /** + * Set userId + * + * @param integer $userId + * @return CBlogTaskRelUser + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set taskId + * + * @param integer $taskId + * @return CBlogTaskRelUser + */ + public function setTaskId($taskId) + { + $this->taskId = $taskId; + + return $this; + } + + /** + * Get taskId + * + * @return integer + */ + public function getTaskId() + { + return $this->taskId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CCalendarEvent.php b/src/Chamilo/CourseBundle/Entity/CCalendarEvent.php new file mode 100644 index 0000000000..31341b8900 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CCalendarEvent.php @@ -0,0 +1,292 @@ +title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set content + * + * @param string $content + * @return CCalendarEvent + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Set startDate + * + * @param \DateTime $startDate + * @return CCalendarEvent + */ + public function setStartDate($startDate) + { + $this->startDate = $startDate; + + return $this; + } + + /** + * Get startDate + * + * @return \DateTime + */ + public function getStartDate() + { + return $this->startDate; + } + + /** + * Set endDate + * + * @param \DateTime $endDate + * @return CCalendarEvent + */ + public function setEndDate($endDate) + { + $this->endDate = $endDate; + + return $this; + } + + /** + * Get endDate + * + * @return \DateTime + */ + public function getEndDate() + { + return $this->endDate; + } + + /** + * Set parentEventId + * + * @param integer $parentEventId + * @return CCalendarEvent + */ + public function setParentEventId($parentEventId) + { + $this->parentEventId = $parentEventId; + + return $this; + } + + /** + * Get parentEventId + * + * @return integer + */ + public function getParentEventId() + { + return $this->parentEventId; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CCalendarEvent + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set allDay + * + * @param integer $allDay + * @return CCalendarEvent + */ + public function setAllDay($allDay) + { + $this->allDay = $allDay; + + return $this; + } + + /** + * Get allDay + * + * @return integer + */ + public function getAllDay() + { + return $this->allDay; + } + + /** + * Set id + * + * @param integer $id + * @return CCalendarEvent + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CCalendarEvent + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CCalendarEventAttachment.php b/src/Chamilo/CourseBundle/Entity/CCalendarEventAttachment.php new file mode 100644 index 0000000000..751d998007 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CCalendarEventAttachment.php @@ -0,0 +1,234 @@ +path = $path; + + return $this; + } + + /** + * Get path + * + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Set comment + * + * @param string $comment + * @return CCalendarEventAttachment + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set size + * + * @param integer $size + * @return CCalendarEventAttachment + */ + public function setSize($size) + { + $this->size = $size; + + return $this; + } + + /** + * Get size + * + * @return integer + */ + public function getSize() + { + return $this->size; + } + + /** + * Set agendaId + * + * @param integer $agendaId + * @return CCalendarEventAttachment + */ + public function setAgendaId($agendaId) + { + $this->agendaId = $agendaId; + + return $this; + } + + /** + * Get agendaId + * + * @return integer + */ + public function getAgendaId() + { + return $this->agendaId; + } + + /** + * Set filename + * + * @param string $filename + * @return CCalendarEventAttachment + */ + public function setFilename($filename) + { + $this->filename = $filename; + + return $this; + } + + /** + * Get filename + * + * @return string + */ + public function getFilename() + { + return $this->filename; + } + + /** + * Set id + * + * @param integer $id + * @return CCalendarEventAttachment + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CCalendarEventAttachment + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CCalendarEventRepeat.php b/src/Chamilo/CourseBundle/Entity/CCalendarEventRepeat.php new file mode 100644 index 0000000000..e4db8d6e35 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CCalendarEventRepeat.php @@ -0,0 +1,204 @@ +calType = $calType; + + return $this; + } + + /** + * Get calType + * + * @return string + */ + public function getCalType() + { + return $this->calType; + } + + /** + * Set calEnd + * + * @param integer $calEnd + * @return CCalendarEventRepeat + */ + public function setCalEnd($calEnd) + { + $this->calEnd = $calEnd; + + return $this; + } + + /** + * Get calEnd + * + * @return integer + */ + public function getCalEnd() + { + return $this->calEnd; + } + + /** + * Set calFrequency + * + * @param integer $calFrequency + * @return CCalendarEventRepeat + */ + public function setCalFrequency($calFrequency) + { + $this->calFrequency = $calFrequency; + + return $this; + } + + /** + * Get calFrequency + * + * @return integer + */ + public function getCalFrequency() + { + return $this->calFrequency; + } + + /** + * Set calDays + * + * @param string $calDays + * @return CCalendarEventRepeat + */ + public function setCalDays($calDays) + { + $this->calDays = $calDays; + + return $this; + } + + /** + * Get calDays + * + * @return string + */ + public function getCalDays() + { + return $this->calDays; + } + + /** + * Set cId + * + * @param integer $cId + * @return CCalendarEventRepeat + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set calId + * + * @param integer $calId + * @return CCalendarEventRepeat + */ + public function setCalId($calId) + { + $this->calId = $calId; + + return $this; + } + + /** + * Get calId + * + * @return integer + */ + public function getCalId() + { + return $this->calId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CCalendarEventRepeatNot.php b/src/Chamilo/CourseBundle/Entity/CCalendarEventRepeatNot.php new file mode 100644 index 0000000000..c82242b27e --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CCalendarEventRepeatNot.php @@ -0,0 +1,118 @@ +cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set calId + * + * @param integer $calId + * @return CCalendarEventRepeatNot + */ + public function setCalId($calId) + { + $this->calId = $calId; + + return $this; + } + + /** + * Get calId + * + * @return integer + */ + public function getCalId() + { + return $this->calId; + } + + /** + * Set calDate + * + * @param integer $calDate + * @return CCalendarEventRepeatNot + */ + public function setCalDate($calDate) + { + $this->calDate = $calDate; + + return $this; + } + + /** + * Get calDate + * + * @return integer + */ + public function getCalDate() + { + return $this->calDate; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CChatConnected.php b/src/Chamilo/CourseBundle/Entity/CChatConnected.php new file mode 100644 index 0000000000..20386cc25b --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CChatConnected.php @@ -0,0 +1,211 @@ +sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set toGroupId + * + * @param integer $toGroupId + * @return CChatConnected + */ + public function setToGroupId($toGroupId) + { + $this->toGroupId = $toGroupId; + + return $this; + } + + /** + * Get toGroupId + * + * @return integer + */ + public function getToGroupId() + { + return $this->toGroupId; + } + + /** + * Set id + * + * @param integer $id + * @return CChatConnected + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CChatConnected + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set userId + * + * @param integer $userId + * @return CChatConnected + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set lastConnection + * + * @param \DateTime $lastConnection + * @return CChatConnected + */ + public function setLastConnection($lastConnection) + { + $this->lastConnection = $lastConnection; + + return $this; + } + + /** + * Get lastConnection + * + * @return \DateTime + */ + public function getLastConnection() + { + return $this->lastConnection; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CCourseDescription.php b/src/Chamilo/CourseBundle/Entity/CCourseDescription.php new file mode 100644 index 0000000000..b51b4791a5 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CCourseDescription.php @@ -0,0 +1,235 @@ +title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set content + * + * @param string $content + * @return CCourseDescription + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CCourseDescription + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set descriptionType + * + * @param boolean $descriptionType + * @return CCourseDescription + */ + public function setDescriptionType($descriptionType) + { + $this->descriptionType = $descriptionType; + + return $this; + } + + /** + * Get descriptionType + * + * @return boolean + */ + public function getDescriptionType() + { + return $this->descriptionType; + } + + /** + * Set progress + * + * @param integer $progress + * @return CCourseDescription + */ + public function setProgress($progress) + { + $this->progress = $progress; + + return $this; + } + + /** + * Get progress + * + * @return integer + */ + public function getProgress() + { + return $this->progress; + } + + /** + * Set id + * + * @param integer $id + * @return CCourseDescription + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CCourseDescription + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CCourseSetting.php b/src/Chamilo/CourseBundle/Entity/CCourseSetting.php new file mode 100644 index 0000000000..334f5bf892 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CCourseSetting.php @@ -0,0 +1,324 @@ +variable = $variable; + + return $this; + } + + /** + * Get variable + * + * @return string + */ + public function getVariable() + { + return $this->variable; + } + + /** + * Set subkey + * + * @param string $subkey + * @return CCourseSetting + */ + public function setSubkey($subkey) + { + $this->subkey = $subkey; + + return $this; + } + + /** + * Get subkey + * + * @return string + */ + public function getSubkey() + { + return $this->subkey; + } + + /** + * Set type + * + * @param string $type + * @return CCourseSetting + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set category + * + * @param string $category + * @return CCourseSetting + */ + public function setCategory($category) + { + $this->category = $category; + + return $this; + } + + /** + * Get category + * + * @return string + */ + public function getCategory() + { + return $this->category; + } + + /** + * Set value + * + * @param string $value + * @return CCourseSetting + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Set title + * + * @param string $title + * @return CCourseSetting + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set comment + * + * @param string $comment + * @return CCourseSetting + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set subkeytext + * + * @param string $subkeytext + * @return CCourseSetting + */ + public function setSubkeytext($subkeytext) + { + $this->subkeytext = $subkeytext; + + return $this; + } + + /** + * Get subkeytext + * + * @return string + */ + public function getSubkeytext() + { + return $this->subkeytext; + } + + /** + * Set id + * + * @param integer $id + * @return CCourseSetting + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CCourseSetting + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CDocument.php b/src/Chamilo/CourseBundle/Entity/CDocument.php new file mode 100644 index 0000000000..2a7638c187 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CDocument.php @@ -0,0 +1,294 @@ +path = $path; + + return $this; + } + + /** + * Get path + * + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Set comment + * + * @param string $comment + * @return CDocument + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set title + * + * @param string $title + * @return CDocument + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set filetype + * + * @param string $filetype + * @return CDocument + */ + public function setFiletype($filetype) + { + $this->filetype = $filetype; + + return $this; + } + + /** + * Get filetype + * + * @return string + */ + public function getFiletype() + { + return $this->filetype; + } + + /** + * Set size + * + * @param integer $size + * @return CDocument + */ + public function setSize($size) + { + $this->size = $size; + + return $this; + } + + /** + * Get size + * + * @return integer + */ + public function getSize() + { + return $this->size; + } + + /** + * Set readonly + * + * @param boolean $readonly + * @return CDocument + */ + public function setReadonly($readonly) + { + $this->readonly = $readonly; + + return $this; + } + + /** + * Get readonly + * + * @return boolean + */ + public function getReadonly() + { + return $this->readonly; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CDocument + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set id + * + * @param integer $id + * @return CDocument + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CDocument + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CDropboxCategory.php b/src/Chamilo/CourseBundle/Entity/CDropboxCategory.php new file mode 100644 index 0000000000..83fc08bbc3 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CDropboxCategory.php @@ -0,0 +1,235 @@ +catName = $catName; + + return $this; + } + + /** + * Get catName + * + * @return string + */ + public function getCatName() + { + return $this->catName; + } + + /** + * Set received + * + * @param boolean $received + * @return CDropboxCategory + */ + public function setReceived($received) + { + $this->received = $received; + + return $this; + } + + /** + * Get received + * + * @return boolean + */ + public function getReceived() + { + return $this->received; + } + + /** + * Set sent + * + * @param boolean $sent + * @return CDropboxCategory + */ + public function setSent($sent) + { + $this->sent = $sent; + + return $this; + } + + /** + * Get sent + * + * @return boolean + */ + public function getSent() + { + return $this->sent; + } + + /** + * Set userId + * + * @param integer $userId + * @return CDropboxCategory + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CDropboxCategory + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set catId + * + * @param integer $catId + * @return CDropboxCategory + */ + public function setCatId($catId) + { + $this->catId = $catId; + + return $this; + } + + /** + * Get catId + * + * @return integer + */ + public function getCatId() + { + return $this->catId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CDropboxCategory + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CDropboxFeedback.php b/src/Chamilo/CourseBundle/Entity/CDropboxFeedback.php new file mode 100644 index 0000000000..2c4aba1bde --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CDropboxFeedback.php @@ -0,0 +1,205 @@ +fileId = $fileId; + + return $this; + } + + /** + * Get fileId + * + * @return integer + */ + public function getFileId() + { + return $this->fileId; + } + + /** + * Set authorUserId + * + * @param integer $authorUserId + * @return CDropboxFeedback + */ + public function setAuthorUserId($authorUserId) + { + $this->authorUserId = $authorUserId; + + return $this; + } + + /** + * Get authorUserId + * + * @return integer + */ + public function getAuthorUserId() + { + return $this->authorUserId; + } + + /** + * Set feedback + * + * @param string $feedback + * @return CDropboxFeedback + */ + public function setFeedback($feedback) + { + $this->feedback = $feedback; + + return $this; + } + + /** + * Get feedback + * + * @return string + */ + public function getFeedback() + { + return $this->feedback; + } + + /** + * Set feedbackDate + * + * @param \DateTime $feedbackDate + * @return CDropboxFeedback + */ + public function setFeedbackDate($feedbackDate) + { + $this->feedbackDate = $feedbackDate; + + return $this; + } + + /** + * Get feedbackDate + * + * @return \DateTime + */ + public function getFeedbackDate() + { + return $this->feedbackDate; + } + + /** + * Set feedbackId + * + * @param integer $feedbackId + * @return CDropboxFeedback + */ + public function setFeedbackId($feedbackId) + { + $this->feedbackId = $feedbackId; + + return $this; + } + + /** + * Get feedbackId + * + * @return integer + */ + public function getFeedbackId() + { + return $this->feedbackId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CDropboxFeedback + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CDropboxFile.php b/src/Chamilo/CourseBundle/Entity/CDropboxFile.php new file mode 100644 index 0000000000..b2f5bf86d2 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CDropboxFile.php @@ -0,0 +1,384 @@ +uploaderId = $uploaderId; + + return $this; + } + + /** + * Get uploaderId + * + * @return integer + */ + public function getUploaderId() + { + return $this->uploaderId; + } + + /** + * Set filename + * + * @param string $filename + * @return CDropboxFile + */ + public function setFilename($filename) + { + $this->filename = $filename; + + return $this; + } + + /** + * Get filename + * + * @return string + */ + public function getFilename() + { + return $this->filename; + } + + /** + * Set filesize + * + * @param integer $filesize + * @return CDropboxFile + */ + public function setFilesize($filesize) + { + $this->filesize = $filesize; + + return $this; + } + + /** + * Get filesize + * + * @return integer + */ + public function getFilesize() + { + return $this->filesize; + } + + /** + * Set title + * + * @param string $title + * @return CDropboxFile + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set description + * + * @param string $description + * @return CDropboxFile + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set author + * + * @param string $author + * @return CDropboxFile + */ + public function setAuthor($author) + { + $this->author = $author; + + return $this; + } + + /** + * Get author + * + * @return string + */ + public function getAuthor() + { + return $this->author; + } + + /** + * Set uploadDate + * + * @param \DateTime $uploadDate + * @return CDropboxFile + */ + public function setUploadDate($uploadDate) + { + $this->uploadDate = $uploadDate; + + return $this; + } + + /** + * Get uploadDate + * + * @return \DateTime + */ + public function getUploadDate() + { + return $this->uploadDate; + } + + /** + * Set lastUploadDate + * + * @param \DateTime $lastUploadDate + * @return CDropboxFile + */ + public function setLastUploadDate($lastUploadDate) + { + $this->lastUploadDate = $lastUploadDate; + + return $this; + } + + /** + * Get lastUploadDate + * + * @return \DateTime + */ + public function getLastUploadDate() + { + return $this->lastUploadDate; + } + + /** + * Set catId + * + * @param integer $catId + * @return CDropboxFile + */ + public function setCatId($catId) + { + $this->catId = $catId; + + return $this; + } + + /** + * Get catId + * + * @return integer + */ + public function getCatId() + { + return $this->catId; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CDropboxFile + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set id + * + * @param integer $id + * @return CDropboxFile + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CDropboxFile + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CDropboxPerson.php b/src/Chamilo/CourseBundle/Entity/CDropboxPerson.php new file mode 100644 index 0000000000..d060fd1097 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CDropboxPerson.php @@ -0,0 +1,115 @@ +cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set fileId + * + * @param integer $fileId + * @return CDropboxPerson + */ + public function setFileId($fileId) + { + $this->fileId = $fileId; + + return $this; + } + + /** + * Get fileId + * + * @return integer + */ + public function getFileId() + { + return $this->fileId; + } + + /** + * Set userId + * + * @param integer $userId + * @return CDropboxPerson + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CDropboxPost.php b/src/Chamilo/CourseBundle/Entity/CDropboxPost.php new file mode 100644 index 0000000000..7676b6e7a1 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CDropboxPost.php @@ -0,0 +1,235 @@ +feedbackDate = $feedbackDate; + + return $this; + } + + /** + * Get feedbackDate + * + * @return \DateTime + */ + public function getFeedbackDate() + { + return $this->feedbackDate; + } + + /** + * Set feedback + * + * @param string $feedback + * @return CDropboxPost + */ + public function setFeedback($feedback) + { + $this->feedback = $feedback; + + return $this; + } + + /** + * Get feedback + * + * @return string + */ + public function getFeedback() + { + return $this->feedback; + } + + /** + * Set catId + * + * @param integer $catId + * @return CDropboxPost + */ + public function setCatId($catId) + { + $this->catId = $catId; + + return $this; + } + + /** + * Get catId + * + * @return integer + */ + public function getCatId() + { + return $this->catId; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CDropboxPost + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CDropboxPost + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set fileId + * + * @param integer $fileId + * @return CDropboxPost + */ + public function setFileId($fileId) + { + $this->fileId = $fileId; + + return $this; + } + + /** + * Get fileId + * + * @return integer + */ + public function getFileId() + { + return $this->fileId; + } + + /** + * Set destUserId + * + * @param integer $destUserId + * @return CDropboxPost + */ + public function setDestUserId($destUserId) + { + $this->destUserId = $destUserId; + + return $this; + } + + /** + * Get destUserId + * + * @return integer + */ + public function getDestUserId() + { + return $this->destUserId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CForumAttachment.php b/src/Chamilo/CourseBundle/Entity/CForumAttachment.php new file mode 100644 index 0000000000..9f5f04ad1f --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CForumAttachment.php @@ -0,0 +1,234 @@ +path = $path; + + return $this; + } + + /** + * Get path + * + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Set comment + * + * @param string $comment + * @return CForumAttachment + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set size + * + * @param integer $size + * @return CForumAttachment + */ + public function setSize($size) + { + $this->size = $size; + + return $this; + } + + /** + * Get size + * + * @return integer + */ + public function getSize() + { + return $this->size; + } + + /** + * Set postId + * + * @param integer $postId + * @return CForumAttachment + */ + public function setPostId($postId) + { + $this->postId = $postId; + + return $this; + } + + /** + * Get postId + * + * @return integer + */ + public function getPostId() + { + return $this->postId; + } + + /** + * Set filename + * + * @param string $filename + * @return CForumAttachment + */ + public function setFilename($filename) + { + $this->filename = $filename; + + return $this; + } + + /** + * Get filename + * + * @return string + */ + public function getFilename() + { + return $this->filename; + } + + /** + * Set id + * + * @param integer $id + * @return CForumAttachment + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CForumAttachment + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CForumCategory.php b/src/Chamilo/CourseBundle/Entity/CForumCategory.php new file mode 100644 index 0000000000..e5e400961a --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CForumCategory.php @@ -0,0 +1,234 @@ +catTitle = $catTitle; + + return $this; + } + + /** + * Get catTitle + * + * @return string + */ + public function getCatTitle() + { + return $this->catTitle; + } + + /** + * Set catComment + * + * @param string $catComment + * @return CForumCategory + */ + public function setCatComment($catComment) + { + $this->catComment = $catComment; + + return $this; + } + + /** + * Get catComment + * + * @return string + */ + public function getCatComment() + { + return $this->catComment; + } + + /** + * Set catOrder + * + * @param integer $catOrder + * @return CForumCategory + */ + public function setCatOrder($catOrder) + { + $this->catOrder = $catOrder; + + return $this; + } + + /** + * Get catOrder + * + * @return integer + */ + public function getCatOrder() + { + return $this->catOrder; + } + + /** + * Set locked + * + * @param integer $locked + * @return CForumCategory + */ + public function setLocked($locked) + { + $this->locked = $locked; + + return $this; + } + + /** + * Get locked + * + * @return integer + */ + public function getLocked() + { + return $this->locked; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CForumCategory + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set catId + * + * @param integer $catId + * @return CForumCategory + */ + public function setCatId($catId) + { + $this->catId = $catId; + + return $this; + } + + /** + * Get catId + * + * @return integer + */ + public function getCatId() + { + return $this->catId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CForumCategory + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CForumForum.php b/src/Chamilo/CourseBundle/Entity/CForumForum.php new file mode 100644 index 0000000000..20debbbd09 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CForumForum.php @@ -0,0 +1,684 @@ +forumTitle = $forumTitle; + + return $this; + } + + /** + * Get forumTitle + * + * @return string + */ + public function getForumTitle() + { + return $this->forumTitle; + } + + /** + * Set forumComment + * + * @param string $forumComment + * @return CForumForum + */ + public function setForumComment($forumComment) + { + $this->forumComment = $forumComment; + + return $this; + } + + /** + * Get forumComment + * + * @return string + */ + public function getForumComment() + { + return $this->forumComment; + } + + /** + * Set forumThreads + * + * @param integer $forumThreads + * @return CForumForum + */ + public function setForumThreads($forumThreads) + { + $this->forumThreads = $forumThreads; + + return $this; + } + + /** + * Get forumThreads + * + * @return integer + */ + public function getForumThreads() + { + return $this->forumThreads; + } + + /** + * Set forumPosts + * + * @param integer $forumPosts + * @return CForumForum + */ + public function setForumPosts($forumPosts) + { + $this->forumPosts = $forumPosts; + + return $this; + } + + /** + * Get forumPosts + * + * @return integer + */ + public function getForumPosts() + { + return $this->forumPosts; + } + + /** + * Set forumLastPost + * + * @param integer $forumLastPost + * @return CForumForum + */ + public function setForumLastPost($forumLastPost) + { + $this->forumLastPost = $forumLastPost; + + return $this; + } + + /** + * Get forumLastPost + * + * @return integer + */ + public function getForumLastPost() + { + return $this->forumLastPost; + } + + /** + * Set forumCategory + * + * @param integer $forumCategory + * @return CForumForum + */ + public function setForumCategory($forumCategory) + { + $this->forumCategory = $forumCategory; + + return $this; + } + + /** + * Get forumCategory + * + * @return integer + */ + public function getForumCategory() + { + return $this->forumCategory; + } + + /** + * Set allowAnonymous + * + * @param integer $allowAnonymous + * @return CForumForum + */ + public function setAllowAnonymous($allowAnonymous) + { + $this->allowAnonymous = $allowAnonymous; + + return $this; + } + + /** + * Get allowAnonymous + * + * @return integer + */ + public function getAllowAnonymous() + { + return $this->allowAnonymous; + } + + /** + * Set allowEdit + * + * @param integer $allowEdit + * @return CForumForum + */ + public function setAllowEdit($allowEdit) + { + $this->allowEdit = $allowEdit; + + return $this; + } + + /** + * Get allowEdit + * + * @return integer + */ + public function getAllowEdit() + { + return $this->allowEdit; + } + + /** + * Set approvalDirectPost + * + * @param string $approvalDirectPost + * @return CForumForum + */ + public function setApprovalDirectPost($approvalDirectPost) + { + $this->approvalDirectPost = $approvalDirectPost; + + return $this; + } + + /** + * Get approvalDirectPost + * + * @return string + */ + public function getApprovalDirectPost() + { + return $this->approvalDirectPost; + } + + /** + * Set allowAttachments + * + * @param integer $allowAttachments + * @return CForumForum + */ + public function setAllowAttachments($allowAttachments) + { + $this->allowAttachments = $allowAttachments; + + return $this; + } + + /** + * Get allowAttachments + * + * @return integer + */ + public function getAllowAttachments() + { + return $this->allowAttachments; + } + + /** + * Set allowNewThreads + * + * @param integer $allowNewThreads + * @return CForumForum + */ + public function setAllowNewThreads($allowNewThreads) + { + $this->allowNewThreads = $allowNewThreads; + + return $this; + } + + /** + * Get allowNewThreads + * + * @return integer + */ + public function getAllowNewThreads() + { + return $this->allowNewThreads; + } + + /** + * Set defaultView + * + * @param string $defaultView + * @return CForumForum + */ + public function setDefaultView($defaultView) + { + $this->defaultView = $defaultView; + + return $this; + } + + /** + * Get defaultView + * + * @return string + */ + public function getDefaultView() + { + return $this->defaultView; + } + + /** + * Set forumOfGroup + * + * @param string $forumOfGroup + * @return CForumForum + */ + public function setForumOfGroup($forumOfGroup) + { + $this->forumOfGroup = $forumOfGroup; + + return $this; + } + + /** + * Get forumOfGroup + * + * @return string + */ + public function getForumOfGroup() + { + return $this->forumOfGroup; + } + + /** + * Set forumGroupPublicPrivate + * + * @param string $forumGroupPublicPrivate + * @return CForumForum + */ + public function setForumGroupPublicPrivate($forumGroupPublicPrivate) + { + $this->forumGroupPublicPrivate = $forumGroupPublicPrivate; + + return $this; + } + + /** + * Get forumGroupPublicPrivate + * + * @return string + */ + public function getForumGroupPublicPrivate() + { + return $this->forumGroupPublicPrivate; + } + + /** + * Set forumOrder + * + * @param integer $forumOrder + * @return CForumForum + */ + public function setForumOrder($forumOrder) + { + $this->forumOrder = $forumOrder; + + return $this; + } + + /** + * Get forumOrder + * + * @return integer + */ + public function getForumOrder() + { + return $this->forumOrder; + } + + /** + * Set locked + * + * @param integer $locked + * @return CForumForum + */ + public function setLocked($locked) + { + $this->locked = $locked; + + return $this; + } + + /** + * Get locked + * + * @return integer + */ + public function getLocked() + { + return $this->locked; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CForumForum + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set forumImage + * + * @param string $forumImage + * @return CForumForum + */ + public function setForumImage($forumImage) + { + $this->forumImage = $forumImage; + + return $this; + } + + /** + * Get forumImage + * + * @return string + */ + public function getForumImage() + { + return $this->forumImage; + } + + /** + * Set startTime + * + * @param \DateTime $startTime + * @return CForumForum + */ + public function setStartTime($startTime) + { + $this->startTime = $startTime; + + return $this; + } + + /** + * Get startTime + * + * @return \DateTime + */ + public function getStartTime() + { + return $this->startTime; + } + + /** + * Set endTime + * + * @param \DateTime $endTime + * @return CForumForum + */ + public function setEndTime($endTime) + { + $this->endTime = $endTime; + + return $this; + } + + /** + * Get endTime + * + * @return \DateTime + */ + public function getEndTime() + { + return $this->endTime; + } + + /** + * Set forumId + * + * @param integer $forumId + * @return CForumForum + */ + public function setForumId($forumId) + { + $this->forumId = $forumId; + + return $this; + } + + /** + * Get forumId + * + * @return integer + */ + public function getForumId() + { + return $this->forumId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CForumForum + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CForumMailcue.php b/src/Chamilo/CourseBundle/Entity/CForumMailcue.php new file mode 100644 index 0000000000..e7f87780f3 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CForumMailcue.php @@ -0,0 +1,175 @@ +id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CForumMailcue + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set threadId + * + * @param integer $threadId + * @return CForumMailcue + */ + public function setThreadId($threadId) + { + $this->threadId = $threadId; + + return $this; + } + + /** + * Get threadId + * + * @return integer + */ + public function getThreadId() + { + return $this->threadId; + } + + /** + * Set userId + * + * @param integer $userId + * @return CForumMailcue + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set postId + * + * @param integer $postId + * @return CForumMailcue + */ + public function setPostId($postId) + { + $this->postId = $postId; + + return $this; + } + + /** + * Get postId + * + * @return integer + */ + public function getPostId() + { + return $this->postId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CForumNotification.php b/src/Chamilo/CourseBundle/Entity/CForumNotification.php new file mode 100644 index 0000000000..b76e5955cb --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CForumNotification.php @@ -0,0 +1,204 @@ +id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CForumNotification + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set userId + * + * @param integer $userId + * @return CForumNotification + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set forumId + * + * @param integer $forumId + * @return CForumNotification + */ + public function setForumId($forumId) + { + $this->forumId = $forumId; + + return $this; + } + + /** + * Get forumId + * + * @return integer + */ + public function getForumId() + { + return $this->forumId; + } + + /** + * Set threadId + * + * @param integer $threadId + * @return CForumNotification + */ + public function setThreadId($threadId) + { + $this->threadId = $threadId; + + return $this; + } + + /** + * Get threadId + * + * @return integer + */ + public function getThreadId() + { + return $this->threadId; + } + + /** + * Set postId + * + * @param integer $postId + * @return CForumNotification + */ + public function setPostId($postId) + { + $this->postId = $postId; + + return $this; + } + + /** + * Get postId + * + * @return integer + */ + public function getPostId() + { + return $this->postId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CForumPost.php b/src/Chamilo/CourseBundle/Entity/CForumPost.php new file mode 100644 index 0000000000..ab94072ac4 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CForumPost.php @@ -0,0 +1,384 @@ +postTitle = $postTitle; + + return $this; + } + + /** + * Get postTitle + * + * @return string + */ + public function getPostTitle() + { + return $this->postTitle; + } + + /** + * Set postText + * + * @param string $postText + * @return CForumPost + */ + public function setPostText($postText) + { + $this->postText = $postText; + + return $this; + } + + /** + * Get postText + * + * @return string + */ + public function getPostText() + { + return $this->postText; + } + + /** + * Set threadId + * + * @param integer $threadId + * @return CForumPost + */ + public function setThreadId($threadId) + { + $this->threadId = $threadId; + + return $this; + } + + /** + * Get threadId + * + * @return integer + */ + public function getThreadId() + { + return $this->threadId; + } + + /** + * Set forumId + * + * @param integer $forumId + * @return CForumPost + */ + public function setForumId($forumId) + { + $this->forumId = $forumId; + + return $this; + } + + /** + * Get forumId + * + * @return integer + */ + public function getForumId() + { + return $this->forumId; + } + + /** + * Set posterId + * + * @param integer $posterId + * @return CForumPost + */ + public function setPosterId($posterId) + { + $this->posterId = $posterId; + + return $this; + } + + /** + * Get posterId + * + * @return integer + */ + public function getPosterId() + { + return $this->posterId; + } + + /** + * Set posterName + * + * @param string $posterName + * @return CForumPost + */ + public function setPosterName($posterName) + { + $this->posterName = $posterName; + + return $this; + } + + /** + * Get posterName + * + * @return string + */ + public function getPosterName() + { + return $this->posterName; + } + + /** + * Set postDate + * + * @param \DateTime $postDate + * @return CForumPost + */ + public function setPostDate($postDate) + { + $this->postDate = $postDate; + + return $this; + } + + /** + * Get postDate + * + * @return \DateTime + */ + public function getPostDate() + { + return $this->postDate; + } + + /** + * Set postNotification + * + * @param boolean $postNotification + * @return CForumPost + */ + public function setPostNotification($postNotification) + { + $this->postNotification = $postNotification; + + return $this; + } + + /** + * Get postNotification + * + * @return boolean + */ + public function getPostNotification() + { + return $this->postNotification; + } + + /** + * Set postParentId + * + * @param integer $postParentId + * @return CForumPost + */ + public function setPostParentId($postParentId) + { + $this->postParentId = $postParentId; + + return $this; + } + + /** + * Get postParentId + * + * @return integer + */ + public function getPostParentId() + { + return $this->postParentId; + } + + /** + * Set visible + * + * @param boolean $visible + * @return CForumPost + */ + public function setVisible($visible) + { + $this->visible = $visible; + + return $this; + } + + /** + * Get visible + * + * @return boolean + */ + public function getVisible() + { + return $this->visible; + } + + /** + * Set postId + * + * @param integer $postId + * @return CForumPost + */ + public function setPostId($postId) + { + $this->postId = $postId; + + return $this; + } + + /** + * Get postId + * + * @return integer + */ + public function getPostId() + { + return $this->postId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CForumPost + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CForumThread.php b/src/Chamilo/CourseBundle/Entity/CForumThread.php new file mode 100644 index 0000000000..cbdac8fc4a --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CForumThread.php @@ -0,0 +1,533 @@ +threadTitle = $threadTitle; + + return $this; + } + + /** + * Get threadTitle + * + * @return string + */ + public function getThreadTitle() + { + return $this->threadTitle; + } + + /** + * Set forumId + * + * @param integer $forumId + * @return CForumThread + */ + public function setForumId($forumId) + { + $this->forumId = $forumId; + + return $this; + } + + /** + * Get forumId + * + * @return integer + */ + public function getForumId() + { + return $this->forumId; + } + + /** + * Set threadReplies + * + * @param integer $threadReplies + * @return CForumThread + */ + public function setThreadReplies($threadReplies) + { + $this->threadReplies = $threadReplies; + + return $this; + } + + /** + * Get threadReplies + * + * @return integer + */ + public function getThreadReplies() + { + return $this->threadReplies; + } + + /** + * Set threadPosterId + * + * @param integer $threadPosterId + * @return CForumThread + */ + public function setThreadPosterId($threadPosterId) + { + $this->threadPosterId = $threadPosterId; + + return $this; + } + + /** + * Get threadPosterId + * + * @return integer + */ + public function getThreadPosterId() + { + return $this->threadPosterId; + } + + /** + * Set threadPosterName + * + * @param string $threadPosterName + * @return CForumThread + */ + public function setThreadPosterName($threadPosterName) + { + $this->threadPosterName = $threadPosterName; + + return $this; + } + + /** + * Get threadPosterName + * + * @return string + */ + public function getThreadPosterName() + { + return $this->threadPosterName; + } + + /** + * Set threadViews + * + * @param integer $threadViews + * @return CForumThread + */ + public function setThreadViews($threadViews) + { + $this->threadViews = $threadViews; + + return $this; + } + + /** + * Get threadViews + * + * @return integer + */ + public function getThreadViews() + { + return $this->threadViews; + } + + /** + * Set threadLastPost + * + * @param integer $threadLastPost + * @return CForumThread + */ + public function setThreadLastPost($threadLastPost) + { + $this->threadLastPost = $threadLastPost; + + return $this; + } + + /** + * Get threadLastPost + * + * @return integer + */ + public function getThreadLastPost() + { + return $this->threadLastPost; + } + + /** + * Set threadDate + * + * @param \DateTime $threadDate + * @return CForumThread + */ + public function setThreadDate($threadDate) + { + $this->threadDate = $threadDate; + + return $this; + } + + /** + * Get threadDate + * + * @return \DateTime + */ + public function getThreadDate() + { + return $this->threadDate; + } + + /** + * Set threadSticky + * + * @param boolean $threadSticky + * @return CForumThread + */ + public function setThreadSticky($threadSticky) + { + $this->threadSticky = $threadSticky; + + return $this; + } + + /** + * Get threadSticky + * + * @return boolean + */ + public function getThreadSticky() + { + return $this->threadSticky; + } + + /** + * Set locked + * + * @param integer $locked + * @return CForumThread + */ + public function setLocked($locked) + { + $this->locked = $locked; + + return $this; + } + + /** + * Get locked + * + * @return integer + */ + public function getLocked() + { + return $this->locked; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CForumThread + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set threadTitleQualify + * + * @param string $threadTitleQualify + * @return CForumThread + */ + public function setThreadTitleQualify($threadTitleQualify) + { + $this->threadTitleQualify = $threadTitleQualify; + + return $this; + } + + /** + * Get threadTitleQualify + * + * @return string + */ + public function getThreadTitleQualify() + { + return $this->threadTitleQualify; + } + + /** + * Set threadQualifyMax + * + * @param float $threadQualifyMax + * @return CForumThread + */ + public function setThreadQualifyMax($threadQualifyMax) + { + $this->threadQualifyMax = $threadQualifyMax; + + return $this; + } + + /** + * Get threadQualifyMax + * + * @return float + */ + public function getThreadQualifyMax() + { + return $this->threadQualifyMax; + } + + /** + * Set threadCloseDate + * + * @param \DateTime $threadCloseDate + * @return CForumThread + */ + public function setThreadCloseDate($threadCloseDate) + { + $this->threadCloseDate = $threadCloseDate; + + return $this; + } + + /** + * Get threadCloseDate + * + * @return \DateTime + */ + public function getThreadCloseDate() + { + return $this->threadCloseDate; + } + + /** + * Set threadWeight + * + * @param float $threadWeight + * @return CForumThread + */ + public function setThreadWeight($threadWeight) + { + $this->threadWeight = $threadWeight; + + return $this; + } + + /** + * Get threadWeight + * + * @return float + */ + public function getThreadWeight() + { + return $this->threadWeight; + } + + /** + * Set threadId + * + * @param integer $threadId + * @return CForumThread + */ + public function setThreadId($threadId) + { + $this->threadId = $threadId; + + return $this; + } + + /** + * Get threadId + * + * @return integer + */ + public function getThreadId() + { + return $this->threadId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CForumThread + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CForumThreadQualify.php b/src/Chamilo/CourseBundle/Entity/CForumThreadQualify.php new file mode 100644 index 0000000000..ebc32fd65e --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CForumThreadQualify.php @@ -0,0 +1,264 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set threadId + * + * @param integer $threadId + * @return CForumThreadQualify + */ + public function setThreadId($threadId) + { + $this->threadId = $threadId; + + return $this; + } + + /** + * Get threadId + * + * @return integer + */ + public function getThreadId() + { + return $this->threadId; + } + + /** + * Set qualify + * + * @param float $qualify + * @return CForumThreadQualify + */ + public function setQualify($qualify) + { + $this->qualify = $qualify; + + return $this; + } + + /** + * Get qualify + * + * @return float + */ + public function getQualify() + { + return $this->qualify; + } + + /** + * Set qualifyUserId + * + * @param integer $qualifyUserId + * @return CForumThreadQualify + */ + public function setQualifyUserId($qualifyUserId) + { + $this->qualifyUserId = $qualifyUserId; + + return $this; + } + + /** + * Get qualifyUserId + * + * @return integer + */ + public function getQualifyUserId() + { + return $this->qualifyUserId; + } + + /** + * Set qualifyTime + * + * @param \DateTime $qualifyTime + * @return CForumThreadQualify + */ + public function setQualifyTime($qualifyTime) + { + $this->qualifyTime = $qualifyTime; + + return $this; + } + + /** + * Get qualifyTime + * + * @return \DateTime + */ + public function getQualifyTime() + { + return $this->qualifyTime; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CForumThreadQualify + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set id + * + * @param integer $id + * @return CForumThreadQualify + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CForumThreadQualify + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CForumThreadQualifyLog.php b/src/Chamilo/CourseBundle/Entity/CForumThreadQualifyLog.php new file mode 100644 index 0000000000..27f2cfebdb --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CForumThreadQualifyLog.php @@ -0,0 +1,265 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set threadId + * + * @param integer $threadId + * @return CForumThreadQualifyLog + */ + public function setThreadId($threadId) + { + $this->threadId = $threadId; + + return $this; + } + + /** + * Get threadId + * + * @return integer + */ + public function getThreadId() + { + return $this->threadId; + } + + /** + * Set qualify + * + * @param float $qualify + * @return CForumThreadQualifyLog + */ + public function setQualify($qualify) + { + $this->qualify = $qualify; + + return $this; + } + + /** + * Get qualify + * + * @return float + */ + public function getQualify() + { + return $this->qualify; + } + + /** + * Set qualifyUserId + * + * @param integer $qualifyUserId + * @return CForumThreadQualifyLog + */ + public function setQualifyUserId($qualifyUserId) + { + $this->qualifyUserId = $qualifyUserId; + + return $this; + } + + /** + * Get qualifyUserId + * + * @return integer + */ + public function getQualifyUserId() + { + return $this->qualifyUserId; + } + + /** + * Set qualifyTime + * + * @param \DateTime $qualifyTime + * @return CForumThreadQualifyLog + */ + public function setQualifyTime($qualifyTime) + { + $this->qualifyTime = $qualifyTime; + + return $this; + } + + /** + * Get qualifyTime + * + * @return \DateTime + */ + public function getQualifyTime() + { + return $this->qualifyTime; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CForumThreadQualifyLog + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set id + * + * @param integer $id + * @return CForumThreadQualifyLog + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CForumThreadQualifyLog + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CGlossary.php b/src/Chamilo/CourseBundle/Entity/CGlossary.php new file mode 100644 index 0000000000..9fb763e5d4 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CGlossary.php @@ -0,0 +1,204 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set description + * + * @param string $description + * @return CGlossary + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set displayOrder + * + * @param integer $displayOrder + * @return CGlossary + */ + public function setDisplayOrder($displayOrder) + { + $this->displayOrder = $displayOrder; + + return $this; + } + + /** + * Get displayOrder + * + * @return integer + */ + public function getDisplayOrder() + { + return $this->displayOrder; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CGlossary + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set glossaryId + * + * @param integer $glossaryId + * @return CGlossary + */ + public function setGlossaryId($glossaryId) + { + $this->glossaryId = $glossaryId; + + return $this; + } + + /** + * Get glossaryId + * + * @return integer + */ + public function getGlossaryId() + { + return $this->glossaryId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CGlossary + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CGroupCategory.php b/src/Chamilo/CourseBundle/Entity/CGroupCategory.php new file mode 100644 index 0000000000..828452a260 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CGroupCategory.php @@ -0,0 +1,504 @@ +title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set description + * + * @param string $description + * @return CGroupCategory + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set docState + * + * @param boolean $docState + * @return CGroupCategory + */ + public function setDocState($docState) + { + $this->docState = $docState; + + return $this; + } + + /** + * Get docState + * + * @return boolean + */ + public function getDocState() + { + return $this->docState; + } + + /** + * Set calendarState + * + * @param boolean $calendarState + * @return CGroupCategory + */ + public function setCalendarState($calendarState) + { + $this->calendarState = $calendarState; + + return $this; + } + + /** + * Get calendarState + * + * @return boolean + */ + public function getCalendarState() + { + return $this->calendarState; + } + + /** + * Set workState + * + * @param boolean $workState + * @return CGroupCategory + */ + public function setWorkState($workState) + { + $this->workState = $workState; + + return $this; + } + + /** + * Get workState + * + * @return boolean + */ + public function getWorkState() + { + return $this->workState; + } + + /** + * Set announcementsState + * + * @param boolean $announcementsState + * @return CGroupCategory + */ + public function setAnnouncementsState($announcementsState) + { + $this->announcementsState = $announcementsState; + + return $this; + } + + /** + * Get announcementsState + * + * @return boolean + */ + public function getAnnouncementsState() + { + return $this->announcementsState; + } + + /** + * Set forumState + * + * @param boolean $forumState + * @return CGroupCategory + */ + public function setForumState($forumState) + { + $this->forumState = $forumState; + + return $this; + } + + /** + * Get forumState + * + * @return boolean + */ + public function getForumState() + { + return $this->forumState; + } + + /** + * Set wikiState + * + * @param boolean $wikiState + * @return CGroupCategory + */ + public function setWikiState($wikiState) + { + $this->wikiState = $wikiState; + + return $this; + } + + /** + * Get wikiState + * + * @return boolean + */ + public function getWikiState() + { + return $this->wikiState; + } + + /** + * Set chatState + * + * @param boolean $chatState + * @return CGroupCategory + */ + public function setChatState($chatState) + { + $this->chatState = $chatState; + + return $this; + } + + /** + * Get chatState + * + * @return boolean + */ + public function getChatState() + { + return $this->chatState; + } + + /** + * Set maxStudent + * + * @param integer $maxStudent + * @return CGroupCategory + */ + public function setMaxStudent($maxStudent) + { + $this->maxStudent = $maxStudent; + + return $this; + } + + /** + * Get maxStudent + * + * @return integer + */ + public function getMaxStudent() + { + return $this->maxStudent; + } + + /** + * Set selfRegAllowed + * + * @param boolean $selfRegAllowed + * @return CGroupCategory + */ + public function setSelfRegAllowed($selfRegAllowed) + { + $this->selfRegAllowed = $selfRegAllowed; + + return $this; + } + + /** + * Get selfRegAllowed + * + * @return boolean + */ + public function getSelfRegAllowed() + { + return $this->selfRegAllowed; + } + + /** + * Set selfUnregAllowed + * + * @param boolean $selfUnregAllowed + * @return CGroupCategory + */ + public function setSelfUnregAllowed($selfUnregAllowed) + { + $this->selfUnregAllowed = $selfUnregAllowed; + + return $this; + } + + /** + * Get selfUnregAllowed + * + * @return boolean + */ + public function getSelfUnregAllowed() + { + return $this->selfUnregAllowed; + } + + /** + * Set groupsPerUser + * + * @param integer $groupsPerUser + * @return CGroupCategory + */ + public function setGroupsPerUser($groupsPerUser) + { + $this->groupsPerUser = $groupsPerUser; + + return $this; + } + + /** + * Get groupsPerUser + * + * @return integer + */ + public function getGroupsPerUser() + { + return $this->groupsPerUser; + } + + /** + * Set displayOrder + * + * @param integer $displayOrder + * @return CGroupCategory + */ + public function setDisplayOrder($displayOrder) + { + $this->displayOrder = $displayOrder; + + return $this; + } + + /** + * Get displayOrder + * + * @return integer + */ + public function getDisplayOrder() + { + return $this->displayOrder; + } + + /** + * Set id + * + * @param integer $id + * @return CGroupCategory + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CGroupCategory + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CGroupInfo.php b/src/Chamilo/CourseBundle/Entity/CGroupInfo.php index 7654113e9f..97c24c0c88 100644 --- a/src/Chamilo/CourseBundle/Entity/CGroupInfo.php +++ b/src/Chamilo/CourseBundle/Entity/CGroupInfo.php @@ -1,14 +1,14 @@ items = new ArrayCollection(); - } - - /** - * - * @return ArrayCollection - */ - public function getItems() - { - return $this->items; - } - - /** - * Set cId - * - * @param integer $cId - * - * @return CGroupInfo - */ - public function setCId($cId) - { - $this->cId = $cId; - - return $this; - } - - /** - * Get cId - * - * @return integer - */ - public function getCId() - { - return $this->cId; - } - - /** - * Set iid - * - * @param integer $id - * @return CGroupInfo - */ - public function setIid($iid) - { - $this->iid = $iid; - - return $this; - } - - /** - * Get id - * - * @return integer - */ - public function getIid() - { - return $this->iid; - } - - /** - * Set id + * Set name * - * @param integer $id + * @param string $name * @return CGroupInfo */ - public function setId($id) + public function setName($name) { - $this->id = $id; + $this->name = $name; return $this; } /** - * Get id + * Get name * - * @return integer + * @return string */ - public function getId() + public function getName() { - return $this->id; + return $this->name; } /** - * Set name + * Set status * - * @param string $name + * @param boolean $status * @return CGroupInfo */ - public function setName($name) + public function setStatus($status) { - $this->name = $name; + $this->status = $status; return $this; } /** - * Get name + * Get status * - * @return string + * @return boolean */ - public function getName() + public function getStatus() { - return $this->name; + return $this->status; } /** @@ -582,4 +515,50 @@ class CGroupInfo { return $this->sessionId; } + + /** + * Set id + * + * @param integer $id + * @return CGroupInfo + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CGroupInfo + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } } diff --git a/src/Chamilo/CourseBundle/Entity/CGroupRelTutor.php b/src/Chamilo/CourseBundle/Entity/CGroupRelTutor.php new file mode 100644 index 0000000000..bb25884505 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CGroupRelTutor.php @@ -0,0 +1,144 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set groupId + * + * @param integer $groupId + * @return CGroupRelTutor + */ + public function setGroupId($groupId) + { + $this->groupId = $groupId; + + return $this; + } + + /** + * Get groupId + * + * @return integer + */ + public function getGroupId() + { + return $this->groupId; + } + + /** + * Set id + * + * @param integer $id + * @return CGroupRelTutor + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CGroupRelTutor + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CGroupRelUser.php b/src/Chamilo/CourseBundle/Entity/CGroupRelUser.php new file mode 100644 index 0000000000..09196b5fe0 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CGroupRelUser.php @@ -0,0 +1,204 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set groupId + * + * @param integer $groupId + * @return CGroupRelUser + */ + public function setGroupId($groupId) + { + $this->groupId = $groupId; + + return $this; + } + + /** + * Get groupId + * + * @return integer + */ + public function getGroupId() + { + return $this->groupId; + } + + /** + * Set status + * + * @param integer $status + * @return CGroupRelUser + */ + public function setStatus($status) + { + $this->status = $status; + + return $this; + } + + /** + * Get status + * + * @return integer + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set role + * + * @param string $role + * @return CGroupRelUser + */ + public function setRole($role) + { + $this->role = $role; + + return $this; + } + + /** + * Get role + * + * @return string + */ + public function getRole() + { + return $this->role; + } + + /** + * Set id + * + * @param integer $id + * @return CGroupRelUser + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CGroupRelUser + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CItemProperty.php b/src/Chamilo/CourseBundle/Entity/CItemProperty.php new file mode 100644 index 0000000000..878fae0980 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CItemProperty.php @@ -0,0 +1,474 @@ +tool = $tool; + + return $this; + } + + /** + * Get tool + * + * @return string + */ + public function getTool() + { + return $this->tool; + } + + /** + * Set insertUserId + * + * @param integer $insertUserId + * @return CItemProperty + */ + public function setInsertUserId($insertUserId) + { + $this->insertUserId = $insertUserId; + + return $this; + } + + /** + * Get insertUserId + * + * @return integer + */ + public function getInsertUserId() + { + return $this->insertUserId; + } + + /** + * Set insertDate + * + * @param \DateTime $insertDate + * @return CItemProperty + */ + public function setInsertDate($insertDate) + { + $this->insertDate = $insertDate; + + return $this; + } + + /** + * Get insertDate + * + * @return \DateTime + */ + public function getInsertDate() + { + return $this->insertDate; + } + + /** + * Set lasteditDate + * + * @param \DateTime $lasteditDate + * @return CItemProperty + */ + public function setLasteditDate($lasteditDate) + { + $this->lasteditDate = $lasteditDate; + + return $this; + } + + /** + * Get lasteditDate + * + * @return \DateTime + */ + public function getLasteditDate() + { + return $this->lasteditDate; + } + + /** + * Set ref + * + * @param integer $ref + * @return CItemProperty + */ + public function setRef($ref) + { + $this->ref = $ref; + + return $this; + } + + /** + * Get ref + * + * @return integer + */ + public function getRef() + { + return $this->ref; + } + + /** + * Set lasteditType + * + * @param string $lasteditType + * @return CItemProperty + */ + public function setLasteditType($lasteditType) + { + $this->lasteditType = $lasteditType; + + return $this; + } + + /** + * Get lasteditType + * + * @return string + */ + public function getLasteditType() + { + return $this->lasteditType; + } + + /** + * Set lasteditUserId + * + * @param integer $lasteditUserId + * @return CItemProperty + */ + public function setLasteditUserId($lasteditUserId) + { + $this->lasteditUserId = $lasteditUserId; + + return $this; + } + + /** + * Get lasteditUserId + * + * @return integer + */ + public function getLasteditUserId() + { + return $this->lasteditUserId; + } + + /** + * Set toGroupId + * + * @param integer $toGroupId + * @return CItemProperty + */ + public function setToGroupId($toGroupId) + { + $this->toGroupId = $toGroupId; + + return $this; + } + + /** + * Get toGroupId + * + * @return integer + */ + public function getToGroupId() + { + return $this->toGroupId; + } + + /** + * Set toUserId + * + * @param integer $toUserId + * @return CItemProperty + */ + public function setToUserId($toUserId) + { + $this->toUserId = $toUserId; + + return $this; + } + + /** + * Get toUserId + * + * @return integer + */ + public function getToUserId() + { + return $this->toUserId; + } + + /** + * Set visibility + * + * @param boolean $visibility + * @return CItemProperty + */ + public function setVisibility($visibility) + { + $this->visibility = $visibility; + + return $this; + } + + /** + * Get visibility + * + * @return boolean + */ + public function getVisibility() + { + return $this->visibility; + } + + /** + * Set startVisible + * + * @param \DateTime $startVisible + * @return CItemProperty + */ + public function setStartVisible($startVisible) + { + $this->startVisible = $startVisible; + + return $this; + } + + /** + * Get startVisible + * + * @return \DateTime + */ + public function getStartVisible() + { + return $this->startVisible; + } + + /** + * Set endVisible + * + * @param \DateTime $endVisible + * @return CItemProperty + */ + public function setEndVisible($endVisible) + { + $this->endVisible = $endVisible; + + return $this; + } + + /** + * Get endVisible + * + * @return \DateTime + */ + public function getEndVisible() + { + return $this->endVisible; + } + + /** + * Set idSession + * + * @param integer $idSession + * @return CItemProperty + */ + public function setIdSession($idSession) + { + $this->idSession = $idSession; + + return $this; + } + + /** + * Get idSession + * + * @return integer + */ + public function getIdSession() + { + return $this->idSession; + } + + /** + * Set id + * + * @param integer $id + * @return CItemProperty + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CItemProperty + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CLink.php b/src/Chamilo/CourseBundle/Entity/CLink.php new file mode 100644 index 0000000000..d3fb8e01fb --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CLink.php @@ -0,0 +1,324 @@ +url = $url; + + return $this; + } + + /** + * Get url + * + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set title + * + * @param string $title + * @return CLink + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set description + * + * @param string $description + * @return CLink + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set categoryId + * + * @param integer $categoryId + * @return CLink + */ + public function setCategoryId($categoryId) + { + $this->categoryId = $categoryId; + + return $this; + } + + /** + * Get categoryId + * + * @return integer + */ + public function getCategoryId() + { + return $this->categoryId; + } + + /** + * Set displayOrder + * + * @param integer $displayOrder + * @return CLink + */ + public function setDisplayOrder($displayOrder) + { + $this->displayOrder = $displayOrder; + + return $this; + } + + /** + * Get displayOrder + * + * @return integer + */ + public function getDisplayOrder() + { + return $this->displayOrder; + } + + /** + * Set onHomepage + * + * @param string $onHomepage + * @return CLink + */ + public function setOnHomepage($onHomepage) + { + $this->onHomepage = $onHomepage; + + return $this; + } + + /** + * Get onHomepage + * + * @return string + */ + public function getOnHomepage() + { + return $this->onHomepage; + } + + /** + * Set target + * + * @param string $target + * @return CLink + */ + public function setTarget($target) + { + $this->target = $target; + + return $this; + } + + /** + * Get target + * + * @return string + */ + public function getTarget() + { + return $this->target; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CLink + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set id + * + * @param integer $id + * @return CLink + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CLink + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CLinkCategory.php b/src/Chamilo/CourseBundle/Entity/CLinkCategory.php new file mode 100644 index 0000000000..c922a85590 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CLinkCategory.php @@ -0,0 +1,204 @@ +categoryTitle = $categoryTitle; + + return $this; + } + + /** + * Get categoryTitle + * + * @return string + */ + public function getCategoryTitle() + { + return $this->categoryTitle; + } + + /** + * Set description + * + * @param string $description + * @return CLinkCategory + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set displayOrder + * + * @param integer $displayOrder + * @return CLinkCategory + */ + public function setDisplayOrder($displayOrder) + { + $this->displayOrder = $displayOrder; + + return $this; + } + + /** + * Get displayOrder + * + * @return integer + */ + public function getDisplayOrder() + { + return $this->displayOrder; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CLinkCategory + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set id + * + * @param integer $id + * @return CLinkCategory + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CLinkCategory + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CLp.php b/src/Chamilo/CourseBundle/Entity/CLp.php new file mode 100644 index 0000000000..59eef63d3a --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CLp.php @@ -0,0 +1,924 @@ +lpType = $lpType; + + return $this; + } + + /** + * Get lpType + * + * @return integer + */ + public function getLpType() + { + return $this->lpType; + } + + /** + * Set name + * + * @param string $name + * @return CLp + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set ref + * + * @param string $ref + * @return CLp + */ + public function setRef($ref) + { + $this->ref = $ref; + + return $this; + } + + /** + * Get ref + * + * @return string + */ + public function getRef() + { + return $this->ref; + } + + /** + * Set description + * + * @param string $description + * @return CLp + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set path + * + * @param string $path + * @return CLp + */ + public function setPath($path) + { + $this->path = $path; + + return $this; + } + + /** + * Get path + * + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Set forceCommit + * + * @param boolean $forceCommit + * @return CLp + */ + public function setForceCommit($forceCommit) + { + $this->forceCommit = $forceCommit; + + return $this; + } + + /** + * Get forceCommit + * + * @return boolean + */ + public function getForceCommit() + { + return $this->forceCommit; + } + + /** + * Set defaultViewMod + * + * @param string $defaultViewMod + * @return CLp + */ + public function setDefaultViewMod($defaultViewMod) + { + $this->defaultViewMod = $defaultViewMod; + + return $this; + } + + /** + * Get defaultViewMod + * + * @return string + */ + public function getDefaultViewMod() + { + return $this->defaultViewMod; + } + + /** + * Set defaultEncoding + * + * @param string $defaultEncoding + * @return CLp + */ + public function setDefaultEncoding($defaultEncoding) + { + $this->defaultEncoding = $defaultEncoding; + + return $this; + } + + /** + * Get defaultEncoding + * + * @return string + */ + public function getDefaultEncoding() + { + return $this->defaultEncoding; + } + + /** + * Set displayOrder + * + * @param integer $displayOrder + * @return CLp + */ + public function setDisplayOrder($displayOrder) + { + $this->displayOrder = $displayOrder; + + return $this; + } + + /** + * Get displayOrder + * + * @return integer + */ + public function getDisplayOrder() + { + return $this->displayOrder; + } + + /** + * Set contentMaker + * + * @param string $contentMaker + * @return CLp + */ + public function setContentMaker($contentMaker) + { + $this->contentMaker = $contentMaker; + + return $this; + } + + /** + * Get contentMaker + * + * @return string + */ + public function getContentMaker() + { + return $this->contentMaker; + } + + /** + * Set contentLocal + * + * @param string $contentLocal + * @return CLp + */ + public function setContentLocal($contentLocal) + { + $this->contentLocal = $contentLocal; + + return $this; + } + + /** + * Get contentLocal + * + * @return string + */ + public function getContentLocal() + { + return $this->contentLocal; + } + + /** + * Set contentLicense + * + * @param string $contentLicense + * @return CLp + */ + public function setContentLicense($contentLicense) + { + $this->contentLicense = $contentLicense; + + return $this; + } + + /** + * Get contentLicense + * + * @return string + */ + public function getContentLicense() + { + return $this->contentLicense; + } + + /** + * Set preventReinit + * + * @param boolean $preventReinit + * @return CLp + */ + public function setPreventReinit($preventReinit) + { + $this->preventReinit = $preventReinit; + + return $this; + } + + /** + * Get preventReinit + * + * @return boolean + */ + public function getPreventReinit() + { + return $this->preventReinit; + } + + /** + * Set jsLib + * + * @param string $jsLib + * @return CLp + */ + public function setJsLib($jsLib) + { + $this->jsLib = $jsLib; + + return $this; + } + + /** + * Get jsLib + * + * @return string + */ + public function getJsLib() + { + return $this->jsLib; + } + + /** + * Set debug + * + * @param boolean $debug + * @return CLp + */ + public function setDebug($debug) + { + $this->debug = $debug; + + return $this; + } + + /** + * Get debug + * + * @return boolean + */ + public function getDebug() + { + return $this->debug; + } + + /** + * Set theme + * + * @param string $theme + * @return CLp + */ + public function setTheme($theme) + { + $this->theme = $theme; + + return $this; + } + + /** + * Get theme + * + * @return string + */ + public function getTheme() + { + return $this->theme; + } + + /** + * Set previewImage + * + * @param string $previewImage + * @return CLp + */ + public function setPreviewImage($previewImage) + { + $this->previewImage = $previewImage; + + return $this; + } + + /** + * Get previewImage + * + * @return string + */ + public function getPreviewImage() + { + return $this->previewImage; + } + + /** + * Set author + * + * @param string $author + * @return CLp + */ + public function setAuthor($author) + { + $this->author = $author; + + return $this; + } + + /** + * Get author + * + * @return string + */ + public function getAuthor() + { + return $this->author; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CLp + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set prerequisite + * + * @param integer $prerequisite + * @return CLp + */ + public function setPrerequisite($prerequisite) + { + $this->prerequisite = $prerequisite; + + return $this; + } + + /** + * Get prerequisite + * + * @return integer + */ + public function getPrerequisite() + { + return $this->prerequisite; + } + + /** + * Set hideTocFrame + * + * @param boolean $hideTocFrame + * @return CLp + */ + public function setHideTocFrame($hideTocFrame) + { + $this->hideTocFrame = $hideTocFrame; + + return $this; + } + + /** + * Get hideTocFrame + * + * @return boolean + */ + public function getHideTocFrame() + { + return $this->hideTocFrame; + } + + /** + * Set seriousgameMode + * + * @param boolean $seriousgameMode + * @return CLp + */ + public function setSeriousgameMode($seriousgameMode) + { + $this->seriousgameMode = $seriousgameMode; + + return $this; + } + + /** + * Get seriousgameMode + * + * @return boolean + */ + public function getSeriousgameMode() + { + return $this->seriousgameMode; + } + + /** + * Set useMaxScore + * + * @param integer $useMaxScore + * @return CLp + */ + public function setUseMaxScore($useMaxScore) + { + $this->useMaxScore = $useMaxScore; + + return $this; + } + + /** + * Get useMaxScore + * + * @return integer + */ + public function getUseMaxScore() + { + return $this->useMaxScore; + } + + /** + * Set autolunch + * + * @param integer $autolunch + * @return CLp + */ + public function setAutolunch($autolunch) + { + $this->autolunch = $autolunch; + + return $this; + } + + /** + * Get autolunch + * + * @return integer + */ + public function getAutolunch() + { + return $this->autolunch; + } + + /** + * Set createdOn + * + * @param \DateTime $createdOn + * @return CLp + */ + public function setCreatedOn($createdOn) + { + $this->createdOn = $createdOn; + + return $this; + } + + /** + * Get createdOn + * + * @return \DateTime + */ + public function getCreatedOn() + { + return $this->createdOn; + } + + /** + * Set modifiedOn + * + * @param \DateTime $modifiedOn + * @return CLp + */ + public function setModifiedOn($modifiedOn) + { + $this->modifiedOn = $modifiedOn; + + return $this; + } + + /** + * Get modifiedOn + * + * @return \DateTime + */ + public function getModifiedOn() + { + return $this->modifiedOn; + } + + /** + * Set publicatedOn + * + * @param \DateTime $publicatedOn + * @return CLp + */ + public function setPublicatedOn($publicatedOn) + { + $this->publicatedOn = $publicatedOn; + + return $this; + } + + /** + * Get publicatedOn + * + * @return \DateTime + */ + public function getPublicatedOn() + { + return $this->publicatedOn; + } + + /** + * Set expiredOn + * + * @param \DateTime $expiredOn + * @return CLp + */ + public function setExpiredOn($expiredOn) + { + $this->expiredOn = $expiredOn; + + return $this; + } + + /** + * Get expiredOn + * + * @return \DateTime + */ + public function getExpiredOn() + { + return $this->expiredOn; + } + + /** + * Set id + * + * @param integer $id + * @return CLp + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CLp + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CLpItem.php b/src/Chamilo/CourseBundle/Entity/CLpItem.php new file mode 100644 index 0000000000..d4a9fc69ec --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CLpItem.php @@ -0,0 +1,744 @@ +lpId = $lpId; + + return $this; + } + + /** + * Get lpId + * + * @return integer + */ + public function getLpId() + { + return $this->lpId; + } + + /** + * Set itemType + * + * @param string $itemType + * @return CLpItem + */ + public function setItemType($itemType) + { + $this->itemType = $itemType; + + return $this; + } + + /** + * Get itemType + * + * @return string + */ + public function getItemType() + { + return $this->itemType; + } + + /** + * Set ref + * + * @param string $ref + * @return CLpItem + */ + public function setRef($ref) + { + $this->ref = $ref; + + return $this; + } + + /** + * Get ref + * + * @return string + */ + public function getRef() + { + return $this->ref; + } + + /** + * Set title + * + * @param string $title + * @return CLpItem + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set description + * + * @param string $description + * @return CLpItem + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set path + * + * @param string $path + * @return CLpItem + */ + public function setPath($path) + { + $this->path = $path; + + return $this; + } + + /** + * Get path + * + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Set minScore + * + * @param float $minScore + * @return CLpItem + */ + public function setMinScore($minScore) + { + $this->minScore = $minScore; + + return $this; + } + + /** + * Get minScore + * + * @return float + */ + public function getMinScore() + { + return $this->minScore; + } + + /** + * Set maxScore + * + * @param float $maxScore + * @return CLpItem + */ + public function setMaxScore($maxScore) + { + $this->maxScore = $maxScore; + + return $this; + } + + /** + * Get maxScore + * + * @return float + */ + public function getMaxScore() + { + return $this->maxScore; + } + + /** + * Set masteryScore + * + * @param float $masteryScore + * @return CLpItem + */ + public function setMasteryScore($masteryScore) + { + $this->masteryScore = $masteryScore; + + return $this; + } + + /** + * Get masteryScore + * + * @return float + */ + public function getMasteryScore() + { + return $this->masteryScore; + } + + /** + * Set parentItemId + * + * @param integer $parentItemId + * @return CLpItem + */ + public function setParentItemId($parentItemId) + { + $this->parentItemId = $parentItemId; + + return $this; + } + + /** + * Get parentItemId + * + * @return integer + */ + public function getParentItemId() + { + return $this->parentItemId; + } + + /** + * Set previousItemId + * + * @param integer $previousItemId + * @return CLpItem + */ + public function setPreviousItemId($previousItemId) + { + $this->previousItemId = $previousItemId; + + return $this; + } + + /** + * Get previousItemId + * + * @return integer + */ + public function getPreviousItemId() + { + return $this->previousItemId; + } + + /** + * Set nextItemId + * + * @param integer $nextItemId + * @return CLpItem + */ + public function setNextItemId($nextItemId) + { + $this->nextItemId = $nextItemId; + + return $this; + } + + /** + * Get nextItemId + * + * @return integer + */ + public function getNextItemId() + { + return $this->nextItemId; + } + + /** + * Set displayOrder + * + * @param integer $displayOrder + * @return CLpItem + */ + public function setDisplayOrder($displayOrder) + { + $this->displayOrder = $displayOrder; + + return $this; + } + + /** + * Get displayOrder + * + * @return integer + */ + public function getDisplayOrder() + { + return $this->displayOrder; + } + + /** + * Set prerequisite + * + * @param string $prerequisite + * @return CLpItem + */ + public function setPrerequisite($prerequisite) + { + $this->prerequisite = $prerequisite; + + return $this; + } + + /** + * Get prerequisite + * + * @return string + */ + public function getPrerequisite() + { + return $this->prerequisite; + } + + /** + * Set parameters + * + * @param string $parameters + * @return CLpItem + */ + public function setParameters($parameters) + { + $this->parameters = $parameters; + + return $this; + } + + /** + * Get parameters + * + * @return string + */ + public function getParameters() + { + return $this->parameters; + } + + /** + * Set launchData + * + * @param string $launchData + * @return CLpItem + */ + public function setLaunchData($launchData) + { + $this->launchData = $launchData; + + return $this; + } + + /** + * Get launchData + * + * @return string + */ + public function getLaunchData() + { + return $this->launchData; + } + + /** + * Set maxTimeAllowed + * + * @param string $maxTimeAllowed + * @return CLpItem + */ + public function setMaxTimeAllowed($maxTimeAllowed) + { + $this->maxTimeAllowed = $maxTimeAllowed; + + return $this; + } + + /** + * Get maxTimeAllowed + * + * @return string + */ + public function getMaxTimeAllowed() + { + return $this->maxTimeAllowed; + } + + /** + * Set terms + * + * @param string $terms + * @return CLpItem + */ + public function setTerms($terms) + { + $this->terms = $terms; + + return $this; + } + + /** + * Get terms + * + * @return string + */ + public function getTerms() + { + return $this->terms; + } + + /** + * Set searchDid + * + * @param integer $searchDid + * @return CLpItem + */ + public function setSearchDid($searchDid) + { + $this->searchDid = $searchDid; + + return $this; + } + + /** + * Get searchDid + * + * @return integer + */ + public function getSearchDid() + { + return $this->searchDid; + } + + /** + * Set audio + * + * @param string $audio + * @return CLpItem + */ + public function setAudio($audio) + { + $this->audio = $audio; + + return $this; + } + + /** + * Get audio + * + * @return string + */ + public function getAudio() + { + return $this->audio; + } + + /** + * Set prerequisiteMinScore + * + * @param float $prerequisiteMinScore + * @return CLpItem + */ + public function setPrerequisiteMinScore($prerequisiteMinScore) + { + $this->prerequisiteMinScore = $prerequisiteMinScore; + + return $this; + } + + /** + * Get prerequisiteMinScore + * + * @return float + */ + public function getPrerequisiteMinScore() + { + return $this->prerequisiteMinScore; + } + + /** + * Set prerequisiteMaxScore + * + * @param float $prerequisiteMaxScore + * @return CLpItem + */ + public function setPrerequisiteMaxScore($prerequisiteMaxScore) + { + $this->prerequisiteMaxScore = $prerequisiteMaxScore; + + return $this; + } + + /** + * Get prerequisiteMaxScore + * + * @return float + */ + public function getPrerequisiteMaxScore() + { + return $this->prerequisiteMaxScore; + } + + /** + * Set id + * + * @param integer $id + * @return CLpItem + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CLpItem + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CLpItemView.php b/src/Chamilo/CourseBundle/Entity/CLpItemView.php new file mode 100644 index 0000000000..a7a48444ec --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CLpItemView.php @@ -0,0 +1,414 @@ +lpItemId = $lpItemId; + + return $this; + } + + /** + * Get lpItemId + * + * @return integer + */ + public function getLpItemId() + { + return $this->lpItemId; + } + + /** + * Set lpViewId + * + * @param integer $lpViewId + * @return CLpItemView + */ + public function setLpViewId($lpViewId) + { + $this->lpViewId = $lpViewId; + + return $this; + } + + /** + * Get lpViewId + * + * @return integer + */ + public function getLpViewId() + { + return $this->lpViewId; + } + + /** + * Set viewCount + * + * @param integer $viewCount + * @return CLpItemView + */ + public function setViewCount($viewCount) + { + $this->viewCount = $viewCount; + + return $this; + } + + /** + * Get viewCount + * + * @return integer + */ + public function getViewCount() + { + return $this->viewCount; + } + + /** + * Set startTime + * + * @param integer $startTime + * @return CLpItemView + */ + public function setStartTime($startTime) + { + $this->startTime = $startTime; + + return $this; + } + + /** + * Get startTime + * + * @return integer + */ + public function getStartTime() + { + return $this->startTime; + } + + /** + * Set totalTime + * + * @param integer $totalTime + * @return CLpItemView + */ + public function setTotalTime($totalTime) + { + $this->totalTime = $totalTime; + + return $this; + } + + /** + * Get totalTime + * + * @return integer + */ + public function getTotalTime() + { + return $this->totalTime; + } + + /** + * Set score + * + * @param float $score + * @return CLpItemView + */ + public function setScore($score) + { + $this->score = $score; + + return $this; + } + + /** + * Get score + * + * @return float + */ + public function getScore() + { + return $this->score; + } + + /** + * Set status + * + * @param string $status + * @return CLpItemView + */ + public function setStatus($status) + { + $this->status = $status; + + return $this; + } + + /** + * Get status + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set suspendData + * + * @param string $suspendData + * @return CLpItemView + */ + public function setSuspendData($suspendData) + { + $this->suspendData = $suspendData; + + return $this; + } + + /** + * Get suspendData + * + * @return string + */ + public function getSuspendData() + { + return $this->suspendData; + } + + /** + * Set lessonLocation + * + * @param string $lessonLocation + * @return CLpItemView + */ + public function setLessonLocation($lessonLocation) + { + $this->lessonLocation = $lessonLocation; + + return $this; + } + + /** + * Get lessonLocation + * + * @return string + */ + public function getLessonLocation() + { + return $this->lessonLocation; + } + + /** + * Set coreExit + * + * @param string $coreExit + * @return CLpItemView + */ + public function setCoreExit($coreExit) + { + $this->coreExit = $coreExit; + + return $this; + } + + /** + * Get coreExit + * + * @return string + */ + public function getCoreExit() + { + return $this->coreExit; + } + + /** + * Set maxScore + * + * @param string $maxScore + * @return CLpItemView + */ + public function setMaxScore($maxScore) + { + $this->maxScore = $maxScore; + + return $this; + } + + /** + * Get maxScore + * + * @return string + */ + public function getMaxScore() + { + return $this->maxScore; + } + + /** + * Set id + * + * @param integer $id + * @return CLpItemView + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CLpItemView + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CLpIvInteraction.php b/src/Chamilo/CourseBundle/Entity/CLpIvInteraction.php new file mode 100644 index 0000000000..a3e4d3b7ec --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CLpIvInteraction.php @@ -0,0 +1,384 @@ +orderId = $orderId; + + return $this; + } + + /** + * Get orderId + * + * @return integer + */ + public function getOrderId() + { + return $this->orderId; + } + + /** + * Set lpIvId + * + * @param integer $lpIvId + * @return CLpIvInteraction + */ + public function setLpIvId($lpIvId) + { + $this->lpIvId = $lpIvId; + + return $this; + } + + /** + * Get lpIvId + * + * @return integer + */ + public function getLpIvId() + { + return $this->lpIvId; + } + + /** + * Set interactionId + * + * @param string $interactionId + * @return CLpIvInteraction + */ + public function setInteractionId($interactionId) + { + $this->interactionId = $interactionId; + + return $this; + } + + /** + * Get interactionId + * + * @return string + */ + public function getInteractionId() + { + return $this->interactionId; + } + + /** + * Set interactionType + * + * @param string $interactionType + * @return CLpIvInteraction + */ + public function setInteractionType($interactionType) + { + $this->interactionType = $interactionType; + + return $this; + } + + /** + * Get interactionType + * + * @return string + */ + public function getInteractionType() + { + return $this->interactionType; + } + + /** + * Set weighting + * + * @param float $weighting + * @return CLpIvInteraction + */ + public function setWeighting($weighting) + { + $this->weighting = $weighting; + + return $this; + } + + /** + * Get weighting + * + * @return float + */ + public function getWeighting() + { + return $this->weighting; + } + + /** + * Set completionTime + * + * @param string $completionTime + * @return CLpIvInteraction + */ + public function setCompletionTime($completionTime) + { + $this->completionTime = $completionTime; + + return $this; + } + + /** + * Get completionTime + * + * @return string + */ + public function getCompletionTime() + { + return $this->completionTime; + } + + /** + * Set correctResponses + * + * @param string $correctResponses + * @return CLpIvInteraction + */ + public function setCorrectResponses($correctResponses) + { + $this->correctResponses = $correctResponses; + + return $this; + } + + /** + * Get correctResponses + * + * @return string + */ + public function getCorrectResponses() + { + return $this->correctResponses; + } + + /** + * Set studentResponse + * + * @param string $studentResponse + * @return CLpIvInteraction + */ + public function setStudentResponse($studentResponse) + { + $this->studentResponse = $studentResponse; + + return $this; + } + + /** + * Get studentResponse + * + * @return string + */ + public function getStudentResponse() + { + return $this->studentResponse; + } + + /** + * Set result + * + * @param string $result + * @return CLpIvInteraction + */ + public function setResult($result) + { + $this->result = $result; + + return $this; + } + + /** + * Get result + * + * @return string + */ + public function getResult() + { + return $this->result; + } + + /** + * Set latency + * + * @param string $latency + * @return CLpIvInteraction + */ + public function setLatency($latency) + { + $this->latency = $latency; + + return $this; + } + + /** + * Get latency + * + * @return string + */ + public function getLatency() + { + return $this->latency; + } + + /** + * Set id + * + * @param integer $id + * @return CLpIvInteraction + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CLpIvInteraction + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CLpIvObjective.php b/src/Chamilo/CourseBundle/Entity/CLpIvObjective.php new file mode 100644 index 0000000000..e137e65e41 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CLpIvObjective.php @@ -0,0 +1,294 @@ +lpIvId = $lpIvId; + + return $this; + } + + /** + * Get lpIvId + * + * @return integer + */ + public function getLpIvId() + { + return $this->lpIvId; + } + + /** + * Set orderId + * + * @param integer $orderId + * @return CLpIvObjective + */ + public function setOrderId($orderId) + { + $this->orderId = $orderId; + + return $this; + } + + /** + * Get orderId + * + * @return integer + */ + public function getOrderId() + { + return $this->orderId; + } + + /** + * Set objectiveId + * + * @param string $objectiveId + * @return CLpIvObjective + */ + public function setObjectiveId($objectiveId) + { + $this->objectiveId = $objectiveId; + + return $this; + } + + /** + * Get objectiveId + * + * @return string + */ + public function getObjectiveId() + { + return $this->objectiveId; + } + + /** + * Set scoreRaw + * + * @param float $scoreRaw + * @return CLpIvObjective + */ + public function setScoreRaw($scoreRaw) + { + $this->scoreRaw = $scoreRaw; + + return $this; + } + + /** + * Get scoreRaw + * + * @return float + */ + public function getScoreRaw() + { + return $this->scoreRaw; + } + + /** + * Set scoreMax + * + * @param float $scoreMax + * @return CLpIvObjective + */ + public function setScoreMax($scoreMax) + { + $this->scoreMax = $scoreMax; + + return $this; + } + + /** + * Get scoreMax + * + * @return float + */ + public function getScoreMax() + { + return $this->scoreMax; + } + + /** + * Set scoreMin + * + * @param float $scoreMin + * @return CLpIvObjective + */ + public function setScoreMin($scoreMin) + { + $this->scoreMin = $scoreMin; + + return $this; + } + + /** + * Get scoreMin + * + * @return float + */ + public function getScoreMin() + { + return $this->scoreMin; + } + + /** + * Set status + * + * @param string $status + * @return CLpIvObjective + */ + public function setStatus($status) + { + $this->status = $status; + + return $this; + } + + /** + * Get status + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set id + * + * @param integer $id + * @return CLpIvObjective + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CLpIvObjective + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CLpView.php b/src/Chamilo/CourseBundle/Entity/CLpView.php new file mode 100644 index 0000000000..206959f7fc --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CLpView.php @@ -0,0 +1,264 @@ +lpId = $lpId; + + return $this; + } + + /** + * Get lpId + * + * @return integer + */ + public function getLpId() + { + return $this->lpId; + } + + /** + * Set userId + * + * @param integer $userId + * @return CLpView + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set viewCount + * + * @param integer $viewCount + * @return CLpView + */ + public function setViewCount($viewCount) + { + $this->viewCount = $viewCount; + + return $this; + } + + /** + * Get viewCount + * + * @return integer + */ + public function getViewCount() + { + return $this->viewCount; + } + + /** + * Set lastItem + * + * @param integer $lastItem + * @return CLpView + */ + public function setLastItem($lastItem) + { + $this->lastItem = $lastItem; + + return $this; + } + + /** + * Get lastItem + * + * @return integer + */ + public function getLastItem() + { + return $this->lastItem; + } + + /** + * Set progress + * + * @param integer $progress + * @return CLpView + */ + public function setProgress($progress) + { + $this->progress = $progress; + + return $this; + } + + /** + * Get progress + * + * @return integer + */ + public function getProgress() + { + return $this->progress; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CLpView + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set id + * + * @param integer $id + * @return CLpView + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CLpView + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CNotebook.php b/src/Chamilo/CourseBundle/Entity/CNotebook.php new file mode 100644 index 0000000000..35500526c7 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CNotebook.php @@ -0,0 +1,324 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set course + * + * @param string $course + * @return CNotebook + */ + public function setCourse($course) + { + $this->course = $course; + + return $this; + } + + /** + * Get course + * + * @return string + */ + public function getCourse() + { + return $this->course; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CNotebook + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set title + * + * @param string $title + * @return CNotebook + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set description + * + * @param string $description + * @return CNotebook + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set creationDate + * + * @param \DateTime $creationDate + * @return CNotebook + */ + public function setCreationDate($creationDate) + { + $this->creationDate = $creationDate; + + return $this; + } + + /** + * Get creationDate + * + * @return \DateTime + */ + public function getCreationDate() + { + return $this->creationDate; + } + + /** + * Set updateDate + * + * @param \DateTime $updateDate + * @return CNotebook + */ + public function setUpdateDate($updateDate) + { + $this->updateDate = $updateDate; + + return $this; + } + + /** + * Get updateDate + * + * @return \DateTime + */ + public function getUpdateDate() + { + return $this->updateDate; + } + + /** + * Set status + * + * @param integer $status + * @return CNotebook + */ + public function setStatus($status) + { + $this->status = $status; + + return $this; + } + + /** + * Get status + * + * @return integer + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set notebookId + * + * @param integer $notebookId + * @return CNotebook + */ + public function setNotebookId($notebookId) + { + $this->notebookId = $notebookId; + + return $this; + } + + /** + * Get notebookId + * + * @return integer + */ + public function getNotebookId() + { + return $this->notebookId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CNotebook + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/COnlineConnected.php b/src/Chamilo/CourseBundle/Entity/COnlineConnected.php new file mode 100644 index 0000000000..d1517d93d4 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/COnlineConnected.php @@ -0,0 +1,114 @@ +lastConnection = $lastConnection; + + return $this; + } + + /** + * Get lastConnection + * + * @return \DateTime + */ + public function getLastConnection() + { + return $this->lastConnection; + } + + /** + * Set cId + * + * @param integer $cId + * @return COnlineConnected + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set userId + * + * @param integer $userId + * @return COnlineConnected + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/COnlineLink.php b/src/Chamilo/CourseBundle/Entity/COnlineLink.php new file mode 100644 index 0000000000..7ec9d1ffff --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/COnlineLink.php @@ -0,0 +1,144 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set url + * + * @param string $url + * @return COnlineLink + */ + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * Get url + * + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set id + * + * @param integer $id + * @return COnlineLink + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return COnlineLink + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CPermissionGroup.php b/src/Chamilo/CourseBundle/Entity/CPermissionGroup.php new file mode 100644 index 0000000000..6bb275f928 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CPermissionGroup.php @@ -0,0 +1,173 @@ +groupId = $groupId; + + return $this; + } + + /** + * Get groupId + * + * @return integer + */ + public function getGroupId() + { + return $this->groupId; + } + + /** + * Set tool + * + * @param string $tool + * @return CPermissionGroup + */ + public function setTool($tool) + { + $this->tool = $tool; + + return $this; + } + + /** + * Get tool + * + * @return string + */ + public function getTool() + { + return $this->tool; + } + + /** + * Set action + * + * @param string $action + * @return CPermissionGroup + */ + public function setAction($action) + { + $this->action = $action; + + return $this; + } + + /** + * Get action + * + * @return string + */ + public function getAction() + { + return $this->action; + } + + /** + * Set id + * + * @param integer $id + * @return CPermissionGroup + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CPermissionGroup + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CPermissionTask.php b/src/Chamilo/CourseBundle/Entity/CPermissionTask.php new file mode 100644 index 0000000000..50035c4f2e --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CPermissionTask.php @@ -0,0 +1,174 @@ +taskId = $taskId; + + return $this; + } + + /** + * Get taskId + * + * @return integer + */ + public function getTaskId() + { + return $this->taskId; + } + + /** + * Set tool + * + * @param string $tool + * @return CPermissionTask + */ + public function setTool($tool) + { + $this->tool = $tool; + + return $this; + } + + /** + * Get tool + * + * @return string + */ + public function getTool() + { + return $this->tool; + } + + /** + * Set action + * + * @param string $action + * @return CPermissionTask + */ + public function setAction($action) + { + $this->action = $action; + + return $this; + } + + /** + * Get action + * + * @return string + */ + public function getAction() + { + return $this->action; + } + + /** + * Set id + * + * @param integer $id + * @return CPermissionTask + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CPermissionTask + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CPermissionUser.php b/src/Chamilo/CourseBundle/Entity/CPermissionUser.php new file mode 100644 index 0000000000..0fc020ab50 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CPermissionUser.php @@ -0,0 +1,174 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set tool + * + * @param string $tool + * @return CPermissionUser + */ + public function setTool($tool) + { + $this->tool = $tool; + + return $this; + } + + /** + * Get tool + * + * @return string + */ + public function getTool() + { + return $this->tool; + } + + /** + * Set action + * + * @param string $action + * @return CPermissionUser + */ + public function setAction($action) + { + $this->action = $action; + + return $this; + } + + /** + * Get action + * + * @return string + */ + public function getAction() + { + return $this->action; + } + + /** + * Set id + * + * @param integer $id + * @return CPermissionUser + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CPermissionUser + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CQuiz.php b/src/Chamilo/CourseBundle/Entity/CQuiz.php new file mode 100644 index 0000000000..0f3d609d4f --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CQuiz.php @@ -0,0 +1,714 @@ +title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set description + * + * @param string $description + * @return CQuiz + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set sound + * + * @param string $sound + * @return CQuiz + */ + public function setSound($sound) + { + $this->sound = $sound; + + return $this; + } + + /** + * Get sound + * + * @return string + */ + public function getSound() + { + return $this->sound; + } + + /** + * Set type + * + * @param boolean $type + * @return CQuiz + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return boolean + */ + public function getType() + { + return $this->type; + } + + /** + * Set random + * + * @param integer $random + * @return CQuiz + */ + public function setRandom($random) + { + $this->random = $random; + + return $this; + } + + /** + * Get random + * + * @return integer + */ + public function getRandom() + { + return $this->random; + } + + /** + * Set randomAnswers + * + * @param boolean $randomAnswers + * @return CQuiz + */ + public function setRandomAnswers($randomAnswers) + { + $this->randomAnswers = $randomAnswers; + + return $this; + } + + /** + * Get randomAnswers + * + * @return boolean + */ + public function getRandomAnswers() + { + return $this->randomAnswers; + } + + /** + * Set active + * + * @param boolean $active + * @return CQuiz + */ + public function setActive($active) + { + $this->active = $active; + + return $this; + } + + /** + * Get active + * + * @return boolean + */ + public function getActive() + { + return $this->active; + } + + /** + * Set resultsDisabled + * + * @param integer $resultsDisabled + * @return CQuiz + */ + public function setResultsDisabled($resultsDisabled) + { + $this->resultsDisabled = $resultsDisabled; + + return $this; + } + + /** + * Get resultsDisabled + * + * @return integer + */ + public function getResultsDisabled() + { + return $this->resultsDisabled; + } + + /** + * Set accessCondition + * + * @param string $accessCondition + * @return CQuiz + */ + public function setAccessCondition($accessCondition) + { + $this->accessCondition = $accessCondition; + + return $this; + } + + /** + * Get accessCondition + * + * @return string + */ + public function getAccessCondition() + { + return $this->accessCondition; + } + + /** + * Set maxAttempt + * + * @param integer $maxAttempt + * @return CQuiz + */ + public function setMaxAttempt($maxAttempt) + { + $this->maxAttempt = $maxAttempt; + + return $this; + } + + /** + * Get maxAttempt + * + * @return integer + */ + public function getMaxAttempt() + { + return $this->maxAttempt; + } + + /** + * Set startTime + * + * @param \DateTime $startTime + * @return CQuiz + */ + public function setStartTime($startTime) + { + $this->startTime = $startTime; + + return $this; + } + + /** + * Get startTime + * + * @return \DateTime + */ + public function getStartTime() + { + return $this->startTime; + } + + /** + * Set endTime + * + * @param \DateTime $endTime + * @return CQuiz + */ + public function setEndTime($endTime) + { + $this->endTime = $endTime; + + return $this; + } + + /** + * Get endTime + * + * @return \DateTime + */ + public function getEndTime() + { + return $this->endTime; + } + + /** + * Set feedbackType + * + * @param integer $feedbackType + * @return CQuiz + */ + public function setFeedbackType($feedbackType) + { + $this->feedbackType = $feedbackType; + + return $this; + } + + /** + * Get feedbackType + * + * @return integer + */ + public function getFeedbackType() + { + return $this->feedbackType; + } + + /** + * Set expiredTime + * + * @param integer $expiredTime + * @return CQuiz + */ + public function setExpiredTime($expiredTime) + { + $this->expiredTime = $expiredTime; + + return $this; + } + + /** + * Get expiredTime + * + * @return integer + */ + public function getExpiredTime() + { + return $this->expiredTime; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CQuiz + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set propagateNeg + * + * @param integer $propagateNeg + * @return CQuiz + */ + public function setPropagateNeg($propagateNeg) + { + $this->propagateNeg = $propagateNeg; + + return $this; + } + + /** + * Get propagateNeg + * + * @return integer + */ + public function getPropagateNeg() + { + return $this->propagateNeg; + } + + /** + * Set reviewAnswers + * + * @param integer $reviewAnswers + * @return CQuiz + */ + public function setReviewAnswers($reviewAnswers) + { + $this->reviewAnswers = $reviewAnswers; + + return $this; + } + + /** + * Get reviewAnswers + * + * @return integer + */ + public function getReviewAnswers() + { + return $this->reviewAnswers; + } + + /** + * Set randomByCategory + * + * @param integer $randomByCategory + * @return CQuiz + */ + public function setRandomByCategory($randomByCategory) + { + $this->randomByCategory = $randomByCategory; + + return $this; + } + + /** + * Get randomByCategory + * + * @return integer + */ + public function getRandomByCategory() + { + return $this->randomByCategory; + } + + /** + * Set textWhenFinished + * + * @param string $textWhenFinished + * @return CQuiz + */ + public function setTextWhenFinished($textWhenFinished) + { + $this->textWhenFinished = $textWhenFinished; + + return $this; + } + + /** + * Get textWhenFinished + * + * @return string + */ + public function getTextWhenFinished() + { + return $this->textWhenFinished; + } + + /** + * Set displayCategoryName + * + * @param integer $displayCategoryName + * @return CQuiz + */ + public function setDisplayCategoryName($displayCategoryName) + { + $this->displayCategoryName = $displayCategoryName; + + return $this; + } + + /** + * Get displayCategoryName + * + * @return integer + */ + public function getDisplayCategoryName() + { + return $this->displayCategoryName; + } + + /** + * Set passPercentage + * + * @param integer $passPercentage + * @return CQuiz + */ + public function setPassPercentage($passPercentage) + { + $this->passPercentage = $passPercentage; + + return $this; + } + + /** + * Get passPercentage + * + * @return integer + */ + public function getPassPercentage() + { + return $this->passPercentage; + } + + /** + * Set id + * + * @param integer $id + * @return CQuiz + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CQuiz + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CQuizAnswer.php b/src/Chamilo/CourseBundle/Entity/CQuizAnswer.php new file mode 100644 index 0000000000..0135fd3478 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CQuizAnswer.php @@ -0,0 +1,408 @@ +id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set questionId + * + * @param integer $questionId + * @return CQuizAnswer + */ + public function setQuestionId($questionId) + { + $this->questionId = $questionId; + + return $this; + } + + /** + * Get questionId + * + * @return integer + */ + public function getQuestionId() + { + return $this->questionId; + } + + /** + * Set answer + * + * @param string $answer + * @return CQuizAnswer + */ + public function setAnswer($answer) + { + $this->answer = $answer; + + return $this; + } + + /** + * Get answer + * + * @return string + */ + public function getAnswer() + { + return $this->answer; + } + + /** + * Set correct + * + * @param integer $correct + * @return CQuizAnswer + */ + public function setCorrect($correct) + { + $this->correct = $correct; + + return $this; + } + + /** + * Get correct + * + * @return integer + */ + public function getCorrect() + { + return $this->correct; + } + + /** + * Set comment + * + * @param string $comment + * @return CQuizAnswer + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set ponderation + * + * @param float $ponderation + * @return CQuizAnswer + */ + public function setPonderation($ponderation) + { + $this->ponderation = $ponderation; + + return $this; + } + + /** + * Get ponderation + * + * @return float + */ + public function getPonderation() + { + return $this->ponderation; + } + + /** + * Set position + * + * @param integer $position + * @return CQuizAnswer + */ + public function setPosition($position) + { + $this->position = $position; + + return $this; + } + + /** + * Get position + * + * @return integer + */ + public function getPosition() + { + return $this->position; + } + + /** + * Set hotspotCoordinates + * + * @param string $hotspotCoordinates + * @return CQuizAnswer + */ + public function setHotspotCoordinates($hotspotCoordinates) + { + $this->hotspotCoordinates = $hotspotCoordinates; + + return $this; + } + + /** + * Get hotspotCoordinates + * + * @return string + */ + public function getHotspotCoordinates() + { + return $this->hotspotCoordinates; + } + + /** + * Set hotspotType + * + * @param string $hotspotType + * @return CQuizAnswer + */ + public function setHotspotType($hotspotType) + { + $this->hotspotType = $hotspotType; + + return $this; + } + + /** + * Get hotspotType + * + * @return string + */ + public function getHotspotType() + { + return $this->hotspotType; + } + + /** + * Set destination + * + * @param string $destination + * @return CQuizAnswer + */ + public function setDestination($destination) + { + $this->destination = $destination; + + return $this; + } + + /** + * Get destination + * + * @return string + */ + public function getDestination() + { + return $this->destination; + } + + /** + * Set answerCode + * + * @param string $answerCode + * @return CQuizAnswer + */ + public function setAnswerCode($answerCode) + { + $this->answerCode = $answerCode; + + return $this; + } + + /** + * Get answerCode + * + * @return string + */ + public function getAnswerCode() + { + return $this->answerCode; + } + + /** + * Set idAuto + * + * @param integer $idAuto + * @return CQuizAnswer + */ + public function setIdAuto($idAuto) + { + $this->idAuto = $idAuto; + + return $this; + } + + /** + * Get idAuto + * + * @return integer + */ + public function getIdAuto() + { + return $this->idAuto; + } + + /** + * Set cId + * + * @param integer $cId + * @return CQuizAnswer + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CQuizQuestion.php b/src/Chamilo/CourseBundle/Entity/CQuizQuestion.php new file mode 100644 index 0000000000..500ad0714a --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CQuizQuestion.php @@ -0,0 +1,354 @@ +question = $question; + + return $this; + } + + /** + * Get question + * + * @return string + */ + public function getQuestion() + { + return $this->question; + } + + /** + * Set description + * + * @param string $description + * @return CQuizQuestion + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set ponderation + * + * @param float $ponderation + * @return CQuizQuestion + */ + public function setPonderation($ponderation) + { + $this->ponderation = $ponderation; + + return $this; + } + + /** + * Get ponderation + * + * @return float + */ + public function getPonderation() + { + return $this->ponderation; + } + + /** + * Set position + * + * @param integer $position + * @return CQuizQuestion + */ + public function setPosition($position) + { + $this->position = $position; + + return $this; + } + + /** + * Get position + * + * @return integer + */ + public function getPosition() + { + return $this->position; + } + + /** + * Set type + * + * @param boolean $type + * @return CQuizQuestion + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return boolean + */ + public function getType() + { + return $this->type; + } + + /** + * Set picture + * + * @param string $picture + * @return CQuizQuestion + */ + public function setPicture($picture) + { + $this->picture = $picture; + + return $this; + } + + /** + * Get picture + * + * @return string + */ + public function getPicture() + { + return $this->picture; + } + + /** + * Set level + * + * @param integer $level + * @return CQuizQuestion + */ + public function setLevel($level) + { + $this->level = $level; + + return $this; + } + + /** + * Get level + * + * @return integer + */ + public function getLevel() + { + return $this->level; + } + + /** + * Set extra + * + * @param string $extra + * @return CQuizQuestion + */ + public function setExtra($extra) + { + $this->extra = $extra; + + return $this; + } + + /** + * Get extra + * + * @return string + */ + public function getExtra() + { + return $this->extra; + } + + /** + * Set questionCode + * + * @param string $questionCode + * @return CQuizQuestion + */ + public function setQuestionCode($questionCode) + { + $this->questionCode = $questionCode; + + return $this; + } + + /** + * Get questionCode + * + * @return string + */ + public function getQuestionCode() + { + return $this->questionCode; + } + + /** + * Set id + * + * @param integer $id + * @return CQuizQuestion + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CQuizQuestion + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CQuizQuestionCategory.php b/src/Chamilo/CourseBundle/Entity/CQuizQuestionCategory.php new file mode 100644 index 0000000000..05003d3469 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CQuizQuestionCategory.php @@ -0,0 +1,144 @@ +title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set description + * + * @param string $description + * @return CQuizQuestionCategory + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set id + * + * @param integer $id + * @return CQuizQuestionCategory + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CQuizQuestionCategory + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CQuizQuestionOption.php b/src/Chamilo/CourseBundle/Entity/CQuizQuestionOption.php new file mode 100644 index 0000000000..367dfeb12d --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CQuizQuestionOption.php @@ -0,0 +1,174 @@ +questionId = $questionId; + + return $this; + } + + /** + * Get questionId + * + * @return integer + */ + public function getQuestionId() + { + return $this->questionId; + } + + /** + * Set name + * + * @param string $name + * @return CQuizQuestionOption + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set position + * + * @param integer $position + * @return CQuizQuestionOption + */ + public function setPosition($position) + { + $this->position = $position; + + return $this; + } + + /** + * Get position + * + * @return integer + */ + public function getPosition() + { + return $this->position; + } + + /** + * Set id + * + * @param integer $id + * @return CQuizQuestionOption + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CQuizQuestionOption + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CQuizQuestionRelCategory.php b/src/Chamilo/CourseBundle/Entity/CQuizQuestionRelCategory.php new file mode 100644 index 0000000000..e92bb156bb --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CQuizQuestionRelCategory.php @@ -0,0 +1,114 @@ +categoryId = $categoryId; + + return $this; + } + + /** + * Get categoryId + * + * @return integer + */ + public function getCategoryId() + { + return $this->categoryId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CQuizQuestionRelCategory + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set questionId + * + * @param integer $questionId + * @return CQuizQuestionRelCategory + */ + public function setQuestionId($questionId) + { + $this->questionId = $questionId; + + return $this; + } + + /** + * Get questionId + * + * @return integer + */ + public function getQuestionId() + { + return $this->questionId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CQuizRelQuestion.php b/src/Chamilo/CourseBundle/Entity/CQuizRelQuestion.php new file mode 100644 index 0000000000..97a5c161d6 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CQuizRelQuestion.php @@ -0,0 +1,144 @@ +questionOrder = $questionOrder; + + return $this; + } + + /** + * Get questionOrder + * + * @return integer + */ + public function getQuestionOrder() + { + return $this->questionOrder; + } + + /** + * Set cId + * + * @param integer $cId + * @return CQuizRelQuestion + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set questionId + * + * @param integer $questionId + * @return CQuizRelQuestion + */ + public function setQuestionId($questionId) + { + $this->questionId = $questionId; + + return $this; + } + + /** + * Get questionId + * + * @return integer + */ + public function getQuestionId() + { + return $this->questionId; + } + + /** + * Set exerciceId + * + * @param integer $exerciceId + * @return CQuizRelQuestion + */ + public function setExerciceId($exerciceId) + { + $this->exerciceId = $exerciceId; + + return $this; + } + + /** + * Get exerciceId + * + * @return integer + */ + public function getExerciceId() + { + return $this->exerciceId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CResource.php b/src/Chamilo/CourseBundle/Entity/CResource.php new file mode 100644 index 0000000000..5a0a815a96 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CResource.php @@ -0,0 +1,204 @@ +sourceType = $sourceType; + + return $this; + } + + /** + * Get sourceType + * + * @return string + */ + public function getSourceType() + { + return $this->sourceType; + } + + /** + * Set sourceId + * + * @param integer $sourceId + * @return CResource + */ + public function setSourceId($sourceId) + { + $this->sourceId = $sourceId; + + return $this; + } + + /** + * Get sourceId + * + * @return integer + */ + public function getSourceId() + { + return $this->sourceId; + } + + /** + * Set resourceType + * + * @param string $resourceType + * @return CResource + */ + public function setResourceType($resourceType) + { + $this->resourceType = $resourceType; + + return $this; + } + + /** + * Get resourceType + * + * @return string + */ + public function getResourceType() + { + return $this->resourceType; + } + + /** + * Set resourceId + * + * @param integer $resourceId + * @return CResource + */ + public function setResourceId($resourceId) + { + $this->resourceId = $resourceId; + + return $this; + } + + /** + * Get resourceId + * + * @return integer + */ + public function getResourceId() + { + return $this->resourceId; + } + + /** + * Set id + * + * @param integer $id + * @return CResource + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CResource + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CRole.php b/src/Chamilo/CourseBundle/Entity/CRole.php new file mode 100644 index 0000000000..7a927ae5fe --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CRole.php @@ -0,0 +1,174 @@ +roleName = $roleName; + + return $this; + } + + /** + * Get roleName + * + * @return string + */ + public function getRoleName() + { + return $this->roleName; + } + + /** + * Set roleComment + * + * @param string $roleComment + * @return CRole + */ + public function setRoleComment($roleComment) + { + $this->roleComment = $roleComment; + + return $this; + } + + /** + * Get roleComment + * + * @return string + */ + public function getRoleComment() + { + return $this->roleComment; + } + + /** + * Set defaultRole + * + * @param boolean $defaultRole + * @return CRole + */ + public function setDefaultRole($defaultRole) + { + $this->defaultRole = $defaultRole; + + return $this; + } + + /** + * Get defaultRole + * + * @return boolean + */ + public function getDefaultRole() + { + return $this->defaultRole; + } + + /** + * Set roleId + * + * @param integer $roleId + * @return CRole + */ + public function setRoleId($roleId) + { + $this->roleId = $roleId; + + return $this; + } + + /** + * Get roleId + * + * @return integer + */ + public function getRoleId() + { + return $this->roleId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CRole + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CRoleGroup.php b/src/Chamilo/CourseBundle/Entity/CRoleGroup.php new file mode 100644 index 0000000000..18b14fc7c9 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CRoleGroup.php @@ -0,0 +1,175 @@ +roleId = $roleId; + + return $this; + } + + /** + * Get roleId + * + * @return integer + */ + public function getRoleId() + { + return $this->roleId; + } + + /** + * Set scope + * + * @param string $scope + * @return CRoleGroup + */ + public function setScope($scope) + { + $this->scope = $scope; + + return $this; + } + + /** + * Get scope + * + * @return string + */ + public function getScope() + { + return $this->scope; + } + + /** + * Set id + * + * @param integer $id + * @return CRoleGroup + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CRoleGroup + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set groupId + * + * @param integer $groupId + * @return CRoleGroup + */ + public function setGroupId($groupId) + { + $this->groupId = $groupId; + + return $this; + } + + /** + * Get groupId + * + * @return integer + */ + public function getGroupId() + { + return $this->groupId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CRolePermissions.php b/src/Chamilo/CourseBundle/Entity/CRolePermissions.php new file mode 100644 index 0000000000..a410a8fb59 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CRolePermissions.php @@ -0,0 +1,204 @@ +defaultPerm = $defaultPerm; + + return $this; + } + + /** + * Get defaultPerm + * + * @return boolean + */ + public function getDefaultPerm() + { + return $this->defaultPerm; + } + + /** + * Set id + * + * @param integer $id + * @return CRolePermissions + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CRolePermissions + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set roleId + * + * @param integer $roleId + * @return CRolePermissions + */ + public function setRoleId($roleId) + { + $this->roleId = $roleId; + + return $this; + } + + /** + * Get roleId + * + * @return integer + */ + public function getRoleId() + { + return $this->roleId; + } + + /** + * Set tool + * + * @param string $tool + * @return CRolePermissions + */ + public function setTool($tool) + { + $this->tool = $tool; + + return $this; + } + + /** + * Get tool + * + * @return string + */ + public function getTool() + { + return $this->tool; + } + + /** + * Set action + * + * @param string $action + * @return CRolePermissions + */ + public function setAction($action) + { + $this->action = $action; + + return $this; + } + + /** + * Get action + * + * @return string + */ + public function getAction() + { + return $this->action; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CRoleUser.php b/src/Chamilo/CourseBundle/Entity/CRoleUser.php new file mode 100644 index 0000000000..8443622c44 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CRoleUser.php @@ -0,0 +1,144 @@ +scope = $scope; + + return $this; + } + + /** + * Get scope + * + * @return string + */ + public function getScope() + { + return $this->scope; + } + + /** + * Set cId + * + * @param integer $cId + * @return CRoleUser + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set roleId + * + * @param integer $roleId + * @return CRoleUser + */ + public function setRoleId($roleId) + { + $this->roleId = $roleId; + + return $this; + } + + /** + * Get roleId + * + * @return integer + */ + public function getRoleId() + { + return $this->roleId; + } + + /** + * Set userId + * + * @param integer $userId + * @return CRoleUser + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CStudentPublication.php b/src/Chamilo/CourseBundle/Entity/CStudentPublication.php new file mode 100644 index 0000000000..88ba7d215f --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CStudentPublication.php @@ -0,0 +1,684 @@ +url = $url; + + return $this; + } + + /** + * Get url + * + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set title + * + * @param string $title + * @return CStudentPublication + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set description + * + * @param string $description + * @return CStudentPublication + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set author + * + * @param string $author + * @return CStudentPublication + */ + public function setAuthor($author) + { + $this->author = $author; + + return $this; + } + + /** + * Get author + * + * @return string + */ + public function getAuthor() + { + return $this->author; + } + + /** + * Set active + * + * @param boolean $active + * @return CStudentPublication + */ + public function setActive($active) + { + $this->active = $active; + + return $this; + } + + /** + * Get active + * + * @return boolean + */ + public function getActive() + { + return $this->active; + } + + /** + * Set accepted + * + * @param boolean $accepted + * @return CStudentPublication + */ + public function setAccepted($accepted) + { + $this->accepted = $accepted; + + return $this; + } + + /** + * Get accepted + * + * @return boolean + */ + public function getAccepted() + { + return $this->accepted; + } + + /** + * Set postGroupId + * + * @param integer $postGroupId + * @return CStudentPublication + */ + public function setPostGroupId($postGroupId) + { + $this->postGroupId = $postGroupId; + + return $this; + } + + /** + * Get postGroupId + * + * @return integer + */ + public function getPostGroupId() + { + return $this->postGroupId; + } + + /** + * Set sentDate + * + * @param \DateTime $sentDate + * @return CStudentPublication + */ + public function setSentDate($sentDate) + { + $this->sentDate = $sentDate; + + return $this; + } + + /** + * Get sentDate + * + * @return \DateTime + */ + public function getSentDate() + { + return $this->sentDate; + } + + /** + * Set filetype + * + * @param string $filetype + * @return CStudentPublication + */ + public function setFiletype($filetype) + { + $this->filetype = $filetype; + + return $this; + } + + /** + * Get filetype + * + * @return string + */ + public function getFiletype() + { + return $this->filetype; + } + + /** + * Set hasProperties + * + * @param integer $hasProperties + * @return CStudentPublication + */ + public function setHasProperties($hasProperties) + { + $this->hasProperties = $hasProperties; + + return $this; + } + + /** + * Get hasProperties + * + * @return integer + */ + public function getHasProperties() + { + return $this->hasProperties; + } + + /** + * Set viewProperties + * + * @param boolean $viewProperties + * @return CStudentPublication + */ + public function setViewProperties($viewProperties) + { + $this->viewProperties = $viewProperties; + + return $this; + } + + /** + * Get viewProperties + * + * @return boolean + */ + public function getViewProperties() + { + return $this->viewProperties; + } + + /** + * Set qualification + * + * @param float $qualification + * @return CStudentPublication + */ + public function setQualification($qualification) + { + $this->qualification = $qualification; + + return $this; + } + + /** + * Get qualification + * + * @return float + */ + public function getQualification() + { + return $this->qualification; + } + + /** + * Set dateOfQualification + * + * @param \DateTime $dateOfQualification + * @return CStudentPublication + */ + public function setDateOfQualification($dateOfQualification) + { + $this->dateOfQualification = $dateOfQualification; + + return $this; + } + + /** + * Get dateOfQualification + * + * @return \DateTime + */ + public function getDateOfQualification() + { + return $this->dateOfQualification; + } + + /** + * Set parentId + * + * @param integer $parentId + * @return CStudentPublication + */ + public function setParentId($parentId) + { + $this->parentId = $parentId; + + return $this; + } + + /** + * Get parentId + * + * @return integer + */ + public function getParentId() + { + return $this->parentId; + } + + /** + * Set qualificatorId + * + * @param integer $qualificatorId + * @return CStudentPublication + */ + public function setQualificatorId($qualificatorId) + { + $this->qualificatorId = $qualificatorId; + + return $this; + } + + /** + * Get qualificatorId + * + * @return integer + */ + public function getQualificatorId() + { + return $this->qualificatorId; + } + + /** + * Set weight + * + * @param float $weight + * @return CStudentPublication + */ + public function setWeight($weight) + { + $this->weight = $weight; + + return $this; + } + + /** + * Get weight + * + * @return float + */ + public function getWeight() + { + return $this->weight; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CStudentPublication + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set userId + * + * @param integer $userId + * @return CStudentPublication + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set allowTextAssignment + * + * @param integer $allowTextAssignment + * @return CStudentPublication + */ + public function setAllowTextAssignment($allowTextAssignment) + { + $this->allowTextAssignment = $allowTextAssignment; + + return $this; + } + + /** + * Get allowTextAssignment + * + * @return integer + */ + public function getAllowTextAssignment() + { + return $this->allowTextAssignment; + } + + /** + * Set containsFile + * + * @param integer $containsFile + * @return CStudentPublication + */ + public function setContainsFile($containsFile) + { + $this->containsFile = $containsFile; + + return $this; + } + + /** + * Get containsFile + * + * @return integer + */ + public function getContainsFile() + { + return $this->containsFile; + } + + /** + * Set id + * + * @param integer $id + * @return CStudentPublication + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CStudentPublication + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CStudentPublicationAssignment.php b/src/Chamilo/CourseBundle/Entity/CStudentPublicationAssignment.php new file mode 100644 index 0000000000..b798f2d35a --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CStudentPublicationAssignment.php @@ -0,0 +1,234 @@ +expiresOn = $expiresOn; + + return $this; + } + + /** + * Get expiresOn + * + * @return \DateTime + */ + public function getExpiresOn() + { + return $this->expiresOn; + } + + /** + * Set endsOn + * + * @param \DateTime $endsOn + * @return CStudentPublicationAssignment + */ + public function setEndsOn($endsOn) + { + $this->endsOn = $endsOn; + + return $this; + } + + /** + * Get endsOn + * + * @return \DateTime + */ + public function getEndsOn() + { + return $this->endsOn; + } + + /** + * Set addToCalendar + * + * @param boolean $addToCalendar + * @return CStudentPublicationAssignment + */ + public function setAddToCalendar($addToCalendar) + { + $this->addToCalendar = $addToCalendar; + + return $this; + } + + /** + * Get addToCalendar + * + * @return boolean + */ + public function getAddToCalendar() + { + return $this->addToCalendar; + } + + /** + * Set enableQualification + * + * @param boolean $enableQualification + * @return CStudentPublicationAssignment + */ + public function setEnableQualification($enableQualification) + { + $this->enableQualification = $enableQualification; + + return $this; + } + + /** + * Get enableQualification + * + * @return boolean + */ + public function getEnableQualification() + { + return $this->enableQualification; + } + + /** + * Set publicationId + * + * @param integer $publicationId + * @return CStudentPublicationAssignment + */ + public function setPublicationId($publicationId) + { + $this->publicationId = $publicationId; + + return $this; + } + + /** + * Get publicationId + * + * @return integer + */ + public function getPublicationId() + { + return $this->publicationId; + } + + /** + * Set id + * + * @param integer $id + * @return CStudentPublicationAssignment + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CStudentPublicationAssignment + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CStudentPublicationComment.php b/src/Chamilo/CourseBundle/Entity/CStudentPublicationComment.php new file mode 100644 index 0000000000..a5d443f901 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CStudentPublicationComment.php @@ -0,0 +1,221 @@ +workId = $workId; + + return $this; + } + + /** + * Get workId + * + * @return integer + */ + public function getWorkId() + { + return $this->workId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CStudentPublicationComment + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set comment + * + * @param string $comment + * @return CStudentPublicationComment + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set file + * + * @param string $file + * @return CStudentPublicationComment + */ + public function setFile($file) + { + $this->file = $file; + + return $this; + } + + /** + * Get file + * + * @return string + */ + public function getFile() + { + return $this->file; + } + + /** + * Set userId + * + * @param integer $userId + * @return CStudentPublicationComment + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set sentAt + * + * @param \DateTime $sentAt + * @return CStudentPublicationComment + */ + public function setSentAt($sentAt) + { + $this->sentAt = $sentAt; + + return $this; + } + + /** + * Get sentAt + * + * @return \DateTime + */ + public function getSentAt() + { + return $this->sentAt; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CStudentPublicationRelDocument.php b/src/Chamilo/CourseBundle/Entity/CStudentPublicationRelDocument.php new file mode 100644 index 0000000000..d04391b485 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CStudentPublicationRelDocument.php @@ -0,0 +1,131 @@ +workId = $workId; + + return $this; + } + + /** + * Get workId + * + * @return integer + */ + public function getWorkId() + { + return $this->workId; + } + + /** + * Set documentId + * + * @param integer $documentId + * @return CStudentPublicationRelDocument + */ + public function setDocumentId($documentId) + { + $this->documentId = $documentId; + + return $this; + } + + /** + * Get documentId + * + * @return integer + */ + public function getDocumentId() + { + return $this->documentId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CStudentPublicationRelDocument + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CStudentPublicationRelUser.php b/src/Chamilo/CourseBundle/Entity/CStudentPublicationRelUser.php new file mode 100644 index 0000000000..abee16c397 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CStudentPublicationRelUser.php @@ -0,0 +1,131 @@ +workId = $workId; + + return $this; + } + + /** + * Get workId + * + * @return integer + */ + public function getWorkId() + { + return $this->workId; + } + + /** + * Set userId + * + * @param integer $userId + * @return CStudentPublicationRelUser + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CStudentPublicationRelUser + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CSurvey.php b/src/Chamilo/CourseBundle/Entity/CSurvey.php new file mode 100644 index 0000000000..a6e2300233 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CSurvey.php @@ -0,0 +1,924 @@ +code = $code; + + return $this; + } + + /** + * Get code + * + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * Set title + * + * @param string $title + * @return CSurvey + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set subtitle + * + * @param string $subtitle + * @return CSurvey + */ + public function setSubtitle($subtitle) + { + $this->subtitle = $subtitle; + + return $this; + } + + /** + * Get subtitle + * + * @return string + */ + public function getSubtitle() + { + return $this->subtitle; + } + + /** + * Set author + * + * @param string $author + * @return CSurvey + */ + public function setAuthor($author) + { + $this->author = $author; + + return $this; + } + + /** + * Get author + * + * @return string + */ + public function getAuthor() + { + return $this->author; + } + + /** + * Set lang + * + * @param string $lang + * @return CSurvey + */ + public function setLang($lang) + { + $this->lang = $lang; + + return $this; + } + + /** + * Get lang + * + * @return string + */ + public function getLang() + { + return $this->lang; + } + + /** + * Set availFrom + * + * @param \DateTime $availFrom + * @return CSurvey + */ + public function setAvailFrom($availFrom) + { + $this->availFrom = $availFrom; + + return $this; + } + + /** + * Get availFrom + * + * @return \DateTime + */ + public function getAvailFrom() + { + return $this->availFrom; + } + + /** + * Set availTill + * + * @param \DateTime $availTill + * @return CSurvey + */ + public function setAvailTill($availTill) + { + $this->availTill = $availTill; + + return $this; + } + + /** + * Get availTill + * + * @return \DateTime + */ + public function getAvailTill() + { + return $this->availTill; + } + + /** + * Set isShared + * + * @param string $isShared + * @return CSurvey + */ + public function setIsShared($isShared) + { + $this->isShared = $isShared; + + return $this; + } + + /** + * Get isShared + * + * @return string + */ + public function getIsShared() + { + return $this->isShared; + } + + /** + * Set template + * + * @param string $template + * @return CSurvey + */ + public function setTemplate($template) + { + $this->template = $template; + + return $this; + } + + /** + * Get template + * + * @return string + */ + public function getTemplate() + { + return $this->template; + } + + /** + * Set intro + * + * @param string $intro + * @return CSurvey + */ + public function setIntro($intro) + { + $this->intro = $intro; + + return $this; + } + + /** + * Get intro + * + * @return string + */ + public function getIntro() + { + return $this->intro; + } + + /** + * Set surveythanks + * + * @param string $surveythanks + * @return CSurvey + */ + public function setSurveythanks($surveythanks) + { + $this->surveythanks = $surveythanks; + + return $this; + } + + /** + * Get surveythanks + * + * @return string + */ + public function getSurveythanks() + { + return $this->surveythanks; + } + + /** + * Set creationDate + * + * @param \DateTime $creationDate + * @return CSurvey + */ + public function setCreationDate($creationDate) + { + $this->creationDate = $creationDate; + + return $this; + } + + /** + * Get creationDate + * + * @return \DateTime + */ + public function getCreationDate() + { + return $this->creationDate; + } + + /** + * Set invited + * + * @param integer $invited + * @return CSurvey + */ + public function setInvited($invited) + { + $this->invited = $invited; + + return $this; + } + + /** + * Get invited + * + * @return integer + */ + public function getInvited() + { + return $this->invited; + } + + /** + * Set answered + * + * @param integer $answered + * @return CSurvey + */ + public function setAnswered($answered) + { + $this->answered = $answered; + + return $this; + } + + /** + * Get answered + * + * @return integer + */ + public function getAnswered() + { + return $this->answered; + } + + /** + * Set inviteMail + * + * @param string $inviteMail + * @return CSurvey + */ + public function setInviteMail($inviteMail) + { + $this->inviteMail = $inviteMail; + + return $this; + } + + /** + * Get inviteMail + * + * @return string + */ + public function getInviteMail() + { + return $this->inviteMail; + } + + /** + * Set reminderMail + * + * @param string $reminderMail + * @return CSurvey + */ + public function setReminderMail($reminderMail) + { + $this->reminderMail = $reminderMail; + + return $this; + } + + /** + * Get reminderMail + * + * @return string + */ + public function getReminderMail() + { + return $this->reminderMail; + } + + /** + * Set mailSubject + * + * @param string $mailSubject + * @return CSurvey + */ + public function setMailSubject($mailSubject) + { + $this->mailSubject = $mailSubject; + + return $this; + } + + /** + * Get mailSubject + * + * @return string + */ + public function getMailSubject() + { + return $this->mailSubject; + } + + /** + * Set anonymous + * + * @param string $anonymous + * @return CSurvey + */ + public function setAnonymous($anonymous) + { + $this->anonymous = $anonymous; + + return $this; + } + + /** + * Get anonymous + * + * @return string + */ + public function getAnonymous() + { + return $this->anonymous; + } + + /** + * Set accessCondition + * + * @param string $accessCondition + * @return CSurvey + */ + public function setAccessCondition($accessCondition) + { + $this->accessCondition = $accessCondition; + + return $this; + } + + /** + * Get accessCondition + * + * @return string + */ + public function getAccessCondition() + { + return $this->accessCondition; + } + + /** + * Set shuffle + * + * @param boolean $shuffle + * @return CSurvey + */ + public function setShuffle($shuffle) + { + $this->shuffle = $shuffle; + + return $this; + } + + /** + * Get shuffle + * + * @return boolean + */ + public function getShuffle() + { + return $this->shuffle; + } + + /** + * Set oneQuestionPerPage + * + * @param boolean $oneQuestionPerPage + * @return CSurvey + */ + public function setOneQuestionPerPage($oneQuestionPerPage) + { + $this->oneQuestionPerPage = $oneQuestionPerPage; + + return $this; + } + + /** + * Get oneQuestionPerPage + * + * @return boolean + */ + public function getOneQuestionPerPage() + { + return $this->oneQuestionPerPage; + } + + /** + * Set surveyVersion + * + * @param string $surveyVersion + * @return CSurvey + */ + public function setSurveyVersion($surveyVersion) + { + $this->surveyVersion = $surveyVersion; + + return $this; + } + + /** + * Get surveyVersion + * + * @return string + */ + public function getSurveyVersion() + { + return $this->surveyVersion; + } + + /** + * Set parentId + * + * @param integer $parentId + * @return CSurvey + */ + public function setParentId($parentId) + { + $this->parentId = $parentId; + + return $this; + } + + /** + * Get parentId + * + * @return integer + */ + public function getParentId() + { + return $this->parentId; + } + + /** + * Set surveyType + * + * @param integer $surveyType + * @return CSurvey + */ + public function setSurveyType($surveyType) + { + $this->surveyType = $surveyType; + + return $this; + } + + /** + * Get surveyType + * + * @return integer + */ + public function getSurveyType() + { + return $this->surveyType; + } + + /** + * Set showFormProfile + * + * @param integer $showFormProfile + * @return CSurvey + */ + public function setShowFormProfile($showFormProfile) + { + $this->showFormProfile = $showFormProfile; + + return $this; + } + + /** + * Get showFormProfile + * + * @return integer + */ + public function getShowFormProfile() + { + return $this->showFormProfile; + } + + /** + * Set formFields + * + * @param string $formFields + * @return CSurvey + */ + public function setFormFields($formFields) + { + $this->formFields = $formFields; + + return $this; + } + + /** + * Get formFields + * + * @return string + */ + public function getFormFields() + { + return $this->formFields; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CSurvey + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set visibleResults + * + * @param integer $visibleResults + * @return CSurvey + */ + public function setVisibleResults($visibleResults) + { + $this->visibleResults = $visibleResults; + + return $this; + } + + /** + * Get visibleResults + * + * @return integer + */ + public function getVisibleResults() + { + return $this->visibleResults; + } + + /** + * Set surveyId + * + * @param integer $surveyId + * @return CSurvey + */ + public function setSurveyId($surveyId) + { + $this->surveyId = $surveyId; + + return $this; + } + + /** + * Get surveyId + * + * @return integer + */ + public function getSurveyId() + { + return $this->surveyId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CSurvey + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CSurveyAnswer.php b/src/Chamilo/CourseBundle/Entity/CSurveyAnswer.php new file mode 100644 index 0000000000..f8ba18e0dc --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CSurveyAnswer.php @@ -0,0 +1,234 @@ +surveyId = $surveyId; + + return $this; + } + + /** + * Get surveyId + * + * @return integer + */ + public function getSurveyId() + { + return $this->surveyId; + } + + /** + * Set questionId + * + * @param integer $questionId + * @return CSurveyAnswer + */ + public function setQuestionId($questionId) + { + $this->questionId = $questionId; + + return $this; + } + + /** + * Get questionId + * + * @return integer + */ + public function getQuestionId() + { + return $this->questionId; + } + + /** + * Set optionId + * + * @param string $optionId + * @return CSurveyAnswer + */ + public function setOptionId($optionId) + { + $this->optionId = $optionId; + + return $this; + } + + /** + * Get optionId + * + * @return string + */ + public function getOptionId() + { + return $this->optionId; + } + + /** + * Set value + * + * @param integer $value + * @return CSurveyAnswer + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return integer + */ + public function getValue() + { + return $this->value; + } + + /** + * Set user + * + * @param string $user + * @return CSurveyAnswer + */ + public function setUser($user) + { + $this->user = $user; + + return $this; + } + + /** + * Get user + * + * @return string + */ + public function getUser() + { + return $this->user; + } + + /** + * Set answerId + * + * @param integer $answerId + * @return CSurveyAnswer + */ + public function setAnswerId($answerId) + { + $this->answerId = $answerId; + + return $this; + } + + /** + * Get answerId + * + * @return integer + */ + public function getAnswerId() + { + return $this->answerId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CSurveyAnswer + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CSurveyGroup.php b/src/Chamilo/CourseBundle/Entity/CSurveyGroup.php new file mode 100644 index 0000000000..dc87acfedc --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CSurveyGroup.php @@ -0,0 +1,174 @@ +name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set description + * + * @param string $description + * @return CSurveyGroup + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set surveyId + * + * @param integer $surveyId + * @return CSurveyGroup + */ + public function setSurveyId($surveyId) + { + $this->surveyId = $surveyId; + + return $this; + } + + /** + * Get surveyId + * + * @return integer + */ + public function getSurveyId() + { + return $this->surveyId; + } + + /** + * Set id + * + * @param integer $id + * @return CSurveyGroup + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CSurveyGroup + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CSurveyInvitation.php b/src/Chamilo/CourseBundle/Entity/CSurveyInvitation.php new file mode 100644 index 0000000000..2fdedc8b00 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CSurveyInvitation.php @@ -0,0 +1,325 @@ +surveyCode = $surveyCode; + + return $this; + } + + /** + * Get surveyCode + * + * @return string + */ + public function getSurveyCode() + { + return $this->surveyCode; + } + + /** + * Set user + * + * @param string $user + * @return CSurveyInvitation + */ + public function setUser($user) + { + $this->user = $user; + + return $this; + } + + /** + * Get user + * + * @return string + */ + public function getUser() + { + return $this->user; + } + + /** + * Set invitationCode + * + * @param string $invitationCode + * @return CSurveyInvitation + */ + public function setInvitationCode($invitationCode) + { + $this->invitationCode = $invitationCode; + + return $this; + } + + /** + * Get invitationCode + * + * @return string + */ + public function getInvitationCode() + { + return $this->invitationCode; + } + + /** + * Set invitationDate + * + * @param \DateTime $invitationDate + * @return CSurveyInvitation + */ + public function setInvitationDate($invitationDate) + { + $this->invitationDate = $invitationDate; + + return $this; + } + + /** + * Get invitationDate + * + * @return \DateTime + */ + public function getInvitationDate() + { + return $this->invitationDate; + } + + /** + * Set reminderDate + * + * @param \DateTime $reminderDate + * @return CSurveyInvitation + */ + public function setReminderDate($reminderDate) + { + $this->reminderDate = $reminderDate; + + return $this; + } + + /** + * Get reminderDate + * + * @return \DateTime + */ + public function getReminderDate() + { + return $this->reminderDate; + } + + /** + * Set answered + * + * @param integer $answered + * @return CSurveyInvitation + */ + public function setAnswered($answered) + { + $this->answered = $answered; + + return $this; + } + + /** + * Get answered + * + * @return integer + */ + public function getAnswered() + { + return $this->answered; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CSurveyInvitation + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set groupId + * + * @param integer $groupId + * @return CSurveyInvitation + */ + public function setGroupId($groupId) + { + $this->groupId = $groupId; + + return $this; + } + + /** + * Get groupId + * + * @return integer + */ + public function getGroupId() + { + return $this->groupId; + } + + /** + * Set surveyInvitationId + * + * @param integer $surveyInvitationId + * @return CSurveyInvitation + */ + public function setSurveyInvitationId($surveyInvitationId) + { + $this->surveyInvitationId = $surveyInvitationId; + + return $this; + } + + /** + * Get surveyInvitationId + * + * @return integer + */ + public function getSurveyInvitationId() + { + return $this->surveyInvitationId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CSurveyInvitation + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CSurveyQuestion.php b/src/Chamilo/CourseBundle/Entity/CSurveyQuestion.php new file mode 100644 index 0000000000..8ffcfcf705 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CSurveyQuestion.php @@ -0,0 +1,414 @@ +surveyId = $surveyId; + + return $this; + } + + /** + * Get surveyId + * + * @return integer + */ + public function getSurveyId() + { + return $this->surveyId; + } + + /** + * Set surveyQuestion + * + * @param string $surveyQuestion + * @return CSurveyQuestion + */ + public function setSurveyQuestion($surveyQuestion) + { + $this->surveyQuestion = $surveyQuestion; + + return $this; + } + + /** + * Get surveyQuestion + * + * @return string + */ + public function getSurveyQuestion() + { + return $this->surveyQuestion; + } + + /** + * Set surveyQuestionComment + * + * @param string $surveyQuestionComment + * @return CSurveyQuestion + */ + public function setSurveyQuestionComment($surveyQuestionComment) + { + $this->surveyQuestionComment = $surveyQuestionComment; + + return $this; + } + + /** + * Get surveyQuestionComment + * + * @return string + */ + public function getSurveyQuestionComment() + { + return $this->surveyQuestionComment; + } + + /** + * Set type + * + * @param string $type + * @return CSurveyQuestion + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set display + * + * @param string $display + * @return CSurveyQuestion + */ + public function setDisplay($display) + { + $this->display = $display; + + return $this; + } + + /** + * Get display + * + * @return string + */ + public function getDisplay() + { + return $this->display; + } + + /** + * Set sort + * + * @param integer $sort + * @return CSurveyQuestion + */ + public function setSort($sort) + { + $this->sort = $sort; + + return $this; + } + + /** + * Get sort + * + * @return integer + */ + public function getSort() + { + return $this->sort; + } + + /** + * Set sharedQuestionId + * + * @param integer $sharedQuestionId + * @return CSurveyQuestion + */ + public function setSharedQuestionId($sharedQuestionId) + { + $this->sharedQuestionId = $sharedQuestionId; + + return $this; + } + + /** + * Get sharedQuestionId + * + * @return integer + */ + public function getSharedQuestionId() + { + return $this->sharedQuestionId; + } + + /** + * Set maxValue + * + * @param integer $maxValue + * @return CSurveyQuestion + */ + public function setMaxValue($maxValue) + { + $this->maxValue = $maxValue; + + return $this; + } + + /** + * Get maxValue + * + * @return integer + */ + public function getMaxValue() + { + return $this->maxValue; + } + + /** + * Set surveyGroupPri + * + * @param integer $surveyGroupPri + * @return CSurveyQuestion + */ + public function setSurveyGroupPri($surveyGroupPri) + { + $this->surveyGroupPri = $surveyGroupPri; + + return $this; + } + + /** + * Get surveyGroupPri + * + * @return integer + */ + public function getSurveyGroupPri() + { + return $this->surveyGroupPri; + } + + /** + * Set surveyGroupSec1 + * + * @param integer $surveyGroupSec1 + * @return CSurveyQuestion + */ + public function setSurveyGroupSec1($surveyGroupSec1) + { + $this->surveyGroupSec1 = $surveyGroupSec1; + + return $this; + } + + /** + * Get surveyGroupSec1 + * + * @return integer + */ + public function getSurveyGroupSec1() + { + return $this->surveyGroupSec1; + } + + /** + * Set surveyGroupSec2 + * + * @param integer $surveyGroupSec2 + * @return CSurveyQuestion + */ + public function setSurveyGroupSec2($surveyGroupSec2) + { + $this->surveyGroupSec2 = $surveyGroupSec2; + + return $this; + } + + /** + * Get surveyGroupSec2 + * + * @return integer + */ + public function getSurveyGroupSec2() + { + return $this->surveyGroupSec2; + } + + /** + * Set questionId + * + * @param integer $questionId + * @return CSurveyQuestion + */ + public function setQuestionId($questionId) + { + $this->questionId = $questionId; + + return $this; + } + + /** + * Get questionId + * + * @return integer + */ + public function getQuestionId() + { + return $this->questionId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CSurveyQuestion + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CSurveyQuestionOption.php b/src/Chamilo/CourseBundle/Entity/CSurveyQuestionOption.php new file mode 100644 index 0000000000..52cc05d847 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CSurveyQuestionOption.php @@ -0,0 +1,234 @@ +questionId = $questionId; + + return $this; + } + + /** + * Get questionId + * + * @return integer + */ + public function getQuestionId() + { + return $this->questionId; + } + + /** + * Set surveyId + * + * @param integer $surveyId + * @return CSurveyQuestionOption + */ + public function setSurveyId($surveyId) + { + $this->surveyId = $surveyId; + + return $this; + } + + /** + * Get surveyId + * + * @return integer + */ + public function getSurveyId() + { + return $this->surveyId; + } + + /** + * Set optionText + * + * @param string $optionText + * @return CSurveyQuestionOption + */ + public function setOptionText($optionText) + { + $this->optionText = $optionText; + + return $this; + } + + /** + * Get optionText + * + * @return string + */ + public function getOptionText() + { + return $this->optionText; + } + + /** + * Set sort + * + * @param integer $sort + * @return CSurveyQuestionOption + */ + public function setSort($sort) + { + $this->sort = $sort; + + return $this; + } + + /** + * Get sort + * + * @return integer + */ + public function getSort() + { + return $this->sort; + } + + /** + * Set value + * + * @param integer $value + * @return CSurveyQuestionOption + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return integer + */ + public function getValue() + { + return $this->value; + } + + /** + * Set questionOptionId + * + * @param integer $questionOptionId + * @return CSurveyQuestionOption + */ + public function setQuestionOptionId($questionOptionId) + { + $this->questionOptionId = $questionOptionId; + + return $this; + } + + /** + * Get questionOptionId + * + * @return integer + */ + public function getQuestionOptionId() + { + return $this->questionOptionId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CSurveyQuestionOption + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CThematic.php b/src/Chamilo/CourseBundle/Entity/CThematic.php new file mode 100644 index 0000000000..a5bc912e8f --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CThematic.php @@ -0,0 +1,234 @@ +title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set content + * + * @param string $content + * @return CThematic + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Set displayOrder + * + * @param integer $displayOrder + * @return CThematic + */ + public function setDisplayOrder($displayOrder) + { + $this->displayOrder = $displayOrder; + + return $this; + } + + /** + * Get displayOrder + * + * @return integer + */ + public function getDisplayOrder() + { + return $this->displayOrder; + } + + /** + * Set active + * + * @param boolean $active + * @return CThematic + */ + public function setActive($active) + { + $this->active = $active; + + return $this; + } + + /** + * Get active + * + * @return boolean + */ + public function getActive() + { + return $this->active; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CThematic + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set id + * + * @param integer $id + * @return CThematic + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CThematic + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CThematicAdvance.php b/src/Chamilo/CourseBundle/Entity/CThematicAdvance.php new file mode 100644 index 0000000000..5e9e869b94 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CThematicAdvance.php @@ -0,0 +1,264 @@ +thematicId = $thematicId; + + return $this; + } + + /** + * Get thematicId + * + * @return integer + */ + public function getThematicId() + { + return $this->thematicId; + } + + /** + * Set attendanceId + * + * @param integer $attendanceId + * @return CThematicAdvance + */ + public function setAttendanceId($attendanceId) + { + $this->attendanceId = $attendanceId; + + return $this; + } + + /** + * Get attendanceId + * + * @return integer + */ + public function getAttendanceId() + { + return $this->attendanceId; + } + + /** + * Set content + * + * @param string $content + * @return CThematicAdvance + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Set startDate + * + * @param \DateTime $startDate + * @return CThematicAdvance + */ + public function setStartDate($startDate) + { + $this->startDate = $startDate; + + return $this; + } + + /** + * Get startDate + * + * @return \DateTime + */ + public function getStartDate() + { + return $this->startDate; + } + + /** + * Set duration + * + * @param integer $duration + * @return CThematicAdvance + */ + public function setDuration($duration) + { + $this->duration = $duration; + + return $this; + } + + /** + * Get duration + * + * @return integer + */ + public function getDuration() + { + return $this->duration; + } + + /** + * Set doneAdvance + * + * @param boolean $doneAdvance + * @return CThematicAdvance + */ + public function setDoneAdvance($doneAdvance) + { + $this->doneAdvance = $doneAdvance; + + return $this; + } + + /** + * Get doneAdvance + * + * @return boolean + */ + public function getDoneAdvance() + { + return $this->doneAdvance; + } + + /** + * Set id + * + * @param integer $id + * @return CThematicAdvance + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CThematicAdvance + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CThematicPlan.php b/src/Chamilo/CourseBundle/Entity/CThematicPlan.php new file mode 100644 index 0000000000..75c23386f0 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CThematicPlan.php @@ -0,0 +1,204 @@ +thematicId = $thematicId; + + return $this; + } + + /** + * Get thematicId + * + * @return integer + */ + public function getThematicId() + { + return $this->thematicId; + } + + /** + * Set title + * + * @param string $title + * @return CThematicPlan + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set description + * + * @param string $description + * @return CThematicPlan + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set descriptionType + * + * @param integer $descriptionType + * @return CThematicPlan + */ + public function setDescriptionType($descriptionType) + { + $this->descriptionType = $descriptionType; + + return $this; + } + + /** + * Get descriptionType + * + * @return integer + */ + public function getDescriptionType() + { + return $this->descriptionType; + } + + /** + * Set id + * + * @param integer $id + * @return CThematicPlan + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CThematicPlan + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CTool.php b/src/Chamilo/CourseBundle/Entity/CTool.php index 3c1c2b49f6..72c82d88d6 100644 --- a/src/Chamilo/CourseBundle/Entity/CTool.php +++ b/src/Chamilo/CourseBundle/Entity/CTool.php @@ -4,16 +4,10 @@ namespace Chamilo\CourseBundle\Entity; use Doctrine\ORM\Mapping as ORM; -use Symfony\Component\Validator\Constraints as Assert; -use Symfony\Component\Validator\Mapping\ClassMetadata; -use Chamilo\CoreBundle\Entity\Course; -use Symfony\Component\HttpFoundation\File\UploadedFile; -use APY\DataGridBundle\Grid\Mapping as GRID; /** * CTool - * @GRID\Source(columns="iid, name") - * @ORM\HasLifecycleCallbacks + * * @ORM\Table(name="c_tool", indexes={@ORM\Index(name="session_id", columns={"session_id"})}) * @ORM\Entity */ @@ -22,301 +16,101 @@ class CTool /** * @var integer * - * @ORM\Column(name="iid", type="integer", precision=0, scale=0, nullable=false, unique=false) + * @ORM\Column(name="iid", type="integer") * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") + * @ORM\GeneratedValue */ private $iid; /** * @var integer * - * @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false) + * @ORM\Column(name="id", type="integer", nullable=true) */ private $id; /** * @var integer * - * @ORM\Column(name="c_id", type="integer", precision=0, scale=0, nullable=false, unique=false) + * @ORM\Column(name="c_id", type="integer") */ private $cId; /** * @var string * - * @ORM\Column(name="name", type="string", length=255, precision=0, scale=0, nullable=false, unique=false) + * @ORM\Column(name="name", type="string", length=255, nullable=false) */ private $name; /** * @var string * - * @ORM\Column(name="link", type="string", length=255, precision=0, scale=0, nullable=false, unique=false) + * @ORM\Column(name="link", type="string", length=255, nullable=false) */ private $link; /** * @var string - * @ORM\Column(name="image", type="string", length=255, precision=0, scale=0, nullable=true, unique=false) + * + * @ORM\Column(name="image", type="string", length=255, nullable=true) */ private $image; - /** - * @var string - * @ORM\Column(name="custom_icon", type="string", length=255, precision=0, scale=0, nullable=true, unique=false) - */ - private $customIcon; - /** * @var boolean * - * @ORM\Column(name="visibility", type="boolean", precision=0, scale=0, nullable=true, unique=false) + * @ORM\Column(name="visibility", type="boolean", nullable=true) */ private $visibility; /** * @var string * - * @ORM\Column(name="admin", type="string", length=255, precision=0, scale=0, nullable=true, unique=false) + * @ORM\Column(name="admin", type="string", length=255, nullable=true) */ private $admin; /** * @var string * - * @ORM\Column(name="address", type="string", length=255, precision=0, scale=0, nullable=true, unique=false) + * @ORM\Column(name="address", type="string", length=255, nullable=true) */ private $address; /** * @var boolean * - * @ORM\Column(name="added_tool", type="boolean", precision=0, scale=0, nullable=true, unique=false) + * @ORM\Column(name="added_tool", type="boolean", nullable=true) */ private $addedTool; /** * @var string * - * @ORM\Column(name="target", type="string", precision=0, scale=0, nullable=false, unique=false) + * @ORM\Column(name="target", type="string", length=20, nullable=false) */ private $target; /** * @var string * - * @ORM\Column(name="category", type="string", length=20, precision=0, scale=0, nullable=false, unique=false) + * @ORM\Column(name="category", type="string", length=20, nullable=false, options={"default" = "authoring"}) */ private $category; /** * @var integer * - * @ORM\Column(name="session_id", type="integer", precision=0, scale=0, nullable=true, unique=false) + * @ORM\Column(name="session_id", type="integer", nullable=true) */ private $sessionId; - /** - * @var string - * - * @ORM\Column(name="description", type="text", precision=0, scale=0, nullable=true, unique=false) - */ - private $description; - - /** - * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", inversedBy="tools") - * @ORM\JoinColumn(name="c_id", referencedColumnName="id") - */ - private $course; - - protected $originalImage; - - /** - */ - public function __construct() - { - // Default values - $this->id = 0; - $this->sessionId = 0; - $this->address = 'squaregrey.gif'; - } - - /** - * @param Course $course - */ - public function setCourse($course) - { - $this->course = $course; - } - - /** - * @param ClassMetadata $metadata - */ - public static function loadValidatorMetadata(ClassMetadata $metadata) - { - $metadata->addPropertyConstraint( - 'customIcon', - new Assert\File(array('mimeTypes' => array("image/png"))) - ); - $metadata->addPropertyConstraint( - 'customIcon', - new Assert\Image(array('maxWidth' => 64, 'minHeight' => 64)) - ); - $metadata->addPropertyConstraint('cId', new Assert\NotBlank()); - } - - /** - * @return Course - */ - public function getCourse() - { - return $this->course; - } - - /** - * @return null|string - */ - public function getAbsolutePath() - { - return null === $this->getCustomIcon() - ? null - : $this->getUploadRootDir().'/'.$this->getCustomIcon(); - } - - /** - * @return string - */ - protected function getUploadRootDir() - { - // the absolute directory path where uploaded - // documents should be saved - $dir = $this->getCourse()->getAbsoluteSysCoursePath().$this->getUploadDir(); - - if (is_dir($dir)) { - return $dir; - } else { - mkdir($dir); - return $dir; - } - } - - /** - * @return string - */ - protected function getUploadDir() - { - // get rid of the __DIR__ so it doesn't screw up - // when displaying uploaded doc/image in the view. - return 'upload/course_home_icons'; - } - - /** - * Called before saving the entity - * - * @ORM\PrePersist() - * @ORM\PreUpdate() - */ - public function preUpload() - { - if (null !== $this->getCustomIcon()) { - - // do whatever you want to generate a unique name - //$filename = sha1(uniqid(mt_rand(), true)); - $this->originalImage = $this->getCustomIcon(); - $this->customIcon = $this->getName().'_'.$this->getSessionId().'.'.$this->getCustomIcon()->guessExtension(); - } - } - - /** - * Called before entity removal - * - * @ORM\PostRemove() - */ - public function removeUpload() - { - if ($file = $this->getAbsolutePath()) { - unlink($file); - } - } - - /** - * Called after entity persistence - * - * @ORM\PostPersist() - * @ORM\PostUpdate() - */ - public function upload() - { - // the file property can be empty if the field is not required - if (null === $this->getCustomIcon()) { - return; - } - - // use the original file name here but you should - // sanitize it at least to avoid any security issues - - // move takes the target directory and then the - // target filename to move to - $this->originalImage->move( - $this->getUploadRootDir(), - $this->customIcon - ); - - // clean up the file property as you won't need it anymore - $this->originalImage = null; - } - - /** - * Set cId - * - * @param integer $cId - * @return CTool - */ - public function setCId($cId) - { - $this->cId = $cId; - - return $this; - } - - /** - * Get cId - * - * @return integer - */ - public function getCId() - { - return $this->cId; - } - - /** - * Set id - * - * @param integer $id - * @return CTool - */ - public function setId($id) - { - $this->id = $id; - - return $this; - } - - /** - * Get id - * - * @return integer - */ - public function getId() - { - return $this->id; - } - /** * Set name * * @param string $name + * * @return CTool */ public function setName($name) @@ -544,69 +338,48 @@ class CTool } /** - * @return string + * Set id + * + * @param integer $id + * @return CTool */ - public function getCustomIcon() + public function setId($id) { - return $this->customIcon; - } + $this->id = $id; - /** - * @param string $customIcon - * @return $this - */ - public function setCustomIcon($customIcon) - { - $this->customIcon = $customIcon; return $this; } /** - * @return string + * Get id + * + * @return integer */ - public function getDescription() + public function getId() { - return $this->description; + return $this->id; } /** - * @param string $description - * @return $this + * Set cId + * + * @param integer $cId + * @return CTool */ - public function setDescription($description) + public function setCId($cId) { - $this->description = $description; - return $this; - } + $this->cId = $cId; - /** - * Creates a gray icon. - * @param \Imagine\Image\ImagineInterface $imagine - * @return bool - */ - public function createGrayIcon($imagine) - { - $customIcon = $this->getCustomIcon(); - if (empty($customIcon)) { - return false; - } - if (file_exists($this->getAbsolutePath())) { - $image = $imagine->open($this->getAbsolutePath()); - $fileInfo = pathinfo($this->getAbsolutePath()); - $originalFilename = $fileInfo['basename']; - $filename = $fileInfo['filename'].'_na.'.$fileInfo['extension']; - $newPath = str_replace($originalFilename, $filename, $this->getAbsolutePath()); - $transformation = new \Imagine\Filter\Advanced\Grayscale(); - $transformation->apply($image)->save($newPath); - } + return $this; } /** - * Replace the $this->image png extension to gif - * @return string + * Get cId + * + * @return integer */ - public function imageGifToPng() + public function getCId() { - return str_replace('.gif', '.png', $this->getImage()); + return $this->cId; } } diff --git a/src/Chamilo/CourseBundle/Entity/CToolIntro.php b/src/Chamilo/CourseBundle/Entity/CToolIntro.php new file mode 100644 index 0000000000..0916b7cba6 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CToolIntro.php @@ -0,0 +1,144 @@ +introText = $introText; + + return $this; + } + + /** + * Get introText + * + * @return string + */ + public function getIntroText() + { + return $this->introText; + } + + /** + * Set id + * + * @param string $id + * @return CToolIntro + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CToolIntro + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CToolIntro + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CUserinfoContent.php b/src/Chamilo/CourseBundle/Entity/CUserinfoContent.php new file mode 100644 index 0000000000..a1290bd195 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CUserinfoContent.php @@ -0,0 +1,234 @@ +userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set definitionId + * + * @param integer $definitionId + * @return CUserinfoContent + */ + public function setDefinitionId($definitionId) + { + $this->definitionId = $definitionId; + + return $this; + } + + /** + * Get definitionId + * + * @return integer + */ + public function getDefinitionId() + { + return $this->definitionId; + } + + /** + * Set editorIp + * + * @param string $editorIp + * @return CUserinfoContent + */ + public function setEditorIp($editorIp) + { + $this->editorIp = $editorIp; + + return $this; + } + + /** + * Get editorIp + * + * @return string + */ + public function getEditorIp() + { + return $this->editorIp; + } + + /** + * Set editionTime + * + * @param \DateTime $editionTime + * @return CUserinfoContent + */ + public function setEditionTime($editionTime) + { + $this->editionTime = $editionTime; + + return $this; + } + + /** + * Get editionTime + * + * @return \DateTime + */ + public function getEditionTime() + { + return $this->editionTime; + } + + /** + * Set content + * + * @param string $content + * @return CUserinfoContent + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Set id + * + * @param integer $id + * @return CUserinfoContent + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CUserinfoContent + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CUserinfoDef.php b/src/Chamilo/CourseBundle/Entity/CUserinfoDef.php new file mode 100644 index 0000000000..89a00ddad0 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CUserinfoDef.php @@ -0,0 +1,204 @@ +title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set comment + * + * @param string $comment + * @return CUserinfoDef + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set lineCount + * + * @param boolean $lineCount + * @return CUserinfoDef + */ + public function setLineCount($lineCount) + { + $this->lineCount = $lineCount; + + return $this; + } + + /** + * Get lineCount + * + * @return boolean + */ + public function getLineCount() + { + return $this->lineCount; + } + + /** + * Set rank + * + * @param boolean $rank + * @return CUserinfoDef + */ + public function setRank($rank) + { + $this->rank = $rank; + + return $this; + } + + /** + * Get rank + * + * @return boolean + */ + public function getRank() + { + return $this->rank; + } + + /** + * Set id + * + * @param integer $id + * @return CUserinfoDef + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CUserinfoDef + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CWiki.php b/src/Chamilo/CourseBundle/Entity/CWiki.php new file mode 100644 index 0000000000..f5e64a14e6 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CWiki.php @@ -0,0 +1,834 @@ +pageId = $pageId; + + return $this; + } + + /** + * Get pageId + * + * @return integer + */ + public function getPageId() + { + return $this->pageId; + } + + /** + * Set reflink + * + * @param string $reflink + * @return CWiki + */ + public function setReflink($reflink) + { + $this->reflink = $reflink; + + return $this; + } + + /** + * Get reflink + * + * @return string + */ + public function getReflink() + { + return $this->reflink; + } + + /** + * Set title + * + * @param string $title + * @return CWiki + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set content + * + * @param string $content + * @return CWiki + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Set userId + * + * @param integer $userId + * @return CWiki + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set groupId + * + * @param integer $groupId + * @return CWiki + */ + public function setGroupId($groupId) + { + $this->groupId = $groupId; + + return $this; + } + + /** + * Get groupId + * + * @return integer + */ + public function getGroupId() + { + return $this->groupId; + } + + /** + * Set dtime + * + * @param \DateTime $dtime + * @return CWiki + */ + public function setDtime($dtime) + { + $this->dtime = $dtime; + + return $this; + } + + /** + * Get dtime + * + * @return \DateTime + */ + public function getDtime() + { + return $this->dtime; + } + + /** + * Set addlock + * + * @param integer $addlock + * @return CWiki + */ + public function setAddlock($addlock) + { + $this->addlock = $addlock; + + return $this; + } + + /** + * Get addlock + * + * @return integer + */ + public function getAddlock() + { + return $this->addlock; + } + + /** + * Set editlock + * + * @param integer $editlock + * @return CWiki + */ + public function setEditlock($editlock) + { + $this->editlock = $editlock; + + return $this; + } + + /** + * Get editlock + * + * @return integer + */ + public function getEditlock() + { + return $this->editlock; + } + + /** + * Set visibility + * + * @param integer $visibility + * @return CWiki + */ + public function setVisibility($visibility) + { + $this->visibility = $visibility; + + return $this; + } + + /** + * Get visibility + * + * @return integer + */ + public function getVisibility() + { + return $this->visibility; + } + + /** + * Set addlockDisc + * + * @param integer $addlockDisc + * @return CWiki + */ + public function setAddlockDisc($addlockDisc) + { + $this->addlockDisc = $addlockDisc; + + return $this; + } + + /** + * Get addlockDisc + * + * @return integer + */ + public function getAddlockDisc() + { + return $this->addlockDisc; + } + + /** + * Set visibilityDisc + * + * @param integer $visibilityDisc + * @return CWiki + */ + public function setVisibilityDisc($visibilityDisc) + { + $this->visibilityDisc = $visibilityDisc; + + return $this; + } + + /** + * Get visibilityDisc + * + * @return integer + */ + public function getVisibilityDisc() + { + return $this->visibilityDisc; + } + + /** + * Set ratinglockDisc + * + * @param integer $ratinglockDisc + * @return CWiki + */ + public function setRatinglockDisc($ratinglockDisc) + { + $this->ratinglockDisc = $ratinglockDisc; + + return $this; + } + + /** + * Get ratinglockDisc + * + * @return integer + */ + public function getRatinglockDisc() + { + return $this->ratinglockDisc; + } + + /** + * Set assignment + * + * @param integer $assignment + * @return CWiki + */ + public function setAssignment($assignment) + { + $this->assignment = $assignment; + + return $this; + } + + /** + * Get assignment + * + * @return integer + */ + public function getAssignment() + { + return $this->assignment; + } + + /** + * Set comment + * + * @param string $comment + * @return CWiki + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set progress + * + * @param string $progress + * @return CWiki + */ + public function setProgress($progress) + { + $this->progress = $progress; + + return $this; + } + + /** + * Get progress + * + * @return string + */ + public function getProgress() + { + return $this->progress; + } + + /** + * Set score + * + * @param integer $score + * @return CWiki + */ + public function setScore($score) + { + $this->score = $score; + + return $this; + } + + /** + * Get score + * + * @return integer + */ + public function getScore() + { + return $this->score; + } + + /** + * Set version + * + * @param integer $version + * @return CWiki + */ + public function setVersion($version) + { + $this->version = $version; + + return $this; + } + + /** + * Get version + * + * @return integer + */ + public function getVersion() + { + return $this->version; + } + + /** + * Set isEditing + * + * @param integer $isEditing + * @return CWiki + */ + public function setIsEditing($isEditing) + { + $this->isEditing = $isEditing; + + return $this; + } + + /** + * Get isEditing + * + * @return integer + */ + public function getIsEditing() + { + return $this->isEditing; + } + + /** + * Set timeEdit + * + * @param \DateTime $timeEdit + * @return CWiki + */ + public function setTimeEdit($timeEdit) + { + $this->timeEdit = $timeEdit; + + return $this; + } + + /** + * Get timeEdit + * + * @return \DateTime + */ + public function getTimeEdit() + { + return $this->timeEdit; + } + + /** + * Set hits + * + * @param integer $hits + * @return CWiki + */ + public function setHits($hits) + { + $this->hits = $hits; + + return $this; + } + + /** + * Get hits + * + * @return integer + */ + public function getHits() + { + return $this->hits; + } + + /** + * Set linksto + * + * @param string $linksto + * @return CWiki + */ + public function setLinksto($linksto) + { + $this->linksto = $linksto; + + return $this; + } + + /** + * Get linksto + * + * @return string + */ + public function getLinksto() + { + return $this->linksto; + } + + /** + * Set tag + * + * @param string $tag + * @return CWiki + */ + public function setTag($tag) + { + $this->tag = $tag; + + return $this; + } + + /** + * Get tag + * + * @return string + */ + public function getTag() + { + return $this->tag; + } + + /** + * Set userIp + * + * @param string $userIp + * @return CWiki + */ + public function setUserIp($userIp) + { + $this->userIp = $userIp; + + return $this; + } + + /** + * Get userIp + * + * @return string + */ + public function getUserIp() + { + return $this->userIp; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CWiki + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set id + * + * @param integer $id + * @return CWiki + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CWiki + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CWikiConf.php b/src/Chamilo/CourseBundle/Entity/CWikiConf.php new file mode 100644 index 0000000000..ff87cd9a21 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CWikiConf.php @@ -0,0 +1,478 @@ +task = $task; + + return $this; + } + + /** + * Get task + * + * @return string + */ + public function getTask() + { + return $this->task; + } + + /** + * Set feedback1 + * + * @param string $feedback1 + * @return CWikiConf + */ + public function setFeedback1($feedback1) + { + $this->feedback1 = $feedback1; + + return $this; + } + + /** + * Get feedback1 + * + * @return string + */ + public function getFeedback1() + { + return $this->feedback1; + } + + /** + * Set feedback2 + * + * @param string $feedback2 + * @return CWikiConf + */ + public function setFeedback2($feedback2) + { + $this->feedback2 = $feedback2; + + return $this; + } + + /** + * Get feedback2 + * + * @return string + */ + public function getFeedback2() + { + return $this->feedback2; + } + + /** + * Set feedback3 + * + * @param string $feedback3 + * @return CWikiConf + */ + public function setFeedback3($feedback3) + { + $this->feedback3 = $feedback3; + + return $this; + } + + /** + * Get feedback3 + * + * @return string + */ + public function getFeedback3() + { + return $this->feedback3; + } + + /** + * Set fprogress1 + * + * @param string $fprogress1 + * @return CWikiConf + */ + public function setFprogress1($fprogress1) + { + $this->fprogress1 = $fprogress1; + + return $this; + } + + /** + * Get fprogress1 + * + * @return string + */ + public function getFprogress1() + { + return $this->fprogress1; + } + + /** + * Set fprogress2 + * + * @param string $fprogress2 + * @return CWikiConf + */ + public function setFprogress2($fprogress2) + { + $this->fprogress2 = $fprogress2; + + return $this; + } + + /** + * Get fprogress2 + * + * @return string + */ + public function getFprogress2() + { + return $this->fprogress2; + } + + /** + * Set fprogress3 + * + * @param string $fprogress3 + * @return CWikiConf + */ + public function setFprogress3($fprogress3) + { + $this->fprogress3 = $fprogress3; + + return $this; + } + + /** + * Get fprogress3 + * + * @return string + */ + public function getFprogress3() + { + return $this->fprogress3; + } + + /** + * Set maxSize + * + * @param integer $maxSize + * @return CWikiConf + */ + public function setMaxSize($maxSize) + { + $this->maxSize = $maxSize; + + return $this; + } + + /** + * Get maxSize + * + * @return integer + */ + public function getMaxSize() + { + return $this->maxSize; + } + + /** + * Set maxText + * + * @param integer $maxText + * @return CWikiConf + */ + public function setMaxText($maxText) + { + $this->maxText = $maxText; + + return $this; + } + + /** + * Get maxText + * + * @return integer + */ + public function getMaxText() + { + return $this->maxText; + } + + /** + * Set maxVersion + * + * @param integer $maxVersion + * @return CWikiConf + */ + public function setMaxVersion($maxVersion) + { + $this->maxVersion = $maxVersion; + + return $this; + } + + /** + * Get maxVersion + * + * @return integer + */ + public function getMaxVersion() + { + return $this->maxVersion; + } + + /** + * Set startdateAssig + * + * @param \DateTime $startdateAssig + * @return CWikiConf + */ + public function setStartdateAssig($startdateAssig) + { + $this->startdateAssig = $startdateAssig; + + return $this; + } + + /** + * Get startdateAssig + * + * @return \DateTime + */ + public function getStartdateAssig() + { + return $this->startdateAssig; + } + + /** + * Set enddateAssig + * + * @param \DateTime $enddateAssig + * @return CWikiConf + */ + public function setEnddateAssig($enddateAssig) + { + $this->enddateAssig = $enddateAssig; + + return $this; + } + + /** + * Get enddateAssig + * + * @return \DateTime + */ + public function getEnddateAssig() + { + return $this->enddateAssig; + } + + /** + * Set delayedsubmit + * + * @param integer $delayedsubmit + * @return CWikiConf + */ + public function setDelayedsubmit($delayedsubmit) + { + $this->delayedsubmit = $delayedsubmit; + + return $this; + } + + /** + * Get delayedsubmit + * + * @return integer + */ + public function getDelayedsubmit() + { + return $this->delayedsubmit; + } + + /** + * Set cId + * + * @param integer $cId + * @return CWikiConf + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set pageId + * + * @param integer $pageId + * @return CWikiConf + */ + public function setPageId($pageId) + { + $this->pageId = $pageId; + + return $this; + } + + /** + * Get pageId + * + * @return integer + */ + public function getPageId() + { + return $this->pageId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CWikiDiscuss.php b/src/Chamilo/CourseBundle/Entity/CWikiDiscuss.php new file mode 100644 index 0000000000..724d0f2540 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CWikiDiscuss.php @@ -0,0 +1,234 @@ +publicationId = $publicationId; + + return $this; + } + + /** + * Get publicationId + * + * @return integer + */ + public function getPublicationId() + { + return $this->publicationId; + } + + /** + * Set usercId + * + * @param integer $usercId + * @return CWikiDiscuss + */ + public function setUsercId($usercId) + { + $this->usercId = $usercId; + + return $this; + } + + /** + * Get usercId + * + * @return integer + */ + public function getUsercId() + { + return $this->usercId; + } + + /** + * Set comment + * + * @param string $comment + * @return CWikiDiscuss + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set pScore + * + * @param string $pScore + * @return CWikiDiscuss + */ + public function setPScore($pScore) + { + $this->pScore = $pScore; + + return $this; + } + + /** + * Get pScore + * + * @return string + */ + public function getPScore() + { + return $this->pScore; + } + + /** + * Set dtime + * + * @param \DateTime $dtime + * @return CWikiDiscuss + */ + public function setDtime($dtime) + { + $this->dtime = $dtime; + + return $this; + } + + /** + * Get dtime + * + * @return \DateTime + */ + public function getDtime() + { + return $this->dtime; + } + + /** + * Set id + * + * @param integer $id + * @return CWikiDiscuss + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set cId + * + * @param integer $cId + * @return CWikiDiscuss + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } +} diff --git a/src/Chamilo/CourseBundle/Entity/CWikiMailcue.php b/src/Chamilo/CourseBundle/Entity/CWikiMailcue.php new file mode 100644 index 0000000000..c84455e7c6 --- /dev/null +++ b/src/Chamilo/CourseBundle/Entity/CWikiMailcue.php @@ -0,0 +1,204 @@ +type = $type; + + return $this; + } + + /** + * Get type + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set groupId + * + * @param integer $groupId + * @return CWikiMailcue + */ + public function setGroupId($groupId) + { + $this->groupId = $groupId; + + return $this; + } + + /** + * Get groupId + * + * @return integer + */ + public function getGroupId() + { + return $this->groupId; + } + + /** + * Set sessionId + * + * @param integer $sessionId + * @return CWikiMailcue + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get sessionId + * + * @return integer + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set cId + * + * @param integer $cId + * @return CWikiMailcue + */ + public function setCId($cId) + { + $this->cId = $cId; + + return $this; + } + + /** + * Get cId + * + * @return integer + */ + public function getCId() + { + return $this->cId; + } + + /** + * Set id + * + * @param integer $id + * @return CWikiMailcue + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set userId + * + * @param integer $userId + * @return CWikiMailcue + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return integer + */ + public function getUserId() + { + return $this->userId; + } +} diff --git a/src/Chamilo/UserBundle/Entity/User.php b/src/Chamilo/UserBundle/Entity/User.php index eea676d2b0..e65b09c270 100644 --- a/src/Chamilo/UserBundle/Entity/User.php +++ b/src/Chamilo/UserBundle/Entity/User.php @@ -136,13 +136,13 @@ class User extends BaseUser //implements ParticipantInterface, ThemeUser * @var string * @ORM\Column(name="picture_uri", type="string", length=250, nullable=true, unique=false) */ - //private $pictureUri; + private $pictureUri; /** * ORM\ManyToOne(targetEntity="Application\Sonata\MediaBundle\Entity\Media", cascade={"all"} ) * @ORM\JoinColumn(name="picture_uri", referencedColumnName="id") */ - protected $pictureUri; + //protected $pictureUri; /** * @var integer @@ -348,7 +348,7 @@ class User extends BaseUser //implements ParticipantInterface, ThemeUser $this->isActive = true; $this->active = 1; $this->registrationDate = new \DateTime(); - + $this->authSource = 'platform'; $this->courses = new ArrayCollection(); $this->items = new ArrayCollection(); $this->classes = new ArrayCollection(); diff --git a/tests/main/inc/lib/export.lib.inc.test.php b/tests/main/inc/lib/export.lib.inc.test.php index 3e28597323..5996decb13 100755 --- a/tests/main/inc/lib/export.lib.inc.test.php +++ b/tests/main/inc/lib/export.lib.inc.test.php @@ -22,7 +22,7 @@ class TestExport extends UnitTestCase { $data = array(); // can only be tested if headers were not sent ob_start(); - $res = Export::export_table_csv($data, $filename = 'export'); + $res = Export::arrayToCsv($data, $filename = 'export'); $this->assertFalse($res); ob_end_clean(); } @@ -32,7 +32,7 @@ class TestExport extends UnitTestCase { $data = array(); $filename = 'export'; ob_start(); - $res=Export::export_table_xls($data,$filename); + $res=Export::arrayToXls($data,$filename); $this->assertFalse($res); ob_end_clean(); } @@ -44,7 +44,7 @@ class TestExport extends UnitTestCase { $wrapper_tagname = null; $encoding=null; ob_start(); - $res=Export::export_table_xml($data,$filename,$item_tagname, + $res=Export::arrayToXml($data,$filename,$item_tagname, $wrapper_tagname,$encoding); $this->assertFalse($res); ob_end_clean(); diff --git a/tests/main/inc/lib/import.lib.test.php b/tests/main/inc/lib/import.lib.test.php index 0ac848bcd6..7e07ed982d 100755 --- a/tests/main/inc/lib/import.lib.test.php +++ b/tests/main/inc/lib/import.lib.test.php @@ -8,7 +8,7 @@ class TestImport extends UnitTestCase { } function testCsvToArray(){ $filename=''; - $res=Import::csv_to_array($filename); + $res=Import::csvToArray($filename); $this->assertTrue(is_array($res)); //var_dump($res); } diff --git a/tests/main/inc/lib/main_api.lib.test.php b/tests/main/inc/lib/main_api.lib.test.php index ef9f6e0f74..1ea64a1aea 100755 --- a/tests/main/inc/lib/main_api.lib.test.php +++ b/tests/main/inc/lib/main_api.lib.test.php @@ -494,16 +494,6 @@ class TestMainApi extends UnitTestCase { $this->assertTrue($cssdir); } - function testApiSendMail(){ - $to= 'chamilotest@beeznest.com'; - $subject='Hello'; - $message='test message'; - $res=api_send_mail($to, $subject, $message, $additional_headers = null, $additional_parameters = null); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - //var_dump($send_mail); - } - function testApiMaxSortValue(){ $user_course_category=1; $user_id =1; @@ -527,15 +517,6 @@ class TestMainApi extends UnitTestCase { $this->assertTrue($_plugins[$location]); } - function testApiPlugin(){ - global $_plugins; - $location=2; - $_plugins[$location]=1; - $res1 = api_plugin($location); - $this->assertFalse($res1); - $this->assertTrue($_plugins[$location]); - } - function testApiIsPluginInstalled(){ $plugin_name = false; $plugin_list = true; @@ -747,9 +728,9 @@ class TestMainApi extends UnitTestCase { function testApiGetStatusOfUserInCourse(){ $id = array( - 'course_code'=>'TEST', + 'c_id'=>'1', 'user_id'=>'1'); - $res=api_get_status_of_user_in_course($id['course_code'],$id['user_id']); + $res=api_get_status_of_user_in_course($id['user_id'], $id['c_id']); $this->assertTrue(is_null($res)); //var_dump($res); } diff --git a/tests/main/inc/lib/sessionmanager.lib.test.php b/tests/main/inc/lib/sessionmanager.lib.test.php index 3dddb88084..de29030568 100755 --- a/tests/main/inc/lib/sessionmanager.lib.test.php +++ b/tests/main/inc/lib/sessionmanager.lib.test.php @@ -63,7 +63,7 @@ class TestSessionManager extends UnitTestCase { global $_user; $id_checked=''; $this->sessionmanager = new SessionManager(); - $res=SessionManager::delete_session($id_checked); + $res=SessionManager::delete($id_checked); $idsesion->expectOnce(Database :: get_main_table(TABLE_MAIN_SESSION)); $this->assertTrue(is_object($idsesion)); $this->assertTrue(is_null($res)); diff --git a/tests/main/inc/lib/stats.lib.inc.test.php b/tests/main/inc/lib/stats.lib.inc.test.php deleted file mode 100755 index b0c66b6f0a..0000000000 --- a/tests/main/inc/lib/stats.lib.inc.test.php +++ /dev/null @@ -1,157 +0,0 @@ -UnitTestCase('System stats library - main/inc/lib/stats.lib.test.php'); - } - - function testaddBrowser() { - $browser=''; - $browsers_array=array(); - $res=addBrowser($browser,$browsers_array); - $this->assertTrue(is_array($res)); - } - - function testaddCountry(){ - $country=''; - $countries_array=array(); - $res=addCountry($country,$countries_array); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - function testaddOs() { - $os=''; - $os_array=array(); - $res=addOs($os,$os_array); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - function testaddProvider() { - $provider=''; - $providers_array=array(); - $res=addProvider($provider,$providers_array); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - function testaddReferer() { - $referer=''; - $referers_array=array(); - $res=addReferer($referer,$referers_array); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - function testcleanProcessedRecords() { - global $TABLETRACK_OPEN; - $limit=''; - $res=cleanProcessedRecords($limit); - if(!is_null($res)) $this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testdecodeOpenInfos() { // 3 excepciones - //ob_start(); - global $_course, $TABLETRACK_OPEN, $_configuration; - $TABLETRACK_OPEN = $_configuration['statistics_database'].".track_e_open"; - $ignore = ignore_user_abort(); - $res=decodeOpenInfos(); - //ob_end_clean(); - if (!is_null($res)){ - $this->assertTrue(is_null($res)); - $this->assertTrue(is_numeric($ignore)); - //var_dump($res); - } - } - - function testextractAgent() { - $user_agent=$_SERVER['HTTP_USER_AGENT']; - $list_browsers=array(); - $list_os=array(); - $res=extractAgent($user_agent, $list_browsers, $list_os ); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testextractCountry() { - $remhost= @getHostByAddr($_SERVER['REMOTE_ADDR']); - $list_countries=array(); - $res=extractCountry($remhost,$list_countries); - if(!is_null($res))$this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testextractProvider() { - $remhost=@getHostByAddr($_SERVER['REMOTE_ADDR']); - $res=extractProvider($remhost); - if(!is_null($res))$this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testfillBrowsersTable() { - global $TABLESTATS_BROWSERS; - $browsers_array=array(); - $res=fillBrowsersTable($browsers_array); - if(!is_null($res)) $this->assertTrue(is_array($res)); - //var_dump($res); - } - - function testfillCountriesTable() { - global $TABLESTATS_COUNTRIES,$_configuration; - $TABLESTATS_COUNTRIES = $_configuration['statistics_database'].".track_c_countries"; - $countries_array=array(); - $res=fillCountriesTable($countries_array); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - function testfillOsTable() { - global $TABLESTATS_OS; - $os_array=array(); - $res=fillOsTable($os_array); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - function testfillProvidersTable() { - global $TABLESTATS_PROVIDERS; - $providers_array=array(); - $res=fillProvidersTable($providers_array); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - function testfillReferersTable() { - global $TABLESTATS_REFERERS; - $referers_array=array(); - $res=fillReferersTable($referers_array); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - function testloadBrowsers() { - $res=loadBrowsers(); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - function testloadCountries() { - global $TABLESTATS_COUNTRIES,$_configuration; - $TABLESTATS_COUNTRIES = $_configuration['statistics_database'].".track_c_countries"; - $res=loadCountries(); - if (!is_null($res)){ - $this->assertTrue(is_array($res)); - } - //var_dump($res); - } - - function testloadOs() { - $res=loadOs(); - $this->assertTrue(is_array($res)); - //var_dump($res); - } -} -?> diff --git a/tests/main/inc/lib/usermanager.lib.test.php b/tests/main/inc/lib/usermanager.lib.test.php index 9d7a603f6d..018c8dc797 100755 --- a/tests/main/inc/lib/usermanager.lib.test.php +++ b/tests/main/inc/lib/usermanager.lib.test.php @@ -205,14 +205,6 @@ class TestUserManager extends UnitTestCase { $this->assertFalse(!(bool)$res); } - function testGetTeacherList() { - ob_start(); - UserManager::get_teacher_list(1212,null); - $res =ob_get_contents(); - ob_end_clean(); - $this->assertFalse(!(bool)$res); - } - function testGetUserIdFromUsername() { $res=UserManager::get_user_id_from_username('arthur3'); $this->assertTrue(!(bool)$res); diff --git a/tests/main/install/install_upgrade.lib.test.php b/tests/main/install/install_upgrade.lib.test.php index b349d9ffd9..be20146852 100755 --- a/tests/main/install/install_upgrade.lib.test.php +++ b/tests/main/install/install_upgrade.lib.test.php @@ -15,13 +15,6 @@ class TestInstallUpgrade extends UnitTestCase{ //var_dump($res); } - public function testFillTrackCountriesTable() { - $track_countries_table=''; - $res = fill_track_countries_table($track_countries_table); - $this->assertEqual(null,$res); - //var_dump($res); - } - public function testWriteCoursesHtaccessFile() { $chamilo_path_folder = api_get_path(SYS_PATH); $url_append=$chamilo_path_folder.'main/install/'; @@ -33,30 +26,6 @@ class TestInstallUpgrade extends UnitTestCase{ $this->assertEqual($chamilo_path_folder.'main/install/',$res); //var_dump($res); } - //This function is ok but the problem is than create course with other code - /* - public function testLoadMainDatabase() { - $chamilo_path_folder= api_get_path(SYS_CODE_PATH); - $installation_settings['{ORGANISATIONNAME}'] = 'My Organisation'; - $installation_settings['{ORGANISATIONURL}'] = 'http://www.chamilo.org'; - $installation_settings['{CAMPUSNAME}'] = 'My campus'; - $installation_settings['{PLATFORMLANGUAGE}'] = 'spanish'; - $installation_settings['{ALLOWSELFREGISTRATION}'] = 1; - $installation_settings['{ALLOWTEACHERSELFREGISTRATION}'] = 1; - $installation_settings['{ADMINLASTNAME}'] = 'Doe'; - $installation_settings['{ADMINFIRSTNAME}'] = 'John'; - $installation_settings['{ADMINLOGIN}'] = 'admin'; - $installation_settings['{ADMINPASSWORD}'] = md5('admin'); - $installation_settings['{ADMINEMAIL}'] = '.localdomain'; - $installation_settings['{ADMINPHONE}'] = '(000) 001 02 03'; - $installation_settings['{PLATFORM_AUTH_SOURCE}'] = PLATFORM_AUTH_SOURCE; - $installation_settings['{ADMINLANGUAGE}'] = 'spanish'; - $installation_settings['{HASHFUNCTIONMODE}'] = 'md5'; - $db_script = $chamilo_path_folder.'install/db_main.sql'; - $res = load_main_database($installation_settings,$db_script); - $this->assertFalse($res); - } -*/ public function testSplitSqlFile() { $ret=''; @@ -67,19 +36,6 @@ class TestInstallUpgrade extends UnitTestCase{ $this->assertTrue($res===true); } - public function testGetSqlFileContents() { - ob_start(); - $file='txt'; - $section='course'; - $print_errors=true; - $res = get_sql_file_contents($file,$section,$print_errors); - ob_end_clean(); - if(is_bool($res)); - $this->assertTrue(is_bool($res)); - $this->assertTrue($res===true || $res === false); - //var_dump($res); - } - public function testMyDirectoryToArray() { $chamilo_path_folder= api_get_path(SYS_PATH); $directory= $chamilo_path_folder.'home'; diff --git a/tests/main/mySpace/myspace.lib.test.php b/tests/main/mySpace/myspace.lib.test.php index 3541e33ef4..8c356ab4c4 100755 --- a/tests/main/mySpace/myspace.lib.test.php +++ b/tests/main/mySpace/myspace.lib.test.php @@ -136,7 +136,7 @@ class TestMySpaceLib extends UnitTestCase { public function testGetUserCreator() { //ob_start(); - $res = MySpace::get_user_creator($users = array(), $course_list = array(), $id_session = 1); + $res = MySpace::get_user_creator($users = array()); $this->assertTrue(is_array($res)); //ob_end_clean(); //var_dump($res); diff --git a/tests/main/survey/survey.lib.test.php b/tests/main/survey/survey.lib.test.php index b9a912845c..e15852fc51 100755 --- a/tests/main/survey/survey.lib.test.php +++ b/tests/main/survey/survey.lib.test.php @@ -14,25 +14,25 @@ class TestSurvey extends UnitTestCase { $this->UnitTestCase(''); } - public function setUp() { - $this->smanager = new survey_manager(); + public function setUp() { + $this->smanager = new SurveyManager(); $this->squestion = new question(); $this->syesno = new yesno(); $this->smultiplechoice = new multiplechoice(); $this->spersonality = new personality(); - $this->smultipleresponse = new multipleresponse(); + $this->smultipleresponse = new multipleresponse(); } - public function tearDown() { + public function tearDown() { $this-> smanager = null; $this-> squestion = null; $this-> syesno = null; $this->smultiplechoice = null; $this->personality = null; - $this->multipleresponse = null; + $this->multipleresponse = null; } - - + + public function testStoreSurvey() { global $_user,$cidReq; $values = array( @@ -45,20 +45,20 @@ class TestSurvey extends UnitTestCase { 'survey_introduction' => '', 'survey_thanks' => '', 'survey_type' => '0', - 'parent_id' => '0', - 'submit_survey' => '' - ); + 'parent_id' => '0', + 'submit_survey' => '' + ); $res = $this->smanager->store_survey($values); $this->assertTrue($res); - $this->assertTrue(is_array($res)); + $this->assertTrue(is_array($res)); } - - public function testGetSurvey() { - $course_code = 'COURSETEST'; + + public function testGetSurvey() { + $course_code = 'COURSETEST'; $survey_id=1; $res3 = $this->smanager->get_survey($survey_id,0,$course_code); - $this->assertTrue(is_array($res3)); + $this->assertTrue(is_array($res3)); } public function testStoreSharedSurvey() { @@ -73,9 +73,9 @@ class TestSurvey extends UnitTestCase { 'survey_introduction' => 'introduction', 'survey_thanks' => '', 'survey_type' => '1', - 'parent_id' => '1', - 'submit_survey' => '' - ); + 'parent_id' => '1', + 'submit_survey' => '' + ); $res = $this->smanager->store_shared_survey($values); $this->assertTrue($res); //var_dump($res); @@ -98,19 +98,19 @@ class TestSurvey extends UnitTestCase { $this->assertNotNull($this->squestion->html); //var_dump($res); } - + public function testYesNoCreateForm() { $form_content=array(); $res1 = $this->syesno->create_form($form_content); $this->assertNull($res1); } - public function testMultipleChoiceCreateForm() { + public function testMultipleChoiceCreateForm() { $form_content=array(); $res2 = $this->smultiplechoice->create_form($form_content); - $this->assertNull($res2); + $this->assertNull($res2); } - + public function testPersonalityCreateForm() { $form_content=array(); @@ -125,7 +125,7 @@ class TestSurvey extends UnitTestCase { $this->assertNotNull($this->smultipleresponse->html); $this->assertTrue($this->smultipleresponse->html); } - + public function testQuestionRenderQuestion() { ob_start(); $form_content=array(); @@ -134,7 +134,7 @@ class TestSurvey extends UnitTestCase { $this->assertTrue(is_null($res)); ob_end_clean(); } - + public function testMultipleChoiseRenderQuestion() { ob_start(); $form_content=array(); @@ -143,7 +143,7 @@ class TestSurvey extends UnitTestCase { $this->assertNull($this->smultiplechoice->html); ob_end_clean(); } - + public function testYesNoRenderQuestion() { ob_start(); $form_content=array(); @@ -171,7 +171,7 @@ class TestSurvey extends UnitTestCase { } //save the survey - + public function testCopySurvey() { $parent_survey = Database::escape_string($parent_survey); $new_survey_id = '1'; @@ -204,7 +204,7 @@ class TestSurvey extends UnitTestCase { } //var_dump($res); } - + public function testSaveQuestion() { $form_content=array(); $res = $this->smanager->save_question($form_content); @@ -237,13 +237,13 @@ class TestSurvey extends UnitTestCase { $this->assertNull($res); //var_dump($res); } - + //get the survey public function testGetPeopleWhoFilledSurvey() { $survey_id=1; $all_user_info=false; - $survey_data = survey_manager::get_survey($survey_id); + $survey_data = SurveyManager::get_survey($survey_id); $result = $this->smanager->get_people_who_filled_survey($survey_id,false); $this->assertTrue(is_array($result)); //var_dump($result); @@ -263,9 +263,9 @@ class TestSurvey extends UnitTestCase { $this->assertNull($res); //var_dump($res); } - + //move the survey - + public function testMoveSurveyQuestion() { $direction='moveup'; $survey_question_id=1; @@ -276,23 +276,23 @@ class TestSurvey extends UnitTestCase { } //epmty the survey - + public function testEmpty_survey() { $survey_id=null; $res = $this->smanager->empty_survey($survey_id); $this->assertTrue($res); //var_dump($res); } - + //functions delete - + public function testHandleAction() { $form_content = array(''); $res = $this->squestion->handle_action($form_content); $this->assertTrue(is_array($res)); //var_dump($res); } - + public function testDeleteAllSurveyQuestions() { $survey_id=1; $shared=false; @@ -310,7 +310,7 @@ class TestSurvey extends UnitTestCase { //var_dump($result); //var_dump($res); } - + public function testDeleteSharedSurveyQuestion() { $survey_id=1; $question_id=01; @@ -318,7 +318,7 @@ class TestSurvey extends UnitTestCase { $this->assertTrue(is_null($res)); //var_dump($res); } - + public function testDeleteSurvey() { $survey_id=1; $shared=false; @@ -327,7 +327,7 @@ class TestSurvey extends UnitTestCase { $this->assertTrue($res); //var_dump($res); } - + public function testDeleteAllSurveyQuestionsOptions() { $survey_id=1; $shared=false; @@ -344,7 +344,7 @@ class TestSurvey extends UnitTestCase { if(is_bool($result)) $this->assertTrue(is_bool($result)); $this->assertTrue($result === true || $result===false); - $this->assertTrue($result); + $this->assertTrue($result); //var_dump($result); } @@ -356,9 +356,9 @@ class TestSurvey extends UnitTestCase { $this->assertTrue($res === true || $res === false); //var_dump($res); } - + //Contest the answer - + public function testUpdateSurveyAnswered() { global $user; $survey_code = 'Survey1'; @@ -373,10 +373,10 @@ class TestSurvey extends UnitTestCase { * This functon only is added to the end of the test and the end of the files in the all test. */ /* public function testDeleteCourse() { - global $cidReq; - $resu = CourseManager::delete_course($cidReq); + global $cidReq; + $resu = CourseManager::delete_course($cidReq); }*/ - + } ?> diff --git a/tests/main/user/userInfoLib.test.php b/tests/main/user/userInfoLib.test.php deleted file mode 100755 index 6e3d6a8b20..0000000000 --- a/tests/main/user/userInfoLib.test.php +++ /dev/null @@ -1,179 +0,0 @@ -UnitTestCase('User info library - main/user/userInfoLib.test.php'); - } - - /** - * clean the content of a bloc for information category - */ - - function testcleanout_cat_content(){ - global $TBL_USERINFO_CONTENT; - $user_id=1; - $definition_id=1; - $res=cleanout_cat_content($user_id, $definition_id); - $this->assertTrue(($res)); - //var_dump($res); - } - - /** - * create a new category definition for the user information - */ - - function testcreate_cat_def() { - global $TBL_USERINFO_DEF; - $res=create_cat_def($title="test", $comment="comment test", $nbline="5"); - $this->assertTrue(($res)); - //var_dump($res); - } - - /** - * Edit a bloc for information category - */ - - function testedit_cat_content() { - global $TBL_USERINFO_CONTENT; - $definition_id=1; - $user_id=1; - $res=edit_cat_content($definition_id, $user_id, $content ="", $user_ip=""); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * modify the definition of a user information category - */ - - function testedit_cat_def() { - $id=1; - $title='test'; - $comment='comment test'; - $nbline=2; - $res=edit_cat_def($id, $title, $comment, $nbline); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * fill a bloc for information category - */ - - function testfill_new_cat_content() { - $definition_id=''; - $user_id=1; - $res=fill_new_cat_content($definition_id, $user_id, $content="", $user_ip=""); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * get the user content of a categories plus the categories definition - */ - - function testget_cat_content() { - $userId=1; - $catId=1; - $res=get_cat_content($userId, $catId); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - function testget_cat_def() { - $catId=1; - $res=get_cat_def($catId); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - function testget_cat_def_list() { - $res=get_cat_def_list(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - function testget_course_user_info() { - $user_id=1; - $res=get_course_user_info($user_id); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - function testget_main_user_info() { - $user_id=1; - $courseCode='TEST'; - $res=get_main_user_info($user_id,$courseCode); - if(!is_bool($res))$this->assertTrue(is_array($res)); - //var_dump($res); - } - - function testhtmlize() { - $phrase='test'; - $res=htmlize($phrase); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testmove_cat_rank() { - $id=1; - $direction='up'; - $res=move_cat_rank($id, $direction); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - -/* - function testmove_cat_rank_by_rank() { - $rank=5; - $direction='up'; - $res=move_cat_rank_by_rank($rank, $direction); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } -*/ - /** - * remove a category from the category list - * @param - int $id - id of the category - * or "ALL" for all category - * @param - boolean $force - FALSE (default) : prevents removal if users have - * already fill this category - * TRUE : bypass user content existence check - * @param - int $nbline - lines number for the field the user will fill. - * @return - bollean - TRUE if succeed, ELSE otherwise - */ - function testremove_cat_def() { - $id=1; - $res=remove_cat_def($id, $force = false); - if(!is_null($res))$this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * @author Hugues Peeters - peeters@ipm.ucl.ac.be - * @param int $user_id - * @param string $course_code - * @param array $properties - should contain 'role', 'status', 'tutor_id' - * @return boolean true if succeed false otherwise - */ - function testupdate_user_course_properties() { - $user_id=1; - $course_code='test'; - $properties=array(); - $res=update_user_course_properties($user_id, $course_code, $properties); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * This functon only is added to the end of the test and the end of the files in the all test. - */ - /*public function testDeleteCourse() { - global $cidReq; - $resu = CourseManager::delete_course($cidReq); - }*/ -} -?> diff --git a/tests/main/work/work.lib.test.php b/tests/main/work/work.lib.test.php index 05fbb95f24..20c579a43f 100755 --- a/tests/main/work/work.lib.test.php +++ b/tests/main/work/work.lib.test.php @@ -177,20 +177,6 @@ class TestWork extends UnitTestCase { //var_dump($res); } - /** - * This function displays the firstname and lastname of the user as a link to the user tool. - * @see this is the same function as in the new forum, so this probably has to move to a user library. - * @todo move this function to the user library - */ - - function testdisplay_user_link_work() { - global $_otherusers; - $user_id=1; - $res=display_user_link_work($user_id, $name=''); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - /** * create a group of select from a date */ diff --git a/tests/phpunit/classes/ImportTest.class.php b/tests/phpunit/classes/ImportTest.class.php index ad4f8c2a66..3d370ff9b4 100755 --- a/tests/phpunit/classes/ImportTest.class.php +++ b/tests/phpunit/classes/ImportTest.class.php @@ -39,10 +39,10 @@ class ImportTest extends PHPUnit_Framework_TestCase } /** - * @covers Import::csv_to_array - * @todo Implement testCsv_to_array(). + * @covers Import::csvToArray + * @todo Implement testcsvToArray(). */ - public function testCsv_to_array() + public function testcsvToArray() { // Remove the following lines when you implement this test. $this->markTestIncomplete( diff --git a/tests/phpunit/classes/UriTest.class.php b/tests/phpunit/classes/UriTest.class.php deleted file mode 100755 index 5162df9dec..0000000000 --- a/tests/phpunit/classes/UriTest.class.php +++ /dev/null @@ -1,100 +0,0 @@ -object = new Uri; - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } - - /** - * @covers Uri::chamilo - * @todo Implement testChamilo(). - */ - public function testChamilo() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Uri::www - * @todo Implement testWww(). - */ - public function testWww() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Uri::here - * @todo Implement testHere(). - */ - public function testHere() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Uri::url - * @todo Implement testUrl(). - */ - public function testUrl() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Uri::params - * @todo Implement testParams(). - */ - public function testParams() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Uri::course_params - * @todo Implement testCourse_params(). - */ - public function testCourse_params() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } -} diff --git a/tests/scripts/check_users_in_csv_file.php b/tests/scripts/check_users_in_csv_file.php index 6dc405251f..1e732d273b 100644 --- a/tests/scripts/check_users_in_csv_file.php +++ b/tests/scripts/check_users_in_csv_file.php @@ -7,7 +7,7 @@ require_once '../inc/global.inc.php'; api_protect_admin_script(); $file = ''; -$users = Import :: csv_to_array($file); +$users = Import :: csvToArray($file); foreach ($users as $user) { $userInfo = api_get_user_info_from_email($user['Email']); if (empty($userInfo)) { diff --git a/tests/scripts/course2session.php b/tests/scripts/course2session.php index 55c1370474..c1379dd73c 100644 --- a/tests/scripts/course2session.php +++ b/tests/scripts/course2session.php @@ -171,8 +171,8 @@ foreach ($res as $course) { if ($debug) { echo "Session $sessionTitle created with ID $id" . $eol; } - SessionManager::add_courses_to_session($id, array($course['code'])); - $resultUsers = Database::query("SELECT user_id FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER). " WHERE course_code = '" . $course['code'] . "'"); + SessionManager::add_courses_to_session($id, array($course['id'])); + $resultUsers = Database::query("SELECT user_id FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER). " WHERE c_id = '" . $course['id'] . "'"); $users = array(); while ($row = Database::fetch_assoc($resultUsers)) { $users[] = $row['user_id']; @@ -202,7 +202,7 @@ foreach ($res as $course) { continue; } $table = Database::get_main_table(TABLE_MAIN_COURSE_USER); - $sql = "DELETE FROM $table WHERE user_id = $user AND course_code = '" . $course['code'] . "'"; + $sql = "DELETE FROM $table WHERE user_id = $user AND c_id = '" . $course['id'] . "'"; if ($debug) { echo $sql . $eol; } diff --git a/tests/scripts/delete_users_from_csv.php b/tests/scripts/delete_users_from_csv.php index e282e534fc..00afbdb2f3 100644 --- a/tests/scripts/delete_users_from_csv.php +++ b/tests/scripts/delete_users_from_csv.php @@ -9,7 +9,7 @@ api_protect_admin_script(); $debug = true; $file = 'file.csv'; -$users = Import :: csv_to_array($file); +$users = Import :: csvToArray($file); foreach ($users as $user) { //$userInfo = api_get_user_info_from_username($user['UserName']); $userInfo = api_get_user_info_from_email($user['Email']); diff --git a/tests/scripts/detect_deleted_visible_documents.php b/tests/scripts/detect_deleted_visible_documents.php index cad16385c4..18f6e764bc 100644 --- a/tests/scripts/detect_deleted_visible_documents.php +++ b/tests/scripts/detect_deleted_visible_documents.php @@ -16,7 +16,7 @@ $itemProperty = Database::get_course_table(TABLE_ITEM_PROPERTY); $sql = "SELECT i.* FROM $document d INNER JOIN $itemProperty i - ON (d.c_id = i.c_id AND i.ref = d.id AND d.session_id = i.id_session) + ON (d.c_id = i.c_id AND i.ref = d.id AND d.session_id = i.session_id) WHERE d.path LIKE '%_DELETED_%' AND i.visibility IN (1, 0) AND @@ -35,7 +35,7 @@ if (!empty($docs)) { SET visibility = 2 WHERE c_id = $courseId AND - id_session = $sessionId AND + session_id = $sessionId AND ref = $ref AND tool = 'document' "; diff --git a/tests/scripts/move_users.php b/tests/scripts/move_users.php index 142a29487f..cbafbdd296 100644 --- a/tests/scripts/move_users.php +++ b/tests/scripts/move_users.php @@ -53,7 +53,7 @@ function moveUserFromCourseToCourse($originCourse, $destinationCourse, $debug = if (PHP_SAPI != 'cli') { $eol = "
    ".$eol; } - + if (empty($originCourse)) { return $output; } else { @@ -81,8 +81,8 @@ function moveUserFromCourseToCourse($originCourse, $destinationCourse, $debug = // Now get the list of users subscribed to the course of origin $sql = "SELECT user_id FROM $tableCRU - WHERE status = ".STUDENT." - AND course_code = '$originCourse'"; + WHERE status = ".STUDENT." + AND c_id = '$courseId'"; $output .= "$sql".$eol; $res = Database::query($sql); $numUsers = Database::num_rows($res); @@ -92,7 +92,7 @@ function moveUserFromCourseToCourse($originCourse, $destinationCourse, $debug = // Now get the list of users subscribed to the course of origin $sqlDestination = "SELECT user_id FROM $tableCRU - WHERE status = ".STUDENT." + WHERE status = ".STUDENT." AND course_code = '$destinationCourse'"; $output .= "$sqlDestination".$eol; $resDestination = Database::query($sqlDestination); diff --git a/tests/scripts/update_user_extra_field.php b/tests/scripts/update_user_extra_field.php index b73dc7f7dd..9c26504ae6 100644 --- a/tests/scripts/update_user_extra_field.php +++ b/tests/scripts/update_user_extra_field.php @@ -26,7 +26,7 @@ api_protect_admin_script(); $extraField = new ExtraField('user'); $file = 'file.csv'; -$users = Import :: csv_to_array($file); +$users = Import :: csvToArray($file); foreach ($users as $user) { $userInfo = api_get_user_info_from_username($user['user']); if (!empty($userInfo)) { diff --git a/tests/test_manager.inc.php b/tests/test_manager.inc.php index 0b04fca2b1..5909a95045 100755 --- a/tests/test_manager.inc.php +++ b/tests/test_manager.inc.php @@ -154,7 +154,6 @@ function create_test_course($course_code = 'TESTCOURSE') { $_course['sysCode' ] = $cData['code' ]; // use as key in db $_course['path' ] = $cData['directory' ]; // use as key in path $_course['dbName' ] = $cData['db_name' ]; // use as key in db list - $_course['dbNameGlu' ] = $_configuration['table_prefix'] . $cData['db_name'] . $_configuration['db_glue']; // use in all queries $_course['titular' ] = $cData['tutor_name' ]; $_course['language' ] = $cData['course_language' ]; $_course['extLink' ]['url' ] = $cData['department_url' ]; diff --git a/user.php b/user.php index a7d3ceb80a..82e6f3d033 100755 --- a/user.php +++ b/user.php @@ -4,17 +4,15 @@ * Clean URls for the Social Network * * The idea is to access to the user info more easily: - * http://campus.chamilo.org/admin instead of + * http://campus.chamilo.org/admin instead of * http://campus.chamilo.org/main/social/profile.php?1 - * To use this you should rename the htaccess to .htaccess and check your + * To use this you should rename the htaccess to .htaccess and check your * virtualhost configuration * * More improvements will come in next versions of Chamilo maybe in the 1.8.8 * @package chamilo.main */ -/** - * Variables definitions and inclusions - */ + $cidReset = true; require_once 'main/inc/global.inc.php'; @@ -43,4 +41,4 @@ if (!empty($array_keys)) { // we cant find your friend header('Location: whoisonline.php'); exit; -} \ No newline at end of file +} diff --git a/user_portal.php b/user_portal.php index 30bd19c399..de72866d5c 100755 --- a/user_portal.php +++ b/user_portal.php @@ -15,7 +15,7 @@ * @todo display_digest, shouldn't this be removed and be made into an extension? */ -use \ChamiloSession as Session; +use ChamiloSession as Session; /* Flag forcing the 'current course' reset, as we're not inside a course anymore */ $cidReset = true; @@ -43,14 +43,24 @@ $courseAndSessions = $controller->return_courses_and_sessions($userId); // Check if a user is enrolled only in one course for going directly to the course after the login. if (api_get_setting('go_to_course_after_login') == 'true') { - $count_of_sessions = $courseAndSessions['session_count']; $count_of_courses_no_sessions = $courseAndSessions['course_count']; - + // User is subscribe in 1 session and 0 courses. if ($count_of_sessions == 1 && $count_of_courses_no_sessions == 0) { $sessions = SessionManager::get_sessions_by_user($userId); + if (isset($sessions[0])) { $sessionInfo = $sessions[0]; + // Session only has 1 course. + if (isset($sessionInfo['courses']) && count($sessionInfo['courses']) == 1) { + $courseCode = $sessionInfo['courses'][0]['code']; + $courseInfo = api_get_course_info($courseCode); + $courseUrl = $courseInfo['course_public_url'].'?id_session='.$sessionInfo['session_id']; + header('Location:'.$courseUrl); + exit; + } + + // Session has many courses. if (isset($sessionInfo['session_id'])) { $url = api_get_path(WEB_CODE_PATH).'session/?session_id='.$sessionInfo['session_id']; @@ -60,6 +70,7 @@ if (api_get_setting('go_to_course_after_login') == 'true') { } } + // User is subscribed to 1 course. if (!isset($_SESSION['coursesAlreadyVisited']) && $count_of_sessions == 0 && $count_of_courses_no_sessions == 1 ) { diff --git a/whoisonline.php b/whoisonline.php index dc845eec58..5f62f43de0 100755 --- a/whoisonline.php +++ b/whoisonline.php @@ -15,8 +15,6 @@ if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) { api_protect_course_script(true); } -require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; - $_SESSION['who_is_online_counter'] = 2; $htmlHeadXtra[] = api_get_js('jquery.endless-scroll.js'); @@ -68,23 +66,23 @@ $(document).ready(function() { $("#link_load_more_items").click(function() { page = $("#link_load_more_items").attr("data_link"); $.ajax({ - beforeSend: function(objeto) { - $("#display_response_id").html("'.addslashes(get_lang('Loading')).'"); - }, - type: "GET", - url: "main/inc/ajax/online.ajax.php?a=load_online_user", - data: "online_page_nr="+page, - success: function(data) { - $("#display_response_id").html(""); - if (data != "end") { - $("#link_load_more_items").remove(); - var last = $("#online_grid_container li:last"); - last.after(data); - } else { - $("#link_load_more_items").remove(); - } + beforeSend: function(objeto) { + $("#display_response_id").html("'.addslashes(get_lang('Loading')).'"); + }, + type: "GET", + url: "main/inc/ajax/online.ajax.php?a=load_online_user", + data: "online_page_nr="+page, + success: function(data) { + $("#display_response_id").html(""); + if (data != "end") { + $("#link_load_more_items").remove(); + var last = $("#online_grid_container li:last"); + last.after(data); + } else { + $("#link_load_more_items").remove(); } - }); + } + }); }); }); '; @@ -129,7 +127,7 @@ if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) || if (api_get_setting('allow_social_tool') == 'true') { if (!api_is_anonymous()) { $query = isset($_GET['q']) ? $_GET['q']: null; - $social_right_content .= '
    '.UserManager::get_search_form($query).'
    '; + $social_right_content .= UserManager::get_search_form($query); } } $social_right_content .= SocialManager::display_user_list($user_list); diff --git a/whoisonlinesession.php b/whoisonlinesession.php index 26a83c5a3e..2b80a5debc 100755 --- a/whoisonlinesession.php +++ b/whoisonlinesession.php @@ -4,9 +4,6 @@ * Shows who is online in a specific session * @package chamilo.main */ -/** - * Initialization - */ include_once './main/inc/global.inc.php'; api_block_anonymous_users(); @@ -47,27 +44,28 @@ Display::display_header(get_lang('UserOnlineListSession')); $session_is_coach = array(); if (isset($_user['user_id']) && $_user['user_id'] != '') { $_user['user_id'] = intval($_user['user_id']); - $result = Database::query("SELECT DISTINCT id, - name, - date_start, - date_end - FROM $tbl_session as session - INNER JOIN $tbl_session_course_user as srcru - ON srcru.id_user = ".$_user['user_id']." AND srcru.status=2 - AND session.id = srcru.id_session - ORDER BY date_start, date_end, name"); + $sql = "SELECT DISTINCT session.id, + name, + date_start, + date_end + FROM $tbl_session as session + INNER JOIN $tbl_session_course_user as srcru + ON srcru.user_id = ".$_user['user_id']." AND srcru.status=2 + AND session.id = srcru.session_id + ORDER BY date_start, date_end, name"; + $result = Database::query($sql); while ($session = Database:: fetch_array($result)) { $session_is_coach[$session['id']] = $session; } - $sql = "SELECT DISTINCT id, - name, - date_start, - date_end - FROM $tbl_session as session - WHERE session.id_coach = ".$_user['user_id']." - ORDER BY date_start, date_end, name"; + $sql = "SELECT DISTINCT session.id, + name, + date_start, + date_end + FROM $tbl_session as session + WHERE session.id_coach = ".$_user['user_id']." + ORDER BY date_start, date_end, name"; $result = Database::query($sql); while ($session = Database:: fetch_array($result)) { $session_is_coach[$session['id']] = $session; @@ -144,9 +142,4 @@ Display::display_header(get_lang('UserOnlineListSession'));