| @@ 448-474 (lines=27) @@ | ||
| 445 | * @param int $link_id Document id to delete |
|
| 446 | * @return void |
|
| 447 | */ |
|
| 448 | public static function delete_link_from_search_engine($course_id, $link_id) |
|
| 449 | { |
|
| 450 | // Remove from search engine if enabled. |
|
| 451 | if (api_get_setting('search_enabled') == 'true') { |
|
| 452 | $tbl_se_ref = Database:: get_main_table( |
|
| 453 | TABLE_MAIN_SEARCH_ENGINE_REF |
|
| 454 | ); |
|
| 455 | $sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1'; |
|
| 456 | $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_LINK, $link_id); |
|
| 457 | $res = Database:: query($sql); |
|
| 458 | if (Database:: num_rows($res) > 0) { |
|
| 459 | $row = Database:: fetch_array($res); |
|
| 460 | require_once api_get_path( |
|
| 461 | LIBRARY_PATH |
|
| 462 | ) . 'search/ChamiloIndexer.class.php'; |
|
| 463 | $di = new ChamiloIndexer(); |
|
| 464 | $di->remove_document((int)$row['search_did']); |
|
| 465 | } |
|
| 466 | $sql = 'DELETE FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1'; |
|
| 467 | $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_LINK, $link_id); |
|
| 468 | Database:: query($sql); |
|
| 469 | ||
| 470 | // Remove terms from db. |
|
| 471 | require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
| 472 | delete_all_values_for_item($course_id, TOOL_DOCUMENT, $link_id); |
|
| 473 | } |
|
| 474 | } |
|
| 475 | ||
| 476 | /** |
|
| 477 | * |
|
| @@ 1318-1340 (lines=23) @@ | ||
| 1315 | * @param string $course_id Course code |
|
| 1316 | * @param int $document_id Document id to delete |
|
| 1317 | */ |
|
| 1318 | public static function delete_document_from_search_engine($course_id, $document_id) |
|
| 1319 | { |
|
| 1320 | // remove from search engine if enabled |
|
| 1321 | if (api_get_setting('search_enabled') == 'true') { |
|
| 1322 | $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF); |
|
| 1323 | $sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1'; |
|
| 1324 | $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_DOCUMENT, $document_id); |
|
| 1325 | $res = Database::query($sql); |
|
| 1326 | if (Database::num_rows($res) > 0) { |
|
| 1327 | $row2 = Database::fetch_array($res); |
|
| 1328 | require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'; |
|
| 1329 | $di = new ChamiloIndexer(); |
|
| 1330 | $di->remove_document((int) $row2['search_did']); |
|
| 1331 | } |
|
| 1332 | $sql = 'DELETE FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1'; |
|
| 1333 | $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_DOCUMENT, $document_id); |
|
| 1334 | Database::query($sql); |
|
| 1335 | ||
| 1336 | // remove terms from db |
|
| 1337 | require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
| 1338 | delete_all_values_for_item($course_id, TOOL_DOCUMENT, $document_id); |
|
| 1339 | } |
|
| 1340 | } |
|
| 1341 | ||
| 1342 | /** |
|
| 1343 | * Gets the id of a document with a given path |
|