Exemplo n.º 1
0
 /**
  * update the information of a glossary term in the database
  *
  * @param array $values an array containing all the form elements
  * @return boolean True on success, false on failure
  * @author Christian Fasanando <*****@*****.**>
  * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium
  * @version januari 2009, dokeos 1.8.6
  */
 public static function update_glossary($values, $message = true)
 {
     // Database table definition
     $t_glossary = Database::get_course_table(TABLE_GLOSSARY);
     $course_id = api_get_course_int_id();
     // check if the glossary term already exists
     if (GlossaryManager::glossary_exists($values['glossary_title'], $values['glossary_id'])) {
         // display the feedback message
         if ($message) {
             Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
         }
         return false;
     } else {
         $sql = "UPDATE {$t_glossary} SET\n                        name \t\t= '" . Database::escape_string($values['glossary_title']) . "',\n                        description\t= '" . Database::escape_string($values['glossary_comment']) . "'\n\t\t\t\t\tWHERE\n\t\t\t\t\t    c_id = {$course_id} AND\n\t\t\t\t\t    glossary_id = " . intval($values['glossary_id']);
         $result = Database::query($sql);
         if ($result === false) {
             return false;
         }
         //update glossary into item_property
         api_item_property_update(api_get_course_info(), TOOL_GLOSSARY, intval($values['glossary_id']), 'GlossaryUpdated', api_get_user_id());
         // display the feedback message
         if ($message) {
             Display::display_confirmation_message(get_lang('TermUpdated'));
         }
     }
     return true;
 }