$language, 'content' => $content, 'changes' => $changes, 'type' => $type, 'version' => intval($version), 'date' => $time ]; Database::insert($legal_table, $params); return true; } elseif($last['type'] != $type && $language==$last['language_id']) { //update $id = $last['legal_id']; $params = [ 'changes' => $changes, 'type' => $type, 'date' => $time ]; Database::update($legal_table, $params, ['legal_id => ?' => $id]); return true; } else { return false; } } public static function delete($id) { /* $legal_table = Database::get_main_table(TABLE_MAIN_LEGAL); $id = intval($id); $sql = "DELETE FROM $legal_table WHERE legal_id = '".$id."'"; */ } /** * Gets the last version of a Term and condition by language * @param int $language language id * @return array all the info of a Term and condition */ public static function get_last_condition_version($language) { $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); $language= Database::escape_string($language); $sql = "SELECT version FROM $legal_conditions_table WHERE language_id = '".$language."' ORDER BY legal_id DESC LIMIT 1 "; $result = Database::query($sql); $row = Database::fetch_array($result); if (Database::num_rows($result) > 0) { return $row['version']; } else { return 0; } } /** * Gets the data of a Term and condition by language * @param int $language language id * @return array all the info of a Term and condition */ public static function get_last_condition ($language) { $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); $language= Database::escape_string($language); $sql = "SELECT * FROM $legal_conditions_table WHERE language_id = '".$language."' ORDER BY version DESC LIMIT 1 "; $result = Database::query($sql); return Database::fetch_array($result); } /** * Gets the last version of a Term and condition by language * @param int $language language id * @return boolean | int the version or false if does not exist */ public static function get_last_version($language) { $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); $language = intval($language); $sql = "SELECT version FROM $legal_conditions_table WHERE language_id = '".$language."' ORDER BY version DESC LIMIT 1 "; $result = Database::query($sql); if (Database::num_rows($result)>0){ $version = Database::fetch_array($result); $version = explode(':',$version[0]); return $version[0]; } else { return false; } } /** * Show the last condition * @param array with type and content i.e array('type'=>'1', 'content'=>'hola'); * * @return string html preview */ public static function show_last_condition($term_preview) { $preview = ''; switch ($term_preview['type']) { case 0: if (!empty($term_preview['content'])) { $preview = '