Merge branch '1.9.x' of github.com:chamilo/chamilo-lms into 1.9.x

1.9.x
Yannick Warnier 12 years ago
commit e10c873482
  1. 4
      main/admin/configure_plugin.php
  2. 2
      main/exercice/question_pool.php
  3. 108
      main/forum/forumfunction.inc.php
  4. 19
      main/inc/lib/course.lib.php
  5. 37
      main/inc/lib/document.lib.php
  6. 39
      main/inc/lib/fileUpload.lib.php
  7. 4
      main/inc/lib/main_api.lib.php
  8. 39
      main/inc/lib/plugin.class.php
  9. 13
      main/inc/lib/tracking.lib.php
  10. 10
      main/inc/lib/wami-recorder/record_document.php
  11. 2
      main/lang/spanish/tracking.inc.php
  12. 4
      main/mySpace/course.php
  13. 24
      main/mySpace/index.php
  14. 8
      plugin/buycourses/database.php
  15. 2
      plugin/buycourses/lang/english.php
  16. 2
      plugin/buycourses/lang/french.php
  17. 2
      plugin/buycourses/lang/spanish.php
  18. 59
      plugin/buycourses/src/buy_course.lib.php
  19. 5
      plugin/buycourses/src/buy_course_plugin.class.php
  20. 9
      plugin/buycourses/src/index.buycourses.php
  21. 6
      plugin/buycourses/view/index.tpl
  22. 4
      plugin/buycourses/view/process.tpl
  23. 2
      plugin/dashboard/block_course/block_course.class.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');
}
}

@ -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 = "<a href='admin.php?".api_get_cidreq()."&editQuestion=$in_questionid&type=$in_questiontype&fromExercise=$in_fromex'>".

@ -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 <patrick.cool@UGent.be>, 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 <patrick.cool@UGent.be>, 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 <patrick.cool@UGent.be>, 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?&amp;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 <patrick.cool@UGent.be>, 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."'

@ -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:

@ -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,

@ -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
*/

@ -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);

@ -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 = "<a href=$pluginUrl>$pluginUrl</a>";
$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 "<script>location.href = '".Security::remove_XSS($_SERVER['REQUEST_URI'])."';</script>";
}
} 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']);
}
}
}
}

@ -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
);
}

@ -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,

@ -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";

@ -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
);
}

@ -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 '<div class="report_section">
</tr>
<tr>
<td>'.Display::url(
get_lang('FollowedCourses'),
get_lang('AssignedCourses'),
api_get_path(WEB_CODE_PATH).'mySpace/course.php'
).
'</td>
<td align="right">'.$count_courses.$linkAddCourse.'</td>
<td align="right">'.$count_courses.$linkCourseDetailsAsTeacher.'</td>
</tr>
<tr>
<td>'.Display::url(
get_lang('FollowedCourses'),
api_get_path(WEB_CODE_PATH).'mySpace/course.php?follow'
).
'</td>
<td align="right">'.$countAssignedCourses.$linkAddCourse.'</td>
</tr>
<tr>
<td>'.Display::url(

@ -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 "<script>location.href = '" . Security::remove_XSS($_SERVER['REQUEST_URI']) . "';</script>";
}

@ -1,6 +1,8 @@
<?php
$strings['plugin_title'] = "Sell courses";
$strings['plugin_comment'] = "Sell courses directly through your Chamilo portal, using a PayPal account to receive funds. This plugin is in beta version. Neither the Chamilo association nor the developers involved could be considered responsible of any issue you might suffer using this plugin.";
$strings['show_main_menu_tab'] = "Show tab in main menu";
$strings['show_main_menu_tab_help'] = "In case of not wanting to show the tab, you can create this link in your Chamilo homepage : %s";
$strings['Visible'] = "Show list";
$strings['Options'] = "Options";
$strings['Price'] = "Price";

@ -1,6 +1,8 @@
<?php
$strings['plugin_title'] = "Vente de cours";
$strings['plugin_comment'] = "Vendez vos cours directement depuis votre portail Chamilo, au travers d'un compte PayPal. Plugin en version beta, à utiliser avec précaution. Ni l'association Chamilo ni les développeurs impliqués dans le développement de ce plugin ne sauraient être tenus responsables d'un quelconque inconvénient causé par celui-ci.";
$strings['show_main_menu_tab'] = "Montrer l'onglet dans le menu principal";
$strings['show_main_menu_tab_help'] = "Dans le cas où vous ne souhaitez pas montrer l'onglet, il est possible de rajouter le lien suivant à votre portail Chamilo: %s";
$strings['Visible'] = "Montrer dans la liste";
$strings['Options'] = "Options";
$strings['Price'] = "Prix";

@ -1,6 +1,8 @@
<?php
$strings['plugin_title'] = "Venta de cursos";
$strings['plugin_comment'] = "Vender cursos a través de PayPal directamente desde su portal Chamilo. Plugin en versión Beta, a usar con mucha precaución. La asociación Chamilo y los desarrolladores involucrados no pueden ser considerados responsables de cualquier inconveniente que se presente.";
$strings['show_main_menu_tab'] = "Mostrar pestaña en el menu principal";
$strings['show_main_menu_tab_help'] = "En caso de no querer mostrar la pestaña, puede agregar el siguiente enlace a su portal Chamilo: %s";
$strings['Visible'] = "Mostrar en el listado";
$strings['Options'] = "Opciones";
$strings['Price'] = "Precio";

@ -136,7 +136,8 @@ function listCourses()
}
/**
*
* Lists current user session details, including each session course details
* @return array Sessions details list
*/
function userSessionList()
{
@ -148,6 +149,7 @@ function userSessionList()
$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();
// get existing sessions
$sql = "SELECT a.session_id, a.visible, a.price, b.*
@ -192,17 +194,17 @@ function userSessionList()
}
}
//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 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";

@ -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);
}
}

@ -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');
}

@ -19,11 +19,11 @@
</div>
{% endif %}
<div class="span12">
</div>
</div>
<div class="row">
<div class="span3">
<div class="thumbnail">
<img src="resources/img/128/buycourses.png">
@ -60,4 +60,4 @@
{% endif %}
</div>
</div>
</div>
</div>

@ -23,7 +23,7 @@
<div class="row">
<div class="span4">
<div class="categories-course-description">
<h3>{{ title }}</h3>
<h3>{{ title }}</h3>
<h5>{{ 'From'|get_lang }} {{ session.date_start }} {{ 'To'|get_lang }} {{ session.date_end }}</h5>
</div>
</div>
@ -65,7 +65,7 @@
</div>
</div>
{% endfor %}
{% else %}
{% else %}
<div class="row">
<div class="span">
<div class="thumbnail">

@ -130,7 +130,7 @@ class BlockCourse extends Block
}
$content .= $data_table;
if (!empty($course_data)) {
$content .= '<div style="text-align:right;margin-top:10px;"><a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/course.php">' . get_lang('SeeMore') . '</a></div>';
$content .= '<div style="text-align:right;margin-top:10px;"><a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/course.php?follow">' . get_lang('SeeMore') . '</a></div>';
}
$content .= '</div>';

Loading…
Cancel
Save