|
|
|
@ -840,38 +840,6 @@ function api_get_path($path = '', $configuration = []) |
|
|
|
|
$root_sys = api_add_trailing_slash($root_sys); |
|
|
|
|
$root_rel = api_add_trailing_slash($root_rel); |
|
|
|
|
|
|
|
|
|
// Initialization of a table that contains common-purpose paths. |
|
|
|
|
/*$paths[$root_web][REL_PATH] = $root_rel; |
|
|
|
|
$paths[$root_web][REL_CODE_PATH] = $root_rel.$code_folder; |
|
|
|
|
$paths[$root_web][WEB_PATH] = $rootWebWithSlash; |
|
|
|
|
$paths[$root_web][WEB_CODE_PATH] = $rootWebWithSlash.'main/'; |
|
|
|
|
$paths[$root_web][WEB_COURSE_PATH] = $rootWebWithSlash.$course_folder; |
|
|
|
|
$paths[$root_web][WEB_PLUGIN_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_PLUGIN_PATH]; |
|
|
|
|
$paths[$root_web][WEB_PLUGIN_ASSET_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_PLUGIN_ASSET_PATH]; |
|
|
|
|
$paths[$root_web][WEB_ARCHIVE_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_ARCHIVE_PATH]; |
|
|
|
|
$paths[$root_web][WEB_CSS_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_CSS_PATH]; |
|
|
|
|
//$paths[$root_web][WEB_UPLOAD_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_UPLOAD_PATH]; |
|
|
|
|
$paths[$root_web][WEB_PUBLIC_PATH] = $rootWebWithSlash; |
|
|
|
|
|
|
|
|
|
$paths[$root_web][WEB_IMG_PATH] = $rootWebWithSlash.$paths[$root_web][WEB_IMG_PATH]; |
|
|
|
|
$paths[$root_web][WEB_LIBRARY_PATH] = $paths[$root_web][WEB_CODE_PATH].$paths[$root_web][WEB_LIBRARY_PATH]; |
|
|
|
|
$paths[$root_web][WEB_LIBRARY_JS_PATH] = $paths[$root_web][WEB_CODE_PATH].$paths[$root_web][WEB_LIBRARY_JS_PATH]; |
|
|
|
|
$paths[$root_web][WEB_AJAX_PATH] = $paths[$root_web][WEB_CODE_PATH].$paths[$root_web][WEB_AJAX_PATH]; |
|
|
|
|
|
|
|
|
|
$paths[$root_web][SYS_PATH] = $root_sys; |
|
|
|
|
$paths[$root_web][SYS_CODE_PATH] = $root_sys.$code_folder; |
|
|
|
|
$paths[$root_web][SYS_TEST_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][SYS_TEST_PATH]; |
|
|
|
|
$paths[$root_web][SYS_TEMPLATE_PATH] = $paths[$root_web][SYS_CODE_PATH].$paths[$root_web][SYS_TEMPLATE_PATH]; |
|
|
|
|
$paths[$root_web][SYS_PUBLIC_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][SYS_PUBLIC_PATH]; |
|
|
|
|
$paths[$root_web][SYS_CSS_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][SYS_CSS_PATH]; |
|
|
|
|
$paths[$root_web][SYS_FONTS_PATH] = $paths[$root_web][SYS_CODE_PATH].$paths[$root_web][SYS_FONTS_PATH]; |
|
|
|
|
$paths[$root_web][SYS_ARCHIVE_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][SYS_ARCHIVE_PATH]; |
|
|
|
|
$paths[$root_web][SYS_APP_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][SYS_APP_PATH]; |
|
|
|
|
$paths[$root_web][SYS_UPLOAD_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][SYS_UPLOAD_PATH]; |
|
|
|
|
$paths[$root_web][SYS_PLUGIN_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][SYS_PLUGIN_PATH]; |
|
|
|
|
$paths[$root_web][LIBRARY_PATH] = $paths[$root_web][SYS_CODE_PATH].$paths[$root_web][LIBRARY_PATH]; |
|
|
|
|
$paths[$root_web][CONFIGURATION_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][CONFIGURATION_PATH];*/ |
|
|
|
|
|
|
|
|
|
global $virtualChamilo; |
|
|
|
|
if (!empty($virtualChamilo)) { |
|
|
|
|
$paths[SYS_ARCHIVE_PATH] = api_add_trailing_slash($virtualChamilo[SYS_ARCHIVE_PATH]); |
|
|
|
@ -3834,309 +3802,6 @@ function convert_sql_date($last_post_datetime) |
|
|
|
|
return mktime((int) $hour, (int) $min, (int) $sec, (int) $month, (int) $day, (int) $year); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Delete a row in the c_item_property table. |
|
|
|
|
* |
|
|
|
|
* @param array $courseInfo |
|
|
|
|
* @param string $tool |
|
|
|
|
* @param int $itemId |
|
|
|
|
* @param int $userId |
|
|
|
|
* @param int $groupId group.iid |
|
|
|
|
* @param int $sessionId |
|
|
|
|
* |
|
|
|
|
* @return false|null |
|
|
|
|
*/ |
|
|
|
|
function api_item_property_delete( |
|
|
|
|
$courseInfo, |
|
|
|
|
$tool, |
|
|
|
|
$itemId, |
|
|
|
|
$userId, |
|
|
|
|
$groupId = 0, |
|
|
|
|
$sessionId = 0 |
|
|
|
|
) { |
|
|
|
|
if (empty($courseInfo)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$courseId = (int) $courseInfo['real_id']; |
|
|
|
|
|
|
|
|
|
if (empty($courseId) || empty($tool) || empty($itemId)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$table = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
|
|
|
$tool = Database::escape_string($tool); |
|
|
|
|
$itemId = intval($itemId); |
|
|
|
|
$userId = intval($userId); |
|
|
|
|
$groupId = intval($groupId); |
|
|
|
|
$sessionId = intval($sessionId); |
|
|
|
|
|
|
|
|
|
$groupCondition = " AND to_group_id = $groupId "; |
|
|
|
|
if (empty($groupId)) { |
|
|
|
|
$groupCondition = " AND (to_group_id is NULL OR to_group_id = 0) "; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$userCondition = " AND to_user_id = $userId "; |
|
|
|
|
if (empty($userId)) { |
|
|
|
|
$userCondition = " AND (to_user_id is NULL OR to_user_id = 0) "; |
|
|
|
|
} |
|
|
|
|
$sessionCondition = api_get_session_condition($sessionId, true, false, 'session_id'); |
|
|
|
|
$sql = "DELETE FROM $table |
|
|
|
|
WHERE |
|
|
|
|
c_id = $courseId AND |
|
|
|
|
tool = '$tool' AND |
|
|
|
|
ref = $itemId |
|
|
|
|
$sessionCondition |
|
|
|
|
$userCondition |
|
|
|
|
$groupCondition |
|
|
|
|
"; |
|
|
|
|
|
|
|
|
|
Database::query($sql); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets item property by tool. |
|
|
|
|
* |
|
|
|
|
* @param string course code |
|
|
|
|
* @param string tool name, linked to 'rubrique' of the course tool_list (Warning: language sensitive !!) |
|
|
|
|
* @param int id of the item itself, linked to key of every tool ('id', ...), "*" = all items of the tool |
|
|
|
|
* @param int $session_id |
|
|
|
|
* @param string $tool |
|
|
|
|
* @param string $course_code |
|
|
|
|
* |
|
|
|
|
* @return array All fields from c_item_property (all rows found) or empty array |
|
|
|
|
*/ |
|
|
|
|
function api_get_item_property_by_tool($tool, $course_code, $session_id = null) |
|
|
|
|
{ |
|
|
|
|
$course_info = api_get_course_info($course_code); |
|
|
|
|
$tool = Database::escape_string($tool); |
|
|
|
|
|
|
|
|
|
// Definition of tables. |
|
|
|
|
$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
|
|
|
$session_id = (int) $session_id; |
|
|
|
|
$session_condition = ' AND session_id = '.$session_id; |
|
|
|
|
if (empty($session_id)) { |
|
|
|
|
$session_condition = " AND (session_id = 0 OR session_id IS NULL) "; |
|
|
|
|
} |
|
|
|
|
$course_id = $course_info['real_id']; |
|
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM $item_property_table |
|
|
|
|
WHERE |
|
|
|
|
c_id = $course_id AND |
|
|
|
|
tool = '$tool' |
|
|
|
|
$session_condition "; |
|
|
|
|
$rs = Database::query($sql); |
|
|
|
|
$list = []; |
|
|
|
|
if (Database::num_rows($rs) > 0) { |
|
|
|
|
while ($row = Database::fetch_array($rs, 'ASSOC')) { |
|
|
|
|
$list[] = $row; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets item property by tool and user. |
|
|
|
|
* |
|
|
|
|
* @param int $userId |
|
|
|
|
* @param int $tool |
|
|
|
|
* @param int $courseId |
|
|
|
|
* @param int $session_id |
|
|
|
|
* |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
function api_get_item_property_list_by_tool_by_user( |
|
|
|
|
$userId, |
|
|
|
|
$tool, |
|
|
|
|
$courseId, |
|
|
|
|
$session_id = 0 |
|
|
|
|
) { |
|
|
|
|
$userId = intval($userId); |
|
|
|
|
$tool = Database::escape_string($tool); |
|
|
|
|
$session_id = intval($session_id); |
|
|
|
|
$courseId = intval($courseId); |
|
|
|
|
|
|
|
|
|
// Definition of tables. |
|
|
|
|
$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
|
|
|
$session_condition = ' AND session_id = '.$session_id; |
|
|
|
|
if (empty($session_id)) { |
|
|
|
|
$session_condition = " AND (session_id = 0 OR session_id IS NULL) "; |
|
|
|
|
} |
|
|
|
|
$sql = "SELECT * FROM $item_property_table |
|
|
|
|
WHERE |
|
|
|
|
insert_user_id = $userId AND |
|
|
|
|
c_id = $courseId AND |
|
|
|
|
tool = '$tool' |
|
|
|
|
$session_condition "; |
|
|
|
|
|
|
|
|
|
$rs = Database::query($sql); |
|
|
|
|
$list = []; |
|
|
|
|
if (Database::num_rows($rs) > 0) { |
|
|
|
|
while ($row = Database::fetch_array($rs, 'ASSOC')) { |
|
|
|
|
$list[] = $row; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets item property id from tool of a course. |
|
|
|
|
* |
|
|
|
|
* @param string $course_code course code |
|
|
|
|
* @param string $tool tool name, linked to 'rubrique' of the course tool_list (Warning: language sensitive !!) |
|
|
|
|
* @param int $ref id of the item itself, linked to key of every tool ('id', ...), "*" = all items of the tool |
|
|
|
|
* @param int $sessionId Session ID (optional) |
|
|
|
|
* |
|
|
|
|
* @return int |
|
|
|
|
*/ |
|
|
|
|
function api_get_item_property_id($course_code, $tool, $ref, $sessionId = 0) |
|
|
|
|
{ |
|
|
|
|
$course_info = api_get_course_info($course_code); |
|
|
|
|
$tool = Database::escape_string($tool); |
|
|
|
|
$ref = (int) $ref; |
|
|
|
|
|
|
|
|
|
// Definition of tables. |
|
|
|
|
$tableItemProperty = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
|
|
|
$course_id = $course_info['real_id']; |
|
|
|
|
$sessionId = (int) $sessionId; |
|
|
|
|
$sessionCondition = " AND session_id = $sessionId "; |
|
|
|
|
if (empty($sessionId)) { |
|
|
|
|
$sessionCondition = ' AND (session_id = 0 OR session_id IS NULL) '; |
|
|
|
|
} |
|
|
|
|
$sql = "SELECT id FROM $tableItemProperty |
|
|
|
|
WHERE |
|
|
|
|
c_id = $course_id AND |
|
|
|
|
tool = '$tool' AND |
|
|
|
|
ref = $ref |
|
|
|
|
$sessionCondition"; |
|
|
|
|
$rs = Database::query($sql); |
|
|
|
|
$item_property_id = ''; |
|
|
|
|
if (Database::num_rows($rs) > 0) { |
|
|
|
|
$row = Database::fetch_array($rs); |
|
|
|
|
$item_property_id = $row['id']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $item_property_id; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Inserts a record in the track_e_item_property table (No update). |
|
|
|
|
* |
|
|
|
|
* @param string $tool |
|
|
|
|
* @param int $ref |
|
|
|
|
* @param string $title |
|
|
|
|
* @param string $content |
|
|
|
|
* @param int $progress |
|
|
|
|
* |
|
|
|
|
* @return bool|int |
|
|
|
|
*/ |
|
|
|
|
function api_track_item_property_update($tool, $ref, $title, $content, $progress) |
|
|
|
|
{ |
|
|
|
|
$tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY); |
|
|
|
|
$course_id = api_get_course_int_id(); //numeric |
|
|
|
|
$course_code = api_get_course_id(); //alphanumeric |
|
|
|
|
$item_property_id = api_get_item_property_id($course_code, $tool, $ref); |
|
|
|
|
if (!empty($item_property_id)) { |
|
|
|
|
$sql = "INSERT IGNORE INTO $tbl_stats_item_property SET |
|
|
|
|
course_id = '$course_id', |
|
|
|
|
item_property_id = '$item_property_id', |
|
|
|
|
title = '".Database::escape_string($title)."', |
|
|
|
|
content = '".Database::escape_string($content)."', |
|
|
|
|
progress = '".intval($progress)."', |
|
|
|
|
lastedit_date = '".api_get_utc_datetime()."', |
|
|
|
|
lastedit_user_id = '".api_get_user_id()."', |
|
|
|
|
session_id = '".api_get_session_id()."'"; |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
$affected_rows = Database::affected_rows($result); |
|
|
|
|
|
|
|
|
|
return $affected_rows; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param string $tool |
|
|
|
|
* @param int $ref |
|
|
|
|
* |
|
|
|
|
* @return array|resource |
|
|
|
|
*/ |
|
|
|
|
function api_get_track_item_property_history($tool, $ref) |
|
|
|
|
{ |
|
|
|
|
$tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY); |
|
|
|
|
$course_id = api_get_course_int_id(); //numeric |
|
|
|
|
$course_code = api_get_course_id(); //alphanumeric |
|
|
|
|
$item_property_id = api_get_item_property_id($course_code, $tool, $ref); |
|
|
|
|
$sql = "SELECT * FROM $tbl_stats_item_property |
|
|
|
|
WHERE item_property_id = $item_property_id AND course_id = $course_id |
|
|
|
|
ORDER BY lastedit_date DESC"; |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
if (false === $result or null === $result) { |
|
|
|
|
$result = []; |
|
|
|
|
} else { |
|
|
|
|
$result = Database::store_result($result, 'ASSOC'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets item property data from tool of a course id. |
|
|
|
|
* |
|
|
|
|
* @deprecated |
|
|
|
|
* |
|
|
|
|
* @param int $course_id |
|
|
|
|
* @param string $tool tool name, linked to 'rubrique' of the course tool_list (Warning: language sensitive !!) |
|
|
|
|
* @param int $ref id of the item itself, linked to key of every tool ('id', ...), "*" = all items of the tool |
|
|
|
|
* @param int $session_id |
|
|
|
|
* @param int $groupId |
|
|
|
|
* |
|
|
|
|
* @return array with all fields from c_item_property, empty array if not found or false if course could not be found |
|
|
|
|
*/ |
|
|
|
|
function api_get_item_property_info($course_id, $tool, $ref, $session_id = 0, $groupId = 0) |
|
|
|
|
{ |
|
|
|
|
$courseInfo = api_get_course_info_by_id($course_id); |
|
|
|
|
|
|
|
|
|
if (empty($courseInfo)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$tool = Database::escape_string($tool); |
|
|
|
|
$course_id = $courseInfo['real_id']; |
|
|
|
|
$ref = (int) $ref; |
|
|
|
|
$session_id = (int) $session_id; |
|
|
|
|
|
|
|
|
|
$sessionCondition = " session_id = $session_id"; |
|
|
|
|
if (empty($session_id)) { |
|
|
|
|
$sessionCondition = ' (session_id = 0 OR session_id IS NULL) '; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Definition of tables. |
|
|
|
|
$table = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM $table |
|
|
|
|
WHERE |
|
|
|
|
c_id = $course_id AND |
|
|
|
|
tool = '$tool' AND |
|
|
|
|
ref = $ref AND |
|
|
|
|
$sessionCondition "; |
|
|
|
|
|
|
|
|
|
if (!empty($groupId)) { |
|
|
|
|
$groupId = (int) $groupId; |
|
|
|
|
$sql .= " AND to_group_id = $groupId "; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$rs = Database::query($sql); |
|
|
|
|
$row = []; |
|
|
|
|
if (Database::num_rows($rs) > 0) { |
|
|
|
|
$row = Database::fetch_array($rs, 'ASSOC'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $row; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Displays a combo box so the user can select his/her preferred language. |
|
|
|
|
* |
|
|
|
@ -4896,21 +4561,7 @@ function copy_folder_course_session( |
|
|
|
|
'size' => '0', |
|
|
|
|
'session_id' => $session_id, |
|
|
|
|
]; |
|
|
|
|
$document_id = Database::insert($table, $params); |
|
|
|
|
if ($document_id) { |
|
|
|
|
/*api_item_property_update( |
|
|
|
|
$course_info, |
|
|
|
|
TOOL_DOCUMENT, |
|
|
|
|
$document_id, |
|
|
|
|
'FolderCreated', |
|
|
|
|
api_get_user_id(), |
|
|
|
|
0, |
|
|
|
|
0, |
|
|
|
|
null, |
|
|
|
|
null, |
|
|
|
|
$session_id |
|
|
|
|
);*/ |
|
|
|
|
} |
|
|
|
|
Database::insert($table, $params); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} // en foreach |
|
|
|
@ -7161,19 +6812,6 @@ function api_set_default_visibility( |
|
|
|
|
$visibility = DocumentManager::getDocumentDefaultVisibility($courseInfo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*api_item_property_update( |
|
|
|
|
$courseInfo, |
|
|
|
|
$original_tool_id, |
|
|
|
|
$item_id, |
|
|
|
|
$visibility, |
|
|
|
|
$userId, |
|
|
|
|
$groupInfo, |
|
|
|
|
null, |
|
|
|
|
null, |
|
|
|
|
null, |
|
|
|
|
$sessionId |
|
|
|
|
);*/ |
|
|
|
|
|
|
|
|
|
// Fixes default visibility for tests |
|
|
|
|
switch ($original_tool_id) { |
|
|
|
|
case TOOL_QUIZ: |
|
|
|
|