예제 #1
0
 /**
  * Delete a glossary term (and re-order all the others)
  *
  * @param integer The id of the glossary term to delete
  * @return bool    True on success, false on failure
  * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium
  * @version januari 2009, dokeos 1.8.6
  */
 public static function delete_glossary($glossary_id, $message = true)
 {
     // Database table definition
     $t_glossary = Database::get_course_table(TABLE_GLOSSARY);
     $course_id = api_get_course_int_id();
     if (empty($glossary_id)) {
         return false;
     }
     $sql = "DELETE FROM {$t_glossary} WHERE c_id = {$course_id} AND glossary_id='" . intval($glossary_id) . "'";
     $result = Database::query($sql);
     if ($result === false or Database::affected_rows($result) < 1) {
         return false;
     }
     //update item_property (delete)
     api_item_property_update(api_get_course_info(), TOOL_GLOSSARY, intval($glossary_id), 'delete', api_get_user_id());
     // reorder the remaining terms
     GlossaryManager::reorder_glossary();
     Session::write('max_glossary_display', GlossaryManager::get_max_glossary_item());
     Display::display_confirmation_message(get_lang('TermDeleted'));
     return true;
 }