| @@ 42-56 (lines=15) @@ | ||
| 39 | * @param int $glossary_id |
|
| 40 | * @return string The glossary description |
|
| 41 | */ |
|
| 42 | public static function get_glossary_term_by_glossary_id ($glossary_id) |
|
| 43 | { |
|
| 44 | $glossary_table = Database::get_course_table(TABLE_GLOSSARY); |
|
| 45 | $course_id = api_get_course_int_id(); |
|
| 46 | $sql = "SELECT description FROM $glossary_table |
|
| 47 | WHERE c_id = $course_id AND glossary_id =".intval($glossary_id); |
|
| 48 | $rs=Database::query($sql); |
|
| 49 | if (Database::num_rows($rs) > 0) { |
|
| 50 | $row = Database::fetch_array($rs); |
|
| 51 | ||
| 52 | return $row['description']; |
|
| 53 | } else { |
|
| 54 | return ''; |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Get glossary term by glossary id |
|
| @@ 207-219 (lines=13) @@ | ||
| 204 | * @param int $relation_type |
|
| 205 | * @return int parent_group_id or false |
|
| 206 | * */ |
|
| 207 | public static function get_parent_group($group_id, $relation_type = 1) |
|
| 208 | { |
|
| 209 | $table = Database :: get_main_table(TABLE_MAIN_GROUP_REL_GROUP); |
|
| 210 | $group_id = intval($group_id); |
|
| 211 | $sql = "SELECT group_id FROM $table WHERE subgroup_id = $group_id"; |
|
| 212 | $res = Database::query($sql); |
|
| 213 | if (Database::num_rows($res) == 0) { |
|
| 214 | return 0; |
|
| 215 | } else { |
|
| 216 | $arr = Database::fetch_assoc($res); |
|
| 217 | return $arr['group_id']; |
|
| 218 | } |
|
| 219 | } |
|
| 220 | ||
| 221 | /** |
|
| 222 | * Get the subgroups ID from a group. |
|
| @@ 77-93 (lines=17) @@ | ||
| 74 | * @param int $language language id |
|
| 75 | * @return array all the info of a Term and condition |
|
| 76 | */ |
|
| 77 | public static function get_last_condition_version($language) |
|
| 78 | { |
|
| 79 | $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
| 80 | $language= Database::escape_string($language); |
|
| 81 | $sql = "SELECT version FROM $legal_conditions_table |
|
| 82 | WHERE language_id = '".$language."' |
|
| 83 | ORDER BY legal_id DESC LIMIT 1 "; |
|
| 84 | $result = Database::query($sql); |
|
| 85 | $row = Database::fetch_array($result); |
|
| 86 | if (Database::num_rows($result) > 0) { |
|
| 87 | ||
| 88 | return $row['version']; |
|
| 89 | } else { |
|
| 90 | ||
| 91 | return 0; |
|
| 92 | } |
|
| 93 | } |
|
| 94 | ||
| 95 | /** |
|
| 96 | * Gets the data of a Term and condition by language |
|
| @@ 180-191 (lines=12) @@ | ||
| 177 | * |
|
| 178 | * @param string Package id |
|
| 179 | */ |
|
| 180 | public static function findByPackageId($package_id) { |
|
| 181 | $table = Database::get_main_table(ChamiloPens::TABLE_NAME); |
|
| 182 | $sql_query = "SELECT * FROM $table WHERE package_id = '".$package_id."';"; |
|
| 183 | $results = Database::query($sql_query); |
|
| 184 | $number = Database::num_rows($results); |
|
| 185 | if($number == 1) { |
|
| 186 | $obj = Database::fetch_assoc($results); |
|
| 187 | return new ChamiloPens($obj); |
|
| 188 | } else { |
|
| 189 | return null; |
|
| 190 | } |
|
| 191 | } |
|
| 192 | ||
| 193 | /** |
|
| 194 | * Returns an array of all the objects of the DB |
|
| @@ 410-422 (lines=13) @@ | ||
| 407 | * Get platform language ID |
|
| 408 | * @return int The platform language ID |
|
| 409 | */ |
|
| 410 | public static function get_platform_language_id() |
|
| 411 | { |
|
| 412 | $name = api_get_setting('platformLanguage'); |
|
| 413 | $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
|
| 414 | $sql = "SELECT id FROM " . $tbl_admin_languages . " WHERE english_name ='$name'"; |
|
| 415 | $res = Database::query($sql); |
|
| 416 | if (Database::num_rows($res) < 1) { |
|
| 417 | return false; |
|
| 418 | } |
|
| 419 | $row = Database::fetch_array($res); |
|
| 420 | ||
| 421 | return $row['id']; |
|
| 422 | } |
|
| 423 | ||
| 424 | /** |
|
| 425 | * Get parent language path (or null if no parent) |
|
| @@ 452-470 (lines=19) @@ | ||
| 449 | * @param string $isocode The language isocode (en, es, fr, zh-TW, etc) |
|
| 450 | * @return mixed English name of the matching language, or false if no active language could be found |
|
| 451 | */ |
|
| 452 | public static function getLanguageFromIsocode($isocode) |
|
| 453 | { |
|
| 454 | $isocode = Database::escape_string($isocode); |
|
| 455 | $adminLanguagesTable = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
|
| 456 | // select language - if case several languages match, get the last (more recent) one |
|
| 457 | $sql = "SELECT english_name |
|
| 458 | FROM " . $adminLanguagesTable . " |
|
| 459 | WHERE |
|
| 460 | isocode ='$isocode' AND |
|
| 461 | available = 1 |
|
| 462 | ORDER BY id |
|
| 463 | DESC LIMIT 1"; |
|
| 464 | $res = Database::query($sql); |
|
| 465 | if (Database::num_rows($res) < 1) { |
|
| 466 | return false; |
|
| 467 | } |
|
| 468 | $row = Database::fetch_assoc($res); |
|
| 469 | return $row['english_name']; |
|
| 470 | } |
|
| 471 | ||
| 472 | /** |
|
| 473 | * Get best language in browser preferences |
|