| @@ 787-803 (lines=17) @@ | ||
| 784 | * @param string $event_type |
|
| 785 | * @return array|bool |
|
| 786 | */ |
|
| 787 | public static function get_events_by_user_and_type($user_id, $event_type) |
|
| 788 | { |
|
| 789 | $TABLETRACK_DEFAULT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT); |
|
| 790 | $user_id = intval($user_id); |
|
| 791 | $event_type = Database::escape_string($event_type); |
|
| 792 | ||
| 793 | $sql = "SELECT * FROM $TABLETRACK_DEFAULT |
|
| 794 | WHERE default_value_type = 'user_id' AND |
|
| 795 | default_value = $user_id AND |
|
| 796 | default_event_type = '$event_type' |
|
| 797 | ORDER BY default_date "; |
|
| 798 | $result = Database::query($sql); |
|
| 799 | if ($result) { |
|
| 800 | return Database::store_result($result, 'ASSOC'); |
|
| 801 | } |
|
| 802 | return false; |
|
| 803 | } |
|
| 804 | ||
| 805 | /** |
|
| 806 | * Save the new message for one event and for one language |
|
| @@ 408-422 (lines=15) @@ | ||
| 405 | * @param int Link/Resource ID |
|
| 406 | * @return bool false on error, true on success |
|
| 407 | */ |
|
| 408 | public static function get_resource_from_course_gradebook($link_id) |
|
| 409 | { |
|
| 410 | if (empty($link_id)) { |
|
| 411 | return false; |
|
| 412 | } |
|
| 413 | // TODO find the corresponding category (the first one for this course, ordered by ID) |
|
| 414 | $l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
| 415 | $sql = "SELECT * FROM $l WHERE id = " . (int) $link_id; |
|
| 416 | $res = Database::query($sql); |
|
| 417 | $row = array(); |
|
| 418 | if (Database::num_rows($res) > 0) { |
|
| 419 | $row = Database::fetch_array($res, 'ASSOC'); |
|
| 420 | } |
|
| 421 | return $row; |
|
| 422 | } |
|
| 423 | ||
| 424 | /** |
|
| 425 | * Return the course id |
|
| @@ 1137-1158 (lines=22) @@ | ||
| 1134 | * @return int User id |
|
| 1135 | * @assert ('0','---') === 0 |
|
| 1136 | */ |
|
| 1137 | public static function get_user_id_from_original_id($original_user_id_value, $original_user_id_name) |
|
| 1138 | { |
|
| 1139 | $t_uf = Database::get_main_table(TABLE_EXTRA_FIELD); |
|
| 1140 | $t_ufv = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
| 1141 | $extraFieldType = EntityExtraField::USER_FIELD_TYPE; |
|
| 1142 | $sql = "SELECT item_id as user_id |
|
| 1143 | FROM $t_uf uf |
|
| 1144 | INNER JOIN $t_ufv ufv |
|
| 1145 | ON ufv.field_id=uf.id |
|
| 1146 | WHERE |
|
| 1147 | variable='$original_user_id_name' AND |
|
| 1148 | value='$original_user_id_value' AND |
|
| 1149 | extra_field_type = $extraFieldType |
|
| 1150 | "; |
|
| 1151 | $res = Database::query($sql); |
|
| 1152 | $row = Database::fetch_object($res); |
|
| 1153 | if ($row) { |
|
| 1154 | return $row->user_id; |
|
| 1155 | } else { |
|
| 1156 | return 0; |
|
| 1157 | } |
|
| 1158 | } |
|
| 1159 | ||
| 1160 | /** |
|
| 1161 | * Check if a username is available |
|
| @@ 4175-4187 (lines=13) @@ | ||
| 4172 | * @param string language name (the corresponding name of the language-folder in the filesystem) |
|
| 4173 | * @return int id of the language |
|
| 4174 | */ |
|
| 4175 | function api_get_language_id($language) |
|
| 4176 | { |
|
| 4177 | $tbl_language = Database::get_main_table(TABLE_MAIN_LANGUAGE); |
|
| 4178 | if (empty($language)) { |
|
| 4179 | return null; |
|
| 4180 | } |
|
| 4181 | $language = Database::escape_string($language); |
|
| 4182 | $sql = "SELECT id FROM $tbl_language |
|
| 4183 | WHERE dokeos_folder = '$language' LIMIT 1"; |
|
| 4184 | $result = Database::query($sql); |
|
| 4185 | $row = Database::fetch_array($result); |
|
| 4186 | return $row['id']; |
|
| 4187 | } |
|
| 4188 | ||
| 4189 | /** |
|
| 4190 | * Gets language of the requested type for the current user. Types are : |
|