| @@ 795-811 (lines=17) @@ | ||
| 792 | * @param string $event_type |
|
| 793 | * @return array|bool |
|
| 794 | */ |
|
| 795 | public static function get_events_by_user_and_type($user_id, $event_type) |
|
| 796 | { |
|
| 797 | $TABLETRACK_DEFAULT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT); |
|
| 798 | $user_id = intval($user_id); |
|
| 799 | $event_type = Database::escape_string($event_type); |
|
| 800 | ||
| 801 | $sql = "SELECT * FROM $TABLETRACK_DEFAULT |
|
| 802 | WHERE default_value_type = 'user_id' AND |
|
| 803 | default_value = $user_id AND |
|
| 804 | default_event_type = '$event_type' |
|
| 805 | ORDER BY default_date "; |
|
| 806 | $result = Database::query($sql); |
|
| 807 | if ($result) { |
|
| 808 | return Database::store_result($result, 'ASSOC'); |
|
| 809 | } |
|
| 810 | return false; |
|
| 811 | } |
|
| 812 | ||
| 813 | /** |
|
| 814 | * Save the new message for one event and for one language |
|
| @@ 428-442 (lines=15) @@ | ||
| 425 | * @param int Link/Resource ID |
|
| 426 | * @return bool false on error, true on success |
|
| 427 | */ |
|
| 428 | public static function get_resource_from_course_gradebook($link_id) |
|
| 429 | { |
|
| 430 | if (empty($link_id)) { |
|
| 431 | return false; |
|
| 432 | } |
|
| 433 | // TODO find the corresponding category (the first one for this course, ordered by ID) |
|
| 434 | $l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
| 435 | $sql = "SELECT * FROM $l WHERE id = " . (int) $link_id; |
|
| 436 | $res = Database::query($sql); |
|
| 437 | $row = array(); |
|
| 438 | if (Database::num_rows($res) > 0) { |
|
| 439 | $row = Database::fetch_array($res, 'ASSOC'); |
|
| 440 | } |
|
| 441 | return $row; |
|
| 442 | } |
|
| 443 | ||
| 444 | /** |
|
| 445 | * Return the course id |
|
| @@ 4270-4282 (lines=13) @@ | ||
| 4267 | * @param string language name (the corresponding name of the language-folder in the filesystem) |
|
| 4268 | * @return int id of the language |
|
| 4269 | */ |
|
| 4270 | function api_get_language_id($language) |
|
| 4271 | { |
|
| 4272 | $tbl_language = Database::get_main_table(TABLE_MAIN_LANGUAGE); |
|
| 4273 | if (empty($language)) { |
|
| 4274 | return null; |
|
| 4275 | } |
|
| 4276 | $language = Database::escape_string($language); |
|
| 4277 | $sql = "SELECT id FROM $tbl_language |
|
| 4278 | WHERE dokeos_folder = '$language' LIMIT 1"; |
|
| 4279 | $result = Database::query($sql); |
|
| 4280 | $row = Database::fetch_array($result); |
|
| 4281 | return $row['id']; |
|
| 4282 | } |
|
| 4283 | ||
| 4284 | /** |
|
| 4285 | * Gets language of the requested type for the current user. Types are : |
|
| @@ 1211-1232 (lines=22) @@ | ||
| 1208 | * @return int User id |
|
| 1209 | * @assert ('0','---') === 0 |
|
| 1210 | */ |
|
| 1211 | public static function get_user_id_from_original_id($original_user_id_value, $original_user_id_name) |
|
| 1212 | { |
|
| 1213 | $t_uf = Database::get_main_table(TABLE_EXTRA_FIELD); |
|
| 1214 | $t_ufv = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
| 1215 | $extraFieldType = EntityExtraField::USER_FIELD_TYPE; |
|
| 1216 | $sql = "SELECT item_id as user_id |
|
| 1217 | FROM $t_uf uf |
|
| 1218 | INNER JOIN $t_ufv ufv |
|
| 1219 | ON ufv.field_id=uf.id |
|
| 1220 | WHERE |
|
| 1221 | variable='$original_user_id_name' AND |
|
| 1222 | value='$original_user_id_value' AND |
|
| 1223 | extra_field_type = $extraFieldType |
|
| 1224 | "; |
|
| 1225 | $res = Database::query($sql); |
|
| 1226 | $row = Database::fetch_object($res); |
|
| 1227 | if ($row) { |
|
| 1228 | return $row->user_id; |
|
| 1229 | } else { |
|
| 1230 | return 0; |
|
| 1231 | } |
|
| 1232 | } |
|
| 1233 | ||
| 1234 | /** |
|
| 1235 | * Check if a username is available |
|