| @@ 1349-1371 (lines=23) @@ | ||
| 1346 | * @param string $course_id Course code |
|
| 1347 | * @param int $document_id Document id to delete |
|
| 1348 | */ |
|
| 1349 | public static function delete_document_from_search_engine($course_id, $document_id) |
|
| 1350 | { |
|
| 1351 | // remove from search engine if enabled |
|
| 1352 | if (api_get_setting('search_enabled') === 'true') { |
|
| 1353 | $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF); |
|
| 1354 | $sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1'; |
|
| 1355 | $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_DOCUMENT, $document_id); |
|
| 1356 | $res = Database::query($sql); |
|
| 1357 | if (Database::num_rows($res) > 0) { |
|
| 1358 | $row2 = Database::fetch_array($res); |
|
| 1359 | require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'; |
|
| 1360 | $di = new ChamiloIndexer(); |
|
| 1361 | $di->remove_document((int) $row2['search_did']); |
|
| 1362 | } |
|
| 1363 | $sql = 'DELETE FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1'; |
|
| 1364 | $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_DOCUMENT, $document_id); |
|
| 1365 | Database::query($sql); |
|
| 1366 | ||
| 1367 | // remove terms from db |
|
| 1368 | require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
| 1369 | delete_all_values_for_item($course_id, TOOL_DOCUMENT, $document_id); |
|
| 1370 | } |
|
| 1371 | } |
|
| 1372 | ||
| 1373 | /** |
|
| 1374 | * Gets the id of a document with a given path |
|
| @@ 443-467 (lines=25) @@ | ||
| 440 | * @param int $link_id Document id to delete |
|
| 441 | * @return void |
|
| 442 | */ |
|
| 443 | public static function delete_link_from_search_engine($course_id, $link_id) |
|
| 444 | { |
|
| 445 | // Remove from search engine if enabled. |
|
| 446 | if (api_get_setting('search_enabled') === 'true') { |
|
| 447 | $tbl_se_ref = Database:: get_main_table( |
|
| 448 | TABLE_MAIN_SEARCH_ENGINE_REF |
|
| 449 | ); |
|
| 450 | $sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1'; |
|
| 451 | $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_LINK, $link_id); |
|
| 452 | $res = Database:: query($sql); |
|
| 453 | if (Database:: num_rows($res) > 0) { |
|
| 454 | $row = Database:: fetch_array($res); |
|
| 455 | require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'; |
|
| 456 | $di = new ChamiloIndexer(); |
|
| 457 | $di->remove_document((int)$row['search_did']); |
|
| 458 | } |
|
| 459 | $sql = 'DELETE FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1'; |
|
| 460 | $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_LINK, $link_id); |
|
| 461 | Database:: query($sql); |
|
| 462 | ||
| 463 | // Remove terms from db. |
|
| 464 | require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
| 465 | delete_all_values_for_item($course_id, TOOL_DOCUMENT, $link_id); |
|
| 466 | } |
|
| 467 | } |
|
| 468 | ||
| 469 | /** |
|
| 470 | * |
|