| @@ 236-255 (lines=20) @@ | ||
| 233 | * |
|
| 234 | * @return array |
|
| 235 | */ |
|
| 236 | function get_work_assignment_by_id($id, $courseId = null) |
|
| 237 | { |
|
| 238 | if (empty($courseId)) { |
|
| 239 | $courseId = api_get_course_int_id(); |
|
| 240 | } else { |
|
| 241 | $courseId = intval($courseId); |
|
| 242 | } |
|
| 243 | $id = intval($id); |
|
| 244 | ||
| 245 | $table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
|
| 246 | $sql = "SELECT * FROM $table |
|
| 247 | WHERE c_id = $courseId AND publication_id = $id"; |
|
| 248 | $result = Database::query($sql); |
|
| 249 | $return = array(); |
|
| 250 | if (Database::num_rows($result)) { |
|
| 251 | $return = Database::fetch_array($result, 'ASSOC'); |
|
| 252 | } |
|
| 253 | ||
| 254 | return $return; |
|
| 255 | } |
|
| 256 | ||
| 257 | /** |
|
| 258 | * @param int $id |
|
| @@ 117-136 (lines=20) @@ | ||
| 114 | * |
|
| 115 | * @return array |
|
| 116 | */ |
|
| 117 | function get_work_data_by_path($path, $courseId = null) |
|
| 118 | { |
|
| 119 | $path = Database::escape_string($path); |
|
| 120 | if (empty($courseId)) { |
|
| 121 | $courseId = api_get_course_int_id(); |
|
| 122 | } else { |
|
| 123 | $courseId = intval($courseId); |
|
| 124 | } |
|
| 125 | ||
| 126 | $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); |
|
| 127 | $sql = "SELECT * FROM ".$work_table." |
|
| 128 | WHERE url = '$path' AND c_id = $courseId "; |
|
| 129 | $result = Database::query($sql); |
|
| 130 | $return = array(); |
|
| 131 | if (Database::num_rows($result)) { |
|
| 132 | $return = Database::fetch_array($result, 'ASSOC'); |
|
| 133 | } |
|
| 134 | ||
| 135 | return $return; |
|
| 136 | } |
|
| 137 | ||
| 138 | /** |
|
| 139 | * @param int $id |
|
| @@ 2553-2568 (lines=16) @@ | ||
| 2550 | * @param int $user_id If none provided, will use current user |
|
| 2551 | * @return int User's status (1 for teacher, 5 for student, etc) |
|
| 2552 | */ |
|
| 2553 | function api_get_user_status($user_id = null) |
|
| 2554 | { |
|
| 2555 | $user_id = intval($user_id); |
|
| 2556 | if (empty($user_id)) { |
|
| 2557 | $user_id = api_get_user_id(); |
|
| 2558 | } |
|
| 2559 | $table = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2560 | $sql = "SELECT status FROM $table WHERE user_id = $user_id "; |
|
| 2561 | $result = Database::query($sql); |
|
| 2562 | $status = null; |
|
| 2563 | if (Database::num_rows($result)) { |
|
| 2564 | $row = Database::fetch_array($result); |
|
| 2565 | $status = $row['status']; |
|
| 2566 | } |
|
| 2567 | return $status; |
|
| 2568 | } |
|
| 2569 | ||
| 2570 | /** |
|
| 2571 | * Checks whether current user is allowed to create courses |
|