@@ 391-400 (lines=10) @@ | ||
388 | * @param int url id |
|
389 | * @return boolean true if success |
|
390 | * */ |
|
391 | public static function relation_url_user_exist($user_id, $url_id) |
|
392 | { |
|
393 | $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
394 | $sql= "SELECT user_id FROM $table |
|
395 | WHERE access_url_id = ".intval($url_id)." AND user_id = ".intval($user_id)." "; |
|
396 | $result = Database::query($sql); |
|
397 | $num = Database::num_rows($result); |
|
398 | ||
399 | return $num; |
|
400 | } |
|
401 | ||
402 | /** |
|
403 | * Checks the relationship between an URL and a Course (return the num_rows) |
|
@@ 409-420 (lines=12) @@ | ||
406 | * @param int $urlId |
|
407 | * @return boolean true if success |
|
408 | * */ |
|
409 | public static function relation_url_course_exist($courseId, $urlId) |
|
410 | { |
|
411 | $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
412 | $sql= "SELECT c_id FROM $table_url_rel_course |
|
413 | WHERE |
|
414 | access_url_id = ".intval($urlId)." AND |
|
415 | c_id = '".intval($courseId)."'"; |
|
416 | $result = Database::query($sql); |
|
417 | $num = Database::num_rows($result); |
|
418 | ||
419 | return $num; |
|
420 | } |
|
421 | ||
422 | /** |
|
423 | * Checks the relationship between an URL and a UserGr |
@@ 253-264 (lines=12) @@ | ||
250 | * @param int user receiver id |
|
251 | * @return int |
|
252 | */ |
|
253 | public static function get_message_number_invitation_by_user_id($user_receiver_id) |
|
254 | { |
|
255 | $tbl_message = Database::get_main_table(TABLE_MESSAGE); |
|
256 | $sql = 'SELECT COUNT(*) as count_message_in_box FROM '.$tbl_message.' |
|
257 | WHERE |
|
258 | user_receiver_id='.intval($user_receiver_id).' AND |
|
259 | msg_status='.MESSAGE_STATUS_INVITATION_PENDING; |
|
260 | $res = Database::query($sql); |
|
261 | $row = Database::fetch_array($res, 'ASSOC'); |
|
262 | ||
263 | return $row['count_message_in_box']; |
|
264 | } |
|
265 | ||
266 | /** |
|
267 | * Get invitation list received by user |
@@ 610-620 (lines=11) @@ | ||
607 | * @param int $user_id The user id |
|
608 | * @return Datetime The date when you obtained the certificate |
|
609 | */ |
|
610 | public static function get_certificate_by_user_id($cat_id, $user_id) |
|
611 | { |
|
612 | $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
|
613 | $sql = 'SELECT * FROM ' . $table_certificate . ' |
|
614 | WHERE cat_id="' . intval($cat_id) . '" AND user_id="' . intval($user_id) . '"'; |
|
615 | ||
616 | $result = Database::query($sql); |
|
617 | $row = Database::fetch_array($result, 'ASSOC'); |
|
618 | ||
619 | return $row; |
|
620 | } |
|
621 | ||
622 | /** |
|
623 | * Get list of users certificates |
@@ 5485-5495 (lines=11) @@ | ||
5482 | * Returns the course name from a given code |
|
5483 | * @param string $code |
|
5484 | */ |
|
5485 | public static function getCourseNameFromCode($code) |
|
5486 | { |
|
5487 | $tbl_main_categories = Database:: get_main_table(TABLE_MAIN_COURSE); |
|
5488 | $sql = 'SELECT title |
|
5489 | FROM ' . $tbl_main_categories . ' |
|
5490 | WHERE code = "' . Database::escape_string($code) . '"'; |
|
5491 | $result = Database::query($sql); |
|
5492 | if ($col = Database::fetch_array($result)) { |
|
5493 | return $col['title']; |
|
5494 | } |
|
5495 | } |
|
5496 | ||
5497 | /** |
|
5498 | * Generates a course code from a course title |