diff --git a/main/admin/configure_plugin.php b/main/admin/configure_plugin.php index e55624b281..6e6b8d195c 100755 --- a/main/admin/configure_plugin.php +++ b/main/admin/configure_plugin.php @@ -69,6 +69,10 @@ if (isset($form)) { 1 ); } + if (isset($values['show_main_menu_tab'])) { + $objPlugin = $plugin_info['plugin_class']::create(); + $objPlugin->manageTab($values['show_main_menu_tab']); + } $message = Display::return_message(get_lang('Updated'), 'success'); } } diff --git a/main/exercice/question_pool.php b/main/exercice/question_pool.php index f958b91e3c..d7e97131c5 100755 --- a/main/exercice/question_pool.php +++ b/main/exercice/question_pool.php @@ -812,7 +812,7 @@ function get_a_tag_for_question( $res = $in_questionname; $sessionIcon = null; if ($in_addA) { - if (!empty($sessionId)) { + if (!empty($sessionId) && $sessionId != -1) { $sessionIcon = ' '.Display::return_icon('star.png', get_lang('Session')); } $res = "". diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 5eba719f42..9e441b0313 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -43,7 +43,7 @@ $(document).ready(function () { * This function handles all the forum and forumcategories actions. This is a wrapper for the * forum and forum categories. All this code code could go into the section where this function is * called but this make the code there cleaner. - * @param int Learning path ID + * @param int $lp_id Learning path ID * @return void * @author Patrick Cool , Ghent University * @author Juan Carlos Raña Trabado (return to lp_id) @@ -67,6 +67,7 @@ function handle_forum_and_forumcategories($lp_id = null) if (($action_forum_cat == 'add' && $get_content == 'forumcategory') || $post_submit_cat) { show_add_forumcategory_form(array(), $lp_id); //$lp_id when is called from learning path } + // Adding a forum if ((($action_forum_cat == 'add' || $action_forum_cat == 'edit') && $get_content == 'forum') || $post_submit_forum) { if ($action_forum_cat == 'edit' && $get_id || $post_submit_forum) { @@ -82,6 +83,7 @@ function handle_forum_and_forumcategories($lp_id = null) $forum_category = get_forum_categories($get_id); show_edit_forumcategory_form($forum_category); } + // Delete a forum category if ($action_forum_cat == 'delete') { $id_forum = intval($get_id); @@ -118,8 +120,8 @@ function handle_forum_and_forumcategories($lp_id = null) /** * This function displays the form that is used to add a forum category. * - * @param array input values (deprecated, set to null when calling) - * @param int Learning path ID + * @param array $inputvalues (deprecated, set to null when calling) + * @param int $lp_id Learning path ID * @return void HTML * @author Patrick Cool , Ghent University * @author Juan Carlos Raña Trabado (return to lp_id) @@ -166,7 +168,8 @@ function show_add_forumcategory_form($inputvalues = array(), $lp_id) /** * This function displays the form that is used to add a forum category. * - * @param array + * @param array $inputvalues + * @param int $lp_id * @return void HTML * * @author Patrick Cool , Ghent University @@ -385,16 +388,14 @@ function delete_forum_image($forum_id) */ function show_edit_forumcategory_form($inputvalues = array()) { - // Initialize the object. - $gradebook = Security::remove_XSS($_GET['gradebook']); - $form = new FormValidator('forumcategory', 'post', 'index.php?&gradebook='.$gradebook.''); + $categoryId = $inputvalues['cat_id']; + $form = new FormValidator('forumcategory', 'post', 'index.php?'.api_get_cidreq().'&id='.$categoryId); // Setting the form elements. $form->addElement('header', '', get_lang('EditForumCategory')); $form->addElement('hidden', 'forum_category_id'); $form->addElement('text', 'forum_category_title', get_lang('Title'), 'class="input_titles"'); - //$form->applyFilter('forum_category_title', 'html_filter'); $form->addElement( 'html_editor', 'forum_category_comment', @@ -403,7 +404,6 @@ function show_edit_forumcategory_form($inputvalues = array()) array('ToolbarSet' => 'Forum', 'Width' => '98%', 'Height' => '200') ); - //$form->applyFilter('forum_category_comment', 'html_filter'); $form->addElement('style_submit_button', 'SubmitEditForumCategory', get_lang('ModifyCategory'), 'class="save"'); // Setting the default values. @@ -446,7 +446,8 @@ function store_forumcategory($values) $table_categories = Database::get_course_table(TABLE_FORUM_CATEGORY); // Find the max cat_order. The new forum category is added at the end => max cat_order + & - $sql = "SELECT MAX(cat_order) as sort_max FROM ".Database::escape_string($table_categories)." WHERE c_id = $course_id"; + $sql = "SELECT MAX(cat_order) as sort_max FROM ".Database::escape_string($table_categories)." + WHERE c_id = $course_id"; $result = Database::query($sql); $row = Database::fetch_array($result); $new_max = $row['sort_max'] + 1; @@ -454,7 +455,8 @@ function store_forumcategory($values) $clean_cat_title = Database::escape_string($values['forum_category_title']); - if (isset($values['forum_category_id'])) { // Storing after edition. + if (isset($values['forum_category_id'])) { + // Storing after edition. $sql = "UPDATE ".$table_categories." SET cat_title='".$clean_cat_title."', cat_comment='".Database::escape_string($values['forum_category_comment'])."' @@ -475,7 +477,13 @@ function store_forumcategory($values) Database::query($sql); $last_id = Database::insert_id(); if ($last_id > 0) { - api_item_property_update(api_get_course_info(), TOOL_FORUM_CATEGORY, $last_id, 'ForumCategoryAdded', api_get_user_id()); + api_item_property_update( + api_get_course_info(), + TOOL_FORUM_CATEGORY, + $last_id, + 'ForumCategoryAdded', + api_get_user_id() + ); api_set_default_visibility($last_id, TOOL_FORUM_CATEGORY); } $return_message = get_lang('ForumCategoryAdded'); @@ -589,7 +597,6 @@ function store_forum($values) WHERE c_id = $course_id AND forum_id='".Database::escape_string($values['forum_id'])."'"; Database::query($sql); - api_item_property_update( $_course, TOOL_FORUM, @@ -639,15 +646,19 @@ function store_forum($values) /** * This function deletes a forum or a forum category - * This function currently does not delete the forums inside the category, nor the threads and replies inside these forums. - * For the moment this is the easiest method and it has the advantage that it allows to recover fora that were acidently deleted + * This function currently does not delete the forums inside the category, + * nor the threads and replies inside these forums. + * For the moment this is the easiest method and it has the advantage that it + * allows to recover fora that were acidently deleted * when the forum category got deleted. * * @param $content = what we are deleting (a forum or a forum category) * @param $id The id of the forum category that has to be deleted. * - * @todo write the code for the cascading deletion of the forums inside a forum category and also the threads and replies inside these forums - * @todo config setting for recovery or not (see also the documents tool: real delete or not). + * @todo write the code for the cascading deletion of the forums inside a + * forum category and also the threads and replies inside these forums + * @todo config setting for recovery or not + * (see also the documents tool: real delete or not). * @return void * @author Patrick Cool , Ghent University * @version february 2006, dokeos 1.8 @@ -659,14 +670,18 @@ function delete_forum_forumcategory_thread($content, $id) $table_forums_post = Database::get_course_table(TABLE_FORUM_POST); $table_forum_thread = Database::get_course_table(TABLE_FORUM_THREAD); $course_id = api_get_course_int_id(); + $id = intval($id); // Delete all attachment file about this tread id. - $sql = "SELECT post_id FROM $table_forums_post WHERE c_id = $course_id AND thread_id = '".(int) $id."' "; + $sql = "SELECT post_id FROM $table_forums_post WHERE c_id = $course_id AND thread_id = '".$id."' "; $res = Database::query($sql); while ($poster_id = Database::fetch_row($res)) { delete_attachment($poster_id[0]); } + $tool_constant = null; + $return_message = null; + if ($content == 'forumcategory') { $tool_constant = TOOL_FORUM_CATEGORY; $return_message = get_lang('ForumCategoryDeleted'); @@ -737,11 +752,18 @@ function delete_post($post_id) $post_parent_id_of_deleted_post = $tab_post_info['post_parent_id']; $thread_id_of_deleted_post = $tab_post_info['thread_id']; $forum_if_of_deleted_post = $tab_post_info['forum_id']; - $sql = "UPDATE $table_posts SET post_parent_id=$post_parent_id_of_deleted_post - WHERE c_id = $course_id AND post_parent_id=$post_id AND thread_id=$thread_id_of_deleted_post AND forum_id=$forum_if_of_deleted_post;"; + $sql = "UPDATE $table_posts + SET post_parent_id=$post_parent_id_of_deleted_post + WHERE + c_id = $course_id AND + post_parent_id=$post_id AND + thread_id=$thread_id_of_deleted_post AND + forum_id=$forum_if_of_deleted_post;"; Database::query($sql); - $sql = "DELETE FROM $table_posts WHERE c_id = $course_id AND post_id='".Database::escape_string($post_id)."'"; // Note: This has to be a recursive function that deletes all of the posts in this block. + // Note: This has to be a recursive function that deletes all of the posts in this block. + $sql = "DELETE FROM $table_posts + WHERE c_id = $course_id AND post_id='".Database::escape_string($post_id)."'"; Database::query($sql); // Delete attachment file about this post id. @@ -761,7 +783,8 @@ function delete_post($post_id) } if (!$last_post_of_thread) { // We deleted the very single post of the thread so we need to delete the entry in the thread table also. - $sql = "DELETE FROM $table_threads WHERE c_id = $course_id AND thread_id='".intval($_GET['thread'])."'"; + $sql = "DELETE FROM $table_threads + WHERE c_id = $course_id AND thread_id='".intval($_GET['thread'])."'"; Database::query($sql); return 'PostDeletedSpecial'; } @@ -781,7 +804,9 @@ function check_if_last_post_of_thread($thread_id) { $table_posts = Database :: get_course_table(TABLE_FORUM_POST); $course_id = api_get_course_int_id(); - $sql = "SELECT * FROM $table_posts WHERE c_id = $course_id AND thread_id='".Database::escape_string($thread_id)."' ORDER BY post_date DESC"; + $sql = "SELECT * FROM $table_posts + WHERE c_id = $course_id AND thread_id='".Database::escape_string($thread_id)."' + ORDER BY post_date DESC"; $result = Database::query($sql); if (Database::num_rows($result) > 0) { $row = Database::fetch_array($result); @@ -933,8 +958,18 @@ function display_up_down_icon($content, $id, $list) function change_visibility($content, $id, $target_visibility) { $_course = api_get_course_info(); - $constants = array('forumcategory' => TOOL_FORUM_CATEGORY, 'forum' => TOOL_FORUM, 'thread' => TOOL_FORUM_THREAD); - api_item_property_update($_course, $constants[$content], $id, $target_visibility, api_get_user_id()); + $constants = array( + 'forumcategory' => TOOL_FORUM_CATEGORY, + 'forum' => TOOL_FORUM, + 'thread' => TOOL_FORUM_THREAD + ); + api_item_property_update( + $_course, + $constants[$content], + $id, + $target_visibility, + api_get_user_id() + ); if ($target_visibility == 'visible') { handle_mail_cue($content, $id); @@ -1031,7 +1066,8 @@ function move_up_down($content, $direction, $id) $id_column = 'forum_id'; $sort_column = 'forum_order'; // We also need the forum_category of this forum. - $sql = "SELECT forum_category FROM $table_forums WHERE c_id = $course_id AND forum_id=".Database::escape_string($id); + $sql = "SELECT forum_category FROM $table_forums + WHERE c_id = $course_id AND forum_id=".Database::escape_string($id); $result = Database::query($sql); $row = Database::fetch_array($result); $forum_category = $row['forum_category']; @@ -1358,7 +1394,7 @@ function get_forums( we use this part of the function) */ // Select all the forum information of the given forum (that is not deleted). - $sql = "SELECT * FROM $table_forums forum , ".$table_item_property." item_properties + $sql = "SELECT * FROM $table_forums forum, ".$table_item_property." item_properties WHERE forum.forum_id=item_properties.ref AND forum_id='".Database::escape_string($id)."' AND @@ -1386,10 +1422,13 @@ function get_forums( GROUP BY forum_id"; // 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 + $sql4 = "SELECT + 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=".Database::escape_string($id)." - AND post.poster_id=users.user_id AND post.c_id = $course_id + WHERE + forum_id=".Database::escape_string($id)." AND + post.poster_id=users.user_id AND + post.c_id = $course_id GROUP BY post.forum_id ORDER BY post.post_id ASC"; } @@ -1516,8 +1555,13 @@ function get_last_post_information($forum_id, $show_invisibles = false, $course_ $table_users = Database :: get_main_table(TABLE_MAIN_USER); $sql = "SELECT post.post_id, post.forum_id, post.poster_id, post.poster_name, post.post_date, users.lastname, users.firstname, post.visible, thread_properties.visibility AS thread_visibility, forum_properties.visibility AS forum_visibility - FROM $table_posts post, $table_users users, $table_item_property thread_properties, $table_item_property forum_properties - WHERE post.forum_id=".Database::escape_string($forum_id)." + FROM + $table_posts post, + $table_users users, + $table_item_property thread_properties, + $table_item_property forum_properties + WHERE + post.forum_id=".Database::escape_string($forum_id)." AND post.poster_id=users.user_id AND post.thread_id=thread_properties.ref AND thread_properties.tool='".TOOL_FORUM_THREAD."' diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index ffeddbb5d6..50698ad231 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -3162,12 +3162,17 @@ class CourseManager /** * get courses followed by user - * @param int $user_id - * @param int $from - * @param int $limit - * @param string $column - * @param string $direction - * @return array courses + * @param int $user_id + * @param int $status + * @param int $from + * @param int $limit + * @param string $column + * @param string $direction + * @param boolean $getCount + * @param string $keyword + * @param int $sessionId + * @param boolean $showAllAssignedCourses + * @return array courses */ public static function getCoursesFollowedByUser( $user_id, @@ -3199,6 +3204,8 @@ class CourseManager $whereConditions .= " AND cru.user_id = '$user_id'"; if (!$showAllAssignedCourses) { $whereConditions .= " AND status = ".COURSEMANAGER; + } else { + $whereConditions .= " AND relation_type = ".COURSE_RELATION_TYPE_COURSE_MANAGER; } break; case DRH: diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index c0da338bc8..dbe11d4b4d 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -2733,7 +2733,14 @@ class DocumentManager } if ($index_document) { - self::index_document($documentId, $course_info['code'], null, $_POST['language'], $_REQUEST, $if_exists); + self::index_document( + $documentId, + $course_info['code'], + null, + $_POST['language'], + $_REQUEST, + $if_exists + ); } if (!empty($documentId) && is_numeric($documentId)) { @@ -4045,6 +4052,7 @@ class DocumentManager * @param null $userId * @param null $groupId * @param null $toUserId + * @param string $comment * @return bool|path */ public static function addFileToDocumentTool( @@ -4054,7 +4062,8 @@ class DocumentManager $userId, $whatIfFileExists = 'overwrite', $groupId = null, - $toUserId = null + $toUserId = null, + $comment = null ) { if (!file_exists($filePath)) { return false; @@ -4082,7 +4091,9 @@ class DocumentManager $toUserId, false, $whatIfFileExists, - false + false, + false, + $comment ); if ($filePath) { @@ -4127,15 +4138,20 @@ class DocumentManager * @param string $whatIfFileExists * @return bool|path */ - public static function addAndConvertWavToMp3($documentData, $courseInfo, $userId, $whatIfFileExists = 'overwrite') - { + public static function addAndConvertWavToMp3( + $documentData, + $courseInfo, + $userId, + $whatIfFileExists = 'overwrite' + ) { if (empty($documentData)) { return false; } - if (isset($documentData['absolute_path']) && file_exists($documentData['absolute_path'])) { + if (isset($documentData['absolute_path']) && + file_exists($documentData['absolute_path']) + ) { $mp3FilePath = self::convertWavToMp3($documentData['absolute_path']); - //$mp3FilePath = str_replace('wav', 'mp3', $documentData['absolute_path']); if (!empty($mp3FilePath)) { $documentId = self::addFileToDocumentTool( @@ -4143,7 +4159,10 @@ class DocumentManager dirname($documentData['path']), $courseInfo, $userId, - $whatIfFileExists + $whatIfFileExists, + null, + null, + $documentData['comment'] ); if (!empty($documentId)) { @@ -4248,7 +4267,7 @@ class DocumentManager $path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; if (!is_dir($path.'audio')) { mkdir($path.'audio', api_get_permissions_for_new_directories()); - $audioId = add_document($_course, '/audio', 'folder', 0, 'audio'); + $audioId = add_document($_course, '/audio', 'folder', 0, 'Audio'); api_item_property_update( $_course, TOOL_DOCUMENT, diff --git a/main/inc/lib/fileUpload.lib.php b/main/inc/lib/fileUpload.lib.php index e95816eb5f..573dc8994e 100755 --- a/main/inc/lib/fileUpload.lib.php +++ b/main/inc/lib/fileUpload.lib.php @@ -177,7 +177,10 @@ function process_uploaded_file($uploaded_file, $show_output = true) * @param int $to_user_id, NULL for everybody * @param int $unzip 1/0 * @param string $what_if_file_exists overwrite, rename or warn if exists (default) - * @param boolean Optional output parameter. So far only use for unzip_uploaded_document function. If no output wanted on success, set to false. + * @param boolean Optional output parameter. + * So far only use for unzip_uploaded_document function. + * If no output wanted on success, set to false. + * @param string $comment * @return string path of the saved file */ function handle_uploaded_document( @@ -191,7 +194,8 @@ function handle_uploaded_document( $unzip = 0, $what_if_file_exists = '', $output = true, - $onlyUploadFile = false + $onlyUploadFile = false, + $comment = null ) { if (!$user_id) { return false; @@ -224,8 +228,8 @@ function handle_uploaded_document( $output, $to_group_id ); - //display_message('Unzipping file'); - } elseif ($unzip == 1 && !preg_match('/.zip$/', strtolower($uploaded_file['name']))) { // We can only unzip ZIP files (no gz, tar,...) + } elseif ($unzip == 1 && !preg_match('/.zip$/', strtolower($uploaded_file['name']))) { + // We can only unzip ZIP files (no gz, tar,...) if ($output) { Display::display_error_message(get_lang('UplNotAZip')." ".get_lang('PleaseTryAgain')); } @@ -315,18 +319,21 @@ function handle_uploaded_document( switch ($what_if_file_exists) { // Overwrite the file if it exists case 'overwrite': + // Check if the target file exists, so we can give another message $file_exists = file_exists($store_path); if (moveUploadedFile($uploaded_file, $store_path)) { chmod($store_path, $files_perm); - if ($file_exists && $docId) { // UPDATE DATABASE $document_id = DocumentManager::get_document_id($_course, $file_path); - if (is_numeric($document_id)) { // Update file size - update_existing_document($_course, $document_id, $uploaded_file['size']); + update_existing_document( + $_course, + $document_id, + $uploaded_file['size'] + ); // Update document item_property api_item_property_update( @@ -353,7 +360,7 @@ function handle_uploaded_document( 'file', $file_size, $document_name, - null, + $comment, 0, true, $to_group_id, @@ -397,7 +404,7 @@ function handle_uploaded_document( 'file', $file_size, $document_name, - null, + $comment, 0, true, $to_group_id, @@ -458,7 +465,7 @@ function handle_uploaded_document( 'file', $file_size, $document_name, - null, // comment + $comment, // comment 0, // read only true, // save visibility $to_group_id, @@ -519,7 +526,7 @@ function handle_uploaded_document( 'file', $file_size, $document_name, - null, + $comment, 0, true, $to_group_id, @@ -1331,9 +1338,13 @@ function search_img_from_html($html_file) { * @author Bert Vanderkimpen * @param array $_course current course information * @param int $user_id current user id - * @param string $desiredDirName complete path of the desired name - * @param string The visible name of the directory - * @param int Visibility (0 for invisible, 1 for visible, 2 for deleted) + * @param int $session_id + * @param int $to_group_id + * @param int $to_user_id + * @param string $base_work_dir + * @param string $desired_dir_name complete path of the desired name + * @param string $title + * @param int $visibility (0 for invisible, 1 for visible, 2 for deleted) * @return string actual directory name if it succeeds, * boolean false otherwise */ diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index 499bf1abc9..1fafd4158a 100755 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -295,6 +295,10 @@ define('DRAWING_ASCIISVG', '{DRAWING_ASCIISVG}'); // Forcing PclZip library to use a custom temporary folder. define('PCLZIP_TEMPORARY_DIR', api_get_path(SYS_ARCHIVE_PATH)); +// Relations type with Course manager +define('COURSE_RELATION_TYPE_COURSE_MANAGER', 1); +define('SESSION_RELATION_TYPE_COURSE_MANAGER', 1); + // Relations type with Human resources manager define('COURSE_RELATION_TYPE_RRHH', 1); define('SESSION_RELATION_TYPE_RRHH', 1); diff --git a/main/inc/lib/plugin.class.php b/main/inc/lib/plugin.class.php index e7a42d0aca..d25c19acc9 100755 --- a/main/inc/lib/plugin.class.php +++ b/main/inc/lib/plugin.class.php @@ -189,6 +189,12 @@ class Plugin $help = null; if ($this->get_lang_plugin_exists($name.'_help')) { $help = $this->get_lang($name.'_help'); + if ($name === "show_main_menu_tab") { + $pluginName = strtolower(str_replace('Plugin', '', get_class($this))); + $pluginUrl = api_get_path(WEB_PATH)."plugin/$pluginName/index.php"; + $pluginUrl = "$pluginUrl"; + $help = sprintf($help, $pluginUrl); + } } switch ($type) { @@ -635,4 +641,37 @@ class Plugin return $resp; } + + /** + * This method shows or hides plugin's tab + * @param boolean Shows or hides the main menu plugin tab + * @param string Plugin starter file path + */ + public function manageTab($showTab, $filePath = 'index.php') + { + $langString = str_replace('Plugin', '', get_class($this)); + $pluginName = strtolower($langString); + $pluginUrl = 'plugin/'.$pluginName.'/'.$filePath; + if ($showTab === 'true') { + $tabAdded = $this->addTab($this->get_lang($langString), $pluginUrl); + if ($tabAdded) { + // The page must be refreshed to show the recently created tab + echo ""; + } + } else { + $settingsCurrentTable = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); + $conditions = array( + 'where' => array( + "variable = 'show_tabs' AND title = ? AND comment = ? " => array( + $this->get_lang($langString), + $pluginUrl + ) + ) + ); + $result = Database::select('subkey', $settingsCurrentTable, $conditions); + if (!empty($result)) { + $this->deleteTab($result[0]['subkey']); + } + } + } } diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index 35f97ef65c..44c9c4ea6d 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -19,6 +19,7 @@ class Tracking */ public static function getStats($userId) { + $assignedCourses = array(); if (api_is_drh() && api_drh_can_access_all_session_content()) { $studentList = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus( 'drh_all', @@ -168,6 +169,15 @@ class Tracking null, true ); + + foreach ($platformCourses as $course) { + $assignedCourses[$course['code']] = $course['code']; + } + + $platformCourses = CourseManager::getCoursesFollowedByUser( + $userId, + COURSEMANAGER + ); foreach ($platformCourses as $course) { $courses[$course['code']] = $course['code']; } @@ -183,7 +193,8 @@ class Tracking 'teachers' => $teachers, 'students' => $students, 'courses' => $courses, - 'sessions' => $sessions + 'sessions' => $sessions, + 'assignedCourses' => $assignedCourses ); } diff --git a/main/inc/lib/wami-recorder/record_document.php b/main/inc/lib/wami-recorder/record_document.php index 8f286c57be..69fb55e730 100755 --- a/main/inc/lib/wami-recorder/record_document.php +++ b/main/inc/lib/wami-recorder/record_document.php @@ -56,9 +56,6 @@ if (!is_dir($saveDir)) { DocumentManager::createDefaultAudioFolder($_course); } -$current_session_id = api_get_session_id(); -$groupId = api_get_group_id(); - //avoid duplicates $waminame_to_save = $waminame; $title_to_save = str_replace('_', ' ', $waminame); @@ -80,7 +77,6 @@ $fh = fopen($documentPath, 'w') or die("can't open file"); fwrite($fh, $content); fclose($fh); - $fileInfo = pathinfo($documentPath); $courseInfo = api_get_course_info(); @@ -92,13 +88,12 @@ $file = array( 'from_file' => true ) ); - $output = true; $documentData = DocumentManager::upload_document( $file, $wamidir, - null, - null, + $fileInfo['basename'], + 'wav', 0, 'overwrite', false, @@ -107,6 +102,7 @@ $documentData = DocumentManager::upload_document( if (!empty($documentData)) { $newDocId = $documentData['id']; + $documentData['comment'] = 'mp3'; $newMp3DocumentId = DocumentManager::addAndConvertWavToMp3( $documentData, $courseInfo, diff --git a/main/lang/spanish/tracking.inc.php b/main/lang/spanish/tracking.inc.php index 717c9cf921..20a7d54356 100644 --- a/main/lang/spanish/tracking.inc.php +++ b/main/lang/spanish/tracking.inc.php @@ -297,7 +297,7 @@ $DashboardBlocks = "Bloques del panel de control"; $DashboardList = "Lista del panel de control"; $YouHaveNotEnabledBlocks = "No ha habilitado ningún bloque"; $BlocksHaveBeenUpdatedSuccessfully = "Los bloques han sido actualizados"; -$AttendanceSheetDescription = "Las listas de asistencia permiten registrar las faltas de asistencia de los estudiantes. En caso de ausencia de un estudiante, el profesor deberá registrarlo manualmente en la casilla correspondiente. +$AttendanceSheetDescription = "Las listas de asistencia permiten registrar las faltas de asistencia de los estudiantes. En caso de ausencia de un estudiante, el profesor deberá registrarlo manualmente en la casilla correspondiente. Es posible crear más de una lista de asistencia por cada curso; así por ejemplo, podrá registrar separadamente la asistencia a las clases teóricas y prácticas."; $AttendanceSheetReport = "Informe de hojas de asistencia"; $YouDoNotHaveDoneAttendances = "No tiene asistencias"; diff --git a/main/mySpace/course.php b/main/mySpace/course.php index b1986fe365..f9b82e75d8 100755 --- a/main/mySpace/course.php +++ b/main/mySpace/course.php @@ -197,6 +197,7 @@ function get_courses($from, $limit, $column, $direction) $userId = api_get_user_id(); $sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0; $keyword = isset($_GET['keyword']) ? $_GET['keyword'] : null; + $follow = isset($_GET['follow']) ? true : false; $drhLoaded = false; if (api_is_drh()) { if (api_drh_can_access_all_session_content()) { @@ -224,7 +225,8 @@ function get_courses($from, $limit, $column, $direction) $direction, false, $keyword, - $sessionId + $sessionId, + $follow ); } diff --git a/main/mySpace/index.php b/main/mySpace/index.php index 3c7cc731d1..185e2ec511 100755 --- a/main/mySpace/index.php +++ b/main/mySpace/index.php @@ -160,6 +160,7 @@ $stats = Tracking::getStats($userId); $students = $stats['students']; $teachers = $stats['teachers']; $humanResourcesUsers = $stats['drh']; +$assignedCourses = $stats['assignedCourses']; $courses = $stats['courses']; $sessions = $stats['sessions']; @@ -171,6 +172,7 @@ if (!empty($sessions)) { } // Courses for the user +$countAssignedCourses = count($assignedCourses); $count_courses = count($courses); // Sessions for the user @@ -219,6 +221,7 @@ $nb_posts = $posts; $avg_time_spent = $totalTimeSpent; $linkAddUser = null; +$linkCourseDetailsAsTeacher = null; $linkAddCourse = null; $linkAddSession = null; @@ -228,9 +231,14 @@ if (api_is_platform_admin()) { api_get_path(WEB_CODE_PATH).'admin/dashboard_add_users_to_user.php?user='.api_get_user_id(), array('class' => '') ); + $linkCourseDetailsAsTeacher = ' '.Display::url( + Display::return_icon('2rightarrow.gif', get_lang('Details')), + api_get_path(WEB_CODE_PATH).'mySpace/course.php', + array('class' => '') + ); $linkAddCourse = ' '.Display::url( - Display::return_icon('add.png', get_lang('Add')), - api_get_path(WEB_CODE_PATH).'admin/dashboard_add_courses_to_user.php?user='.api_get_user_id(), + Display::return_icon('2rightarrow.gif', get_lang('Details')), + api_get_path(WEB_CODE_PATH).'mySpace/course.php?follow', array('class' => '') ); $linkAddSession = ' '.Display::url( @@ -276,11 +284,19 @@ echo '
'.Display::url( - get_lang('FollowedCourses'), + get_lang('AssignedCourses'), api_get_path(WEB_CODE_PATH).'mySpace/course.php' ). ' - '.$count_courses.$linkAddCourse.' + '.$count_courses.$linkCourseDetailsAsTeacher.' + + + '.Display::url( + get_lang('FollowedCourses'), + api_get_path(WEB_CODE_PATH).'mySpace/course.php?follow' + ). + ' + '.$countAssignedCourses.$linkAddCourse.' '.Display::url( diff --git a/plugin/buycourses/database.php b/plugin/buycourses/database.php index 10b3221b3e..f1cc054280 100644 --- a/plugin/buycourses/database.php +++ b/plugin/buycourses/database.php @@ -14,7 +14,6 @@ if (!function_exists('api_get_path')) { /** * Create the script context, then execute database queries to enable */ -$objPlugin = BuyCoursesPlugin::create(); $table = Database::get_main_table(TABLE_BUY_SESSION); $sql = "CREATE TABLE IF NOT EXISTS $table ( @@ -407,10 +406,3 @@ $sql = "CREATE TABLE IF NOT EXISTS $table ( status VARCHAR(20) NOT NULL DEFAULT '', date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)"; Database::query($sql); - -//Menu main tabs -$rsTab = $objPlugin->addTab($objPlugin->get_lang('BuyCourses'), 'plugin/buycourses/index.php'); - -if ($rsTab) { - echo ""; -} diff --git a/plugin/buycourses/lang/english.php b/plugin/buycourses/lang/english.php index 7d0a0cbe93..ae2408d163 100644 --- a/plugin/buycourses/lang/english.php +++ b/plugin/buycourses/lang/english.php @@ -1,6 +1,8 @@ 0) { $sql = "SELECT 1 FROM $tableSessionRelUser - WHERE id_session='".$rowSession['session_id']."' AND - id_user ='" . $_SESSION['_user']['user_id'] . "';"; + WHERE id_session ='".$rowSession['session_id']."' AND + id_user = $currentUserId"; Database::query($sql); if (Database::affected_rows() > 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='" . $currentUserId . "';"; Database::query($sql); if (Database::affected_rows() > 0) { $rowSession['enrolled'] = "TMP"; @@ -213,7 +215,7 @@ function userSessionList() } else { $sql = "SELECT 1 FROM $tableBuySessionTemporal WHERE session_id ='".$rowSession['session_id']."' AND - user_id='" . $_SESSION['_user']['user_id'] . "';"; + user_id='" . $currentUserId . "';"; Database::query($sql); if (Database::affected_rows() > 0) { $rowSession['enrolled'] = "TMP"; @@ -230,7 +232,8 @@ function userSessionList() } /** - * + * Lists current user course details + * @return array Course details list */ function userCourseList() { @@ -238,6 +241,7 @@ function userCourseList() $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); $tableCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER); $tableBuyCourseTemporal = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL); + $currentUserId = api_get_user_id(); $sql = "SELECT a.course_id, a.visible, a.price, b.* FROM $tableBuyCourse a, $tableCourse b @@ -255,17 +259,17 @@ function userCourseList() $rowTmp = Database::fetch_assoc($tmp); $row['teacher'] = $rowTmp['firstname'] . ' ' . $rowTmp['lastname']; //check if the user is enrolled - if (isset($_SESSION['_user']) || $_SESSION['_user']['user_id'] != '') { + if ($currentUserId > 0) { $sql = "SELECT 1 FROM $tableCourseRelUser WHERE course_code='" . $row['code'] . "' - AND user_id='" . $_SESSION['_user']['user_id'] . "';"; + AND user_id='" . $currentUserId . "';"; Database::query($sql); if (Database::affected_rows() > 0) { $row['enrolled'] = "YES"; } else { $sql = "SELECT 1 FROM $tableBuyCourseTemporal WHERE course_code='" . $row['code'] . "' - AND user_id='" . $_SESSION['_user']['user_id'] . "';"; + AND user_id='" . $currentUserId . "';"; Database::query($sql); if (Database::affected_rows() > 0) { $row['enrolled'] = "TMP"; @@ -276,7 +280,7 @@ function userCourseList() } else { $sql = "SELECT 1 FROM $tableBuyCourseTemporal WHERE course_code='" . $row['code'] . "' - AND user_id='" . $_SESSION['_user']['user_id'] . "';"; + AND user_id='" . $currentUserId . "';"; Database::query($sql); if (Database::affected_rows() > 0) { $row['enrolled'] = "TMP"; @@ -297,11 +301,15 @@ function userCourseList() } /** - * + * Checks if a session or a course is already bought + * @param string Session id or course code + * @param int User id + * @param string What has to be checked + * @return boolean True if it is already bought, and false otherwise */ function checkUserBuy($parameter, $user, $type = 'COURSE') { - $sql = "SELECT 1 FROM %s WHERE %s ='" . $parameter . "' AND id_user='" . $user . "';"; + $sql = "SELECT 1 FROM %s WHERE %s ='" . Database::escape_string($parameter) . "' AND id_user='" . intval($user) . "';"; $sql = $type === 'SESSION' ? sprintf($sql, Database::get_main_table(TABLE_MAIN_SESSION_USER), 'id_session') : sprintf($sql, Database::get_main_table(TABLE_MAIN_COURSE_USER), 'course_code'); @@ -314,11 +322,15 @@ function checkUserBuy($parameter, $user, $type = 'COURSE') } /** - * + * Checks if a session or a course has already a transfer + * @param string Session id or course code + * @param int User id + * @param string What has to be checked + * @return boolean True if it has already a transfer, and false otherwise */ function checkUserBuyTransfer($parameter, $user, $type = 'COURSE') { - $sql = "SELECT 1 FROM %s WHERE %s ='" . $parameter . "' AND id_user='" . $user . "';"; + $sql = "SELECT 1 FROM %s WHERE %s ='" . Database::escape_string($parameter) . "' AND user_id='" . intval($user) . "';"; $sql = $type === 'SESSION' ? sprintf($sql, Database::get_main_table(TABLE_BUY_SESSION_TEMPORARY), 'session_id') : sprintf($sql, Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL), 'course_code'); @@ -331,7 +343,8 @@ function checkUserBuyTransfer($parameter, $user, $type = 'COURSE') } /** - * + * Returns an array with all the categories + * @return array All the categories */ function listCategories() { @@ -462,6 +475,7 @@ function sessionInfo($code) $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); $tableSessionRelUser = Database::get_main_table(TABLE_MAIN_SESSION_USER); $tableBuySessionTemporal = Database::get_main_table(TABLE_BUY_SESSION_TEMPORARY); + $currentUserId = api_get_user_id(); $code = Database::escape_string($code); $sql = "SELECT a.session_id, a.visible, a.price, b.* @@ -505,15 +519,15 @@ function sessionInfo($code) } } //check if the user is enrolled in the current session - if (isset($_SESSION['_user']) || $_SESSION['_user']['user_id'] != '') { + if ($currentUserId > 0) { $sql = "SELECT 1 FROM $tableSessionRelUser - WHERE user_id='".$_SESSION['_user']['user_id']."';"; + WHERE id_user = $currentUserId"; Database::query($sql); if (Database::affected_rows() > 0) { $rowSession['enrolled'] = "YES"; } else { $sql = "SELECT 1 FROM $tableBuySessionTemporal - WHERE user_id='".$_SESSION['_user']['user_id']."';"; + WHERE user_id='".$currentUserId."';"; Database::query($sql); if (Database::affected_rows() > 0) { $rowSession['enrolled'] = "TMP"; @@ -523,7 +537,7 @@ function sessionInfo($code) } } else { $sql = "SELECT 1 FROM $tableBuySessionTemporal - WHERE user_id='".$_SESSION['_user']['user_id']."';"; + WHERE user_id='".$currentUserId."';"; Database::query($sql); if (Database::affected_rows() > 0) { $rowSession['enrolled'] = "TMP"; @@ -546,6 +560,7 @@ function courseInfo($code) $tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE); $tableCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER); $tableUser = Database::get_main_table(TABLE_MAIN_USER); + $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 @@ -564,10 +579,10 @@ function courseInfo($code) $rowTmp = Database::fetch_assoc($tmp); $row['teacher'] = $rowTmp['firstname'] . ' ' . $rowTmp['lastname']; //Check if student is enrolled - if (isset($_SESSION['_user']) || $_SESSION['_user']['user_id'] != '') { + if ($currentUserId > 0) { $sql = "SELECT 1 FROM $tableCourseRelUser WHERE course_code='" . $row['code'] . "' - AND user_id='" . $_SESSION['_user']['user_id'] . "';"; + AND user_id='" . $currentUserId . "';"; Database::query($sql); if (Database::affected_rows() > 0) { $row['enrolled'] = "YES"; diff --git a/plugin/buycourses/src/buy_course_plugin.class.php b/plugin/buycourses/src/buy_course_plugin.class.php index a3e61f9b43..c2f291c7c1 100644 --- a/plugin/buycourses/src/buy_course_plugin.class.php +++ b/plugin/buycourses/src/buy_course_plugin.class.php @@ -31,6 +31,7 @@ class BuyCoursesPlugin extends Plugin Alex Aragón - BeezNest (Design icons and css styles), Imanol Losada - BeezNest (introduction of sessions purchase)', array( + 'show_main_menu_tab' => 'boolean', 'include_sessions' => 'boolean', 'paypal_enable' => 'boolean', 'transfer_enable' => 'boolean', @@ -69,8 +70,6 @@ class BuyCoursesPlugin extends Plugin $sql = "DROP TABLE IF EXISTS $tableToBeDeleted"; Database::query($sql); } - - $objPlugin = BuyCoursesPlugin::create(); - $objPlugin->deleteTab('custom_tab_1'); + $this->manageTab(false); } } diff --git a/plugin/buycourses/src/index.buycourses.php b/plugin/buycourses/src/index.buycourses.php index 3fd88c431c..780b757ef9 100644 --- a/plugin/buycourses/src/index.buycourses.php +++ b/plugin/buycourses/src/index.buycourses.php @@ -11,11 +11,12 @@ $plugin = BuyCoursesPlugin::create(); $guess_enable = $plugin->get('unregistered_users_enable'); if ($guess_enable == "true" || isset($_SESSION['_user'])) { + $isAdmin = api_is_platform_admin(); $title = $plugin->get_lang('CourseListOnSale'); $templateName = $plugin->get_lang('BuyCourses'); $tpl = new Template($templateName); - $tpl->assign('isAdmin', api_is_platform_admin()); + $tpl->assign('isAdmin', $isAdmin); $tpl->assign('title', $title); $tpl->assign('BuySessions', $plugin->get_lang('BuySessions')); $tpl->assign('BuyCourses', $templateName); @@ -25,7 +26,7 @@ if ($guess_enable == "true" || isset($_SESSION['_user'])) { $tpl->assign('OrdersPendingOfPayment', $plugin->get_lang('OrdersPendingOfPayment')); $listing_tpl = 'buycourses/view/index.tpl'; $content = $tpl->fetch($listing_tpl); - $tpl->assign('content', $content); - $tpl->display_one_col_template(); + $tpl->assign('content', $content); + // If the user is NOT an administrator, redirect it to course/session buy list + $isAdmin ? $tpl->display_one_col_template() : header('Location: src/list.php'); } - diff --git a/plugin/buycourses/view/index.tpl b/plugin/buycourses/view/index.tpl index 0169191372..33b894fa1f 100644 --- a/plugin/buycourses/view/index.tpl +++ b/plugin/buycourses/view/index.tpl @@ -19,11 +19,11 @@
{% endif %}
- +
- +
@@ -60,4 +60,4 @@ {% endif %}
-
\ No newline at end of file + diff --git a/plugin/buycourses/view/process.tpl b/plugin/buycourses/view/process.tpl index fea838a738..b2624a50b4 100644 --- a/plugin/buycourses/view/process.tpl +++ b/plugin/buycourses/view/process.tpl @@ -23,7 +23,7 @@
-

{{ title }}

+

{{ title }}

{{ 'From'|get_lang }} {{ session.date_start }} {{ 'To'|get_lang }} {{ session.date_end }}
@@ -65,7 +65,7 @@
{% endfor %} - {% else %} + {% else %}
diff --git a/plugin/dashboard/block_course/block_course.class.php b/plugin/dashboard/block_course/block_course.class.php index 288ed5047b..5c30433fe3 100755 --- a/plugin/dashboard/block_course/block_course.class.php +++ b/plugin/dashboard/block_course/block_course.class.php @@ -130,7 +130,7 @@ class BlockCourse extends Block } $content .= $data_table; if (!empty($course_data)) { - $content .= '
' . get_lang('SeeMore') . '
'; + $content .= '
' . get_lang('SeeMore') . '
'; } $content .= '
';