| @@ 151-176 (lines=26) @@ | ||
| 148 | * @param int $ref_id representative id inside one tool item |
|
| 149 | * @return array |
|
| 150 | */ |
|
| 151 | function get_specific_field_values_list_by_prefix( |
|
| 152 | $prefix, |
|
| 153 | $course_code, |
|
| 154 | $tool_id, |
|
| 155 | $ref_id |
|
| 156 | ) { |
|
| 157 | $table_sf = Database:: get_main_table(TABLE_MAIN_SPECIFIC_FIELD); |
|
| 158 | $table_sfv = Database:: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES); |
|
| 159 | $sql = 'SELECT sfv.value FROM %s sf LEFT JOIN %s sfv ON sf.id = sfv.field_id'. |
|
| 160 | ' WHERE sf.code = \'%s\' AND sfv.c_id = \'%s\' AND tool_id = \'%s\' AND sfv.ref_id = %s'; |
|
| 161 | $sql = sprintf( |
|
| 162 | $sql, |
|
| 163 | $table_sf, |
|
| 164 | $table_sfv, |
|
| 165 | $prefix, |
|
| 166 | $course_code, |
|
| 167 | $tool_id, |
|
| 168 | $ref_id |
|
| 169 | ); |
|
| 170 | $sql_result = Database::query($sql); |
|
| 171 | while ($result = Database::fetch_array($sql_result)) { |
|
| 172 | $return_array[] = $result; |
|
| 173 | } |
|
| 174 | ||
| 175 | return $return_array; |
|
| 176 | } |
|
| 177 | ||
| 178 | /** |
|
| 179 | * Add a specific field value |
|
| @@ 3327-3349 (lines=23) @@ | ||
| 3324 | * @param int Session id |
|
| 3325 | * @return array Courses list |
|
| 3326 | */ |
|
| 3327 | public static function get_courses_list_from_session($session_id) |
|
| 3328 | { |
|
| 3329 | $session_id = intval($session_id); |
|
| 3330 | ||
| 3331 | // table definition |
|
| 3332 | $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE); |
|
| 3333 | $courseTable = Database :: get_main_table(TABLE_MAIN_COURSE); |
|
| 3334 | ||
| 3335 | $sql = "SELECT DISTINCT code, c_id |
|
| 3336 | FROM $tbl_session_course sc |
|
| 3337 | INNER JOIN $courseTable c |
|
| 3338 | ON sc.c_id = c.id |
|
| 3339 | WHERE session_id= $session_id"; |
|
| 3340 | ||
| 3341 | $result = Database::query($sql); |
|
| 3342 | ||
| 3343 | $courses = array(); |
|
| 3344 | while ($row = Database::fetch_array($result)) { |
|
| 3345 | $courses[$row['code']] = $row; |
|
| 3346 | } |
|
| 3347 | ||
| 3348 | return $courses; |
|
| 3349 | } |
|
| 3350 | ||
| 3351 | /** |
|
| 3352 | * Count the number of documents that an user has uploaded to a course |
|
| @@ 5466-5489 (lines=24) @@ | ||
| 5463 | * @param string $lastname Lastname to search |
|
| 5464 | * @return array The user list |
|
| 5465 | */ |
|
| 5466 | public static function getUserByName($firstname, $lastname) |
|
| 5467 | { |
|
| 5468 | $firstname = Database::escape_string($firstname); |
|
| 5469 | $lastname = Database::escape_string($lastname); |
|
| 5470 | ||
| 5471 | $userTable = Database::get_main_table(TABLE_MAIN_USER); |
|
| 5472 | ||
| 5473 | $sql = <<<SQL |
|
| 5474 | SELECT id, username, lastname, firstname |
|
| 5475 | FROM $userTable |
|
| 5476 | WHERE |
|
| 5477 | firstname LIKE '$firstname%' AND |
|
| 5478 | lastname LIKE '$lastname%' |
|
| 5479 | SQL; |
|
| 5480 | ||
| 5481 | $result = Database::query($sql); |
|
| 5482 | ||
| 5483 | $users = []; |
|
| 5484 | while ($resultData = Database::fetch_object($result)) { |
|
| 5485 | $users[] = $resultData; |
|
| 5486 | } |
|
| 5487 | ||
| 5488 | return $users; |
|
| 5489 | } |
|
| 5490 | ||
| 5491 | /** |
|
| 5492 | * @param int $optionSelected |
|