| @@ 3673-3687 (lines=15) @@ | ||
| 3670 | * |
|
| 3671 | * @return int 0 if fails otherwise the tag id |
|
| 3672 | */ |
|
| 3673 | public static function get_tag_id_from_id($tag_id, $field_id) |
|
| 3674 | { |
|
| 3675 | $table_user_tag = Database::get_main_table(TABLE_MAIN_TAG); |
|
| 3676 | $tag_id = intval($tag_id); |
|
| 3677 | $field_id = intval($field_id); |
|
| 3678 | $sql = "SELECT id FROM $table_user_tag |
|
| 3679 | WHERE id = '$tag_id' AND field_id = $field_id"; |
|
| 3680 | $result = Database::query($sql); |
|
| 3681 | if (Database::num_rows($result) > 0) { |
|
| 3682 | $row = Database::fetch_array($result, 'ASSOC'); |
|
| 3683 | return $row['id']; |
|
| 3684 | } else { |
|
| 3685 | return false; |
|
| 3686 | } |
|
| 3687 | } |
|
| 3688 | ||
| 3689 | /** |
|
| 3690 | * Adds a user-tag value |
|
| @@ 3069-3089 (lines=21) @@ | ||
| 3066 | * @param array $courseInfo |
|
| 3067 | * @return int |
|
| 3068 | */ |
|
| 3069 | function getWorkCommentCount($id, $courseInfo = array()) |
|
| 3070 | { |
|
| 3071 | if (empty($courseInfo)) { |
|
| 3072 | $courseInfo = api_get_course_info(); |
|
| 3073 | } |
|
| 3074 | ||
| 3075 | $commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT); |
|
| 3076 | $id = intval($id); |
|
| 3077 | ||
| 3078 | $sql = "SELECT count(*) as count |
|
| 3079 | FROM $commentTable |
|
| 3080 | WHERE work_id = $id AND c_id = ".$courseInfo['real_id']; |
|
| 3081 | ||
| 3082 | $result = Database::query($sql); |
|
| 3083 | if (Database::num_rows($result)) { |
|
| 3084 | $comment = Database::fetch_array($result); |
|
| 3085 | return $comment['count']; |
|
| 3086 | } |
|
| 3087 | ||
| 3088 | return 0; |
|
| 3089 | } |
|
| 3090 | ||
| 3091 | /** |
|
| 3092 | * Get comment count for a specific parent |
|