|
@@ -266,7 +266,9 @@ class learnpath
|
|
|
error_log(
|
|
|
'New LP - learnpath::__construct() - ' .
|
|
|
'aicc object with id ' . $my_item_id .
|
|
|
- ' set in items[]', 0);
|
|
|
+ ' set in items[]',
|
|
|
+ 0
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -482,6 +484,8 @@ class learnpath
|
|
|
* @param string $description
|
|
|
* @param int $prerequisites
|
|
|
* @param int $max_time_allowed
|
|
|
+ * @param int $userId
|
|
|
+ *
|
|
|
* @return int
|
|
|
*/
|
|
|
public function add_item(
|
|
@@ -492,7 +496,8 @@ class learnpath
|
|
|
$title,
|
|
|
$description,
|
|
|
$prerequisites = 0,
|
|
|
- $max_time_allowed = 0
|
|
|
+ $max_time_allowed = 0,
|
|
|
+ $userId = 0
|
|
|
) {
|
|
|
$course_id = $this->course_info['real_id'];
|
|
|
if ($this->debug > 0) {
|
|
@@ -503,6 +508,8 @@ class learnpath
|
|
|
$this->course_info = api_get_course_info($this->cc);
|
|
|
$course_id = $this->course_info['real_id'];
|
|
|
}
|
|
|
+ $userId = empty($userId) ? api_get_user_id() : $userId;
|
|
|
+ $sessionId = api_get_session_id();
|
|
|
$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
|
|
|
$_course = $this->course_info;
|
|
|
$parent = intval($parent);
|
|
@@ -656,31 +663,37 @@ class learnpath
|
|
|
'/audio',
|
|
|
'folder',
|
|
|
0,
|
|
|
- 'audio'
|
|
|
+ 'audio',
|
|
|
+ '',
|
|
|
+ 0,
|
|
|
+ true,
|
|
|
+ null,
|
|
|
+ $sessionId,
|
|
|
+ $userId
|
|
|
);
|
|
|
api_item_property_update(
|
|
|
$_course,
|
|
|
TOOL_DOCUMENT,
|
|
|
$audio_id,
|
|
|
'FolderCreated',
|
|
|
- api_get_user_id(),
|
|
|
+ $userId,
|
|
|
null,
|
|
|
null,
|
|
|
null,
|
|
|
null,
|
|
|
- api_get_session_id()
|
|
|
+ $sessionId
|
|
|
);
|
|
|
api_item_property_update(
|
|
|
$_course,
|
|
|
TOOL_DOCUMENT,
|
|
|
$audio_id,
|
|
|
'invisible',
|
|
|
- api_get_user_id(),
|
|
|
+ $userId,
|
|
|
null,
|
|
|
null,
|
|
|
null,
|
|
|
null,
|
|
|
- api_get_session_id()
|
|
|
+ $sessionId
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -689,7 +702,7 @@ class learnpath
|
|
|
$_FILES['mp3'],
|
|
|
api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document',
|
|
|
'/audio',
|
|
|
- api_get_user_id(),
|
|
|
+ $userId,
|
|
|
'',
|
|
|
'',
|
|
|
'',
|
|
@@ -731,7 +744,8 @@ class learnpath
|
|
|
$zipname = '',
|
|
|
$publicated_on = '',
|
|
|
$expired_on = '',
|
|
|
- $categoryId = 0
|
|
|
+ $categoryId = 0,
|
|
|
+ $userId = 0
|
|
|
) {
|
|
|
global $charset;
|
|
|
|
|
@@ -753,6 +767,8 @@ class learnpath
|
|
|
// Session id.
|
|
|
$session_id = api_get_session_id();
|
|
|
|
|
|
+ $userId = empty($userId) ? api_get_user_id() : $userId;
|
|
|
+
|
|
|
$check_name = "SELECT * FROM $tbl_lp
|
|
|
WHERE c_id = $course_id AND name = '$name'";
|
|
|
|
|
@@ -859,9 +875,9 @@ class learnpath
|
|
|
TOOL_LEARNPATH,
|
|
|
$id,
|
|
|
'LearnpathAdded',
|
|
|
- api_get_user_id()
|
|
|
+ $userId
|
|
|
);
|
|
|
- api_set_default_visibility($id, TOOL_LEARNPATH, 0, $courseInfo);
|
|
|
+ api_set_default_visibility($id, TOOL_LEARNPATH, 0, $courseInfo, $session_id, $userId);
|
|
|
return $id;
|
|
|
}
|
|
|
break;
|
|
@@ -5576,15 +5592,18 @@ class learnpath
|
|
|
|
|
|
$title_cut = cut($arrLP[$i]['title'], 25);
|
|
|
|
|
|
- $url = api_get_self() . '?'.api_get_cidreq().'&action=view_item&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id;
|
|
|
- $title_cut = Display::url(
|
|
|
- $title_cut,
|
|
|
- $url,
|
|
|
- array(
|
|
|
- 'class' => 'moved',
|
|
|
- 'data-title' => $title_cut
|
|
|
- )
|
|
|
- );
|
|
|
+ // Link for the documents
|
|
|
+ if ($arrLP[$i]['item_type'] == 'document') {
|
|
|
+ $url = api_get_self() . '?'.api_get_cidreq().'&action=view_item&mode=preview_document&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id;
|
|
|
+ $title_cut = Display::url(
|
|
|
+ $title_cut,
|
|
|
+ $url,
|
|
|
+ array(
|
|
|
+ 'class' => 'ajax moved',
|
|
|
+ 'data-title' => $title_cut
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
if (($i % 2) == 0) {
|
|
|
$oddClass = 'row_odd';
|
|
@@ -5898,18 +5917,22 @@ class learnpath
|
|
|
/**
|
|
|
* Creates the default learning path folder
|
|
|
* @param array $course
|
|
|
+ * @param int $creatorId
|
|
|
+ *
|
|
|
* @return bool
|
|
|
*/
|
|
|
- public static function generate_learning_path_folder($course)
|
|
|
+ public static function generate_learning_path_folder($course, $creatorId = 0)
|
|
|
{
|
|
|
// Creating learning_path folder
|
|
|
$dir = '/learning_path';
|
|
|
$filepath = api_get_path(SYS_COURSE_PATH).$course['path'] . '/document';
|
|
|
+ $creatorId = empty($creatorId) ? api_get_user_id() : $creatorId;
|
|
|
+
|
|
|
$folder = false;
|
|
|
if (!is_dir($filepath.'/'.$dir)) {
|
|
|
$folderData = create_unexisting_directory(
|
|
|
$course,
|
|
|
- api_get_user_id(),
|
|
|
+ $creatorId,
|
|
|
api_get_session_id(),
|
|
|
0,
|
|
|
0,
|
|
@@ -5924,15 +5947,18 @@ class learnpath
|
|
|
} else {
|
|
|
$folder = true;
|
|
|
}
|
|
|
+
|
|
|
return $folder;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @param array $course
|
|
|
* @param string $lp_name
|
|
|
+ * @param int $creatorId
|
|
|
+ *
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function generate_lp_folder($course, $lp_name = null)
|
|
|
+ public function generate_lp_folder($course, $lp_name = '', $creatorId = 0)
|
|
|
{
|
|
|
$filepath = '';
|
|
|
$dir = '/learning_path/';
|
|
@@ -5940,8 +5966,11 @@ class learnpath
|
|
|
if (empty($lp_name)) {
|
|
|
$lp_name = $this->name;
|
|
|
}
|
|
|
+ $creatorId = empty($creatorId) ? api_get_user_id() : $creatorId;
|
|
|
|
|
|
- $folder = self::generate_learning_path_folder($course);
|
|
|
+ $folder = self::generate_learning_path_folder($course, $creatorId);
|
|
|
+ // Creating LP folder
|
|
|
+ if ($folder) {
|
|
|
// Limits title size
|
|
|
$title = api_substr(api_replace_dangerous_char($lp_name), 0 , 80);
|
|
|
$dir = $dir.$title;
|
|
@@ -5954,7 +5983,7 @@ class learnpath
|
|
|
if (!is_dir($filepath.'/'.$dir)) {
|
|
|
$folderData = create_unexisting_directory(
|
|
|
$course,
|
|
|
- api_get_user_id(),
|
|
|
+ $creatorId,
|
|
|
0,
|
|
|
0,
|
|
|
0,
|
|
@@ -5998,10 +6027,11 @@ class learnpath
|
|
|
* @param string $title
|
|
|
* @param string $extension
|
|
|
* @param int $parentId
|
|
|
+ * @param int $creatorId creator id
|
|
|
*
|
|
|
* @return string
|
|
|
*/
|
|
|
- public function create_document($courseInfo, $content = '', $title = '', $extension = 'html', $parentId = 0)
|
|
|
+ public function create_document($courseInfo, $content = '', $title = '', $extension = 'html', $parentId = 0, $creatorId = 0)
|
|
|
{
|
|
|
if (!empty($courseInfo)) {
|
|
|
$course_id = $courseInfo['real_id'];
|
|
@@ -6009,6 +6039,10 @@ class learnpath
|
|
|
$course_id = api_get_course_int_id();
|
|
|
}
|
|
|
|
|
|
+ $creatorId = empty($creatorId) ? api_get_user_id() : $creatorId;
|
|
|
+ $sessionId = api_get_session_id();
|
|
|
+
|
|
|
+
|
|
|
//$dir = '/';
|
|
|
// Generates folder
|
|
|
$result = $this->generate_lp_folder($courseInfo);
|
|
@@ -6112,7 +6146,13 @@ class learnpath
|
|
|
$save_file_path,
|
|
|
'file',
|
|
|
$file_size,
|
|
|
- $tmp_filename
|
|
|
+ $tmp_filename,
|
|
|
+ '',
|
|
|
+ 0, //readonly
|
|
|
+ true,
|
|
|
+ null,
|
|
|
+ $sessionId,
|
|
|
+ $creatorId
|
|
|
);
|
|
|
|
|
|
if ($document_id) {
|
|
@@ -6121,15 +6161,15 @@ class learnpath
|
|
|
TOOL_DOCUMENT,
|
|
|
$document_id,
|
|
|
'DocumentAdded',
|
|
|
- api_get_user_id(),
|
|
|
+ $creatorId,
|
|
|
null,
|
|
|
null,
|
|
|
null,
|
|
|
null,
|
|
|
- api_get_session_id()
|
|
|
+ $sessionId
|
|
|
);
|
|
|
|
|
|
- $new_comment = (isset($_POST['comment'])) ? trim($_POST['comment']) : '';
|
|
|
+ $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
|
|
|
$new_title = $originalTitle;
|
|
|
|
|
|
if ($new_comment || $new_title) {
|