| @@ 3688-3702 (lines=15) @@ | ||
| 3685 | * |
|
| 3686 | * @return int 0 if fails otherwise the tag id |
|
| 3687 | */ |
|
| 3688 | public static function get_tag_id_from_id($tag_id, $field_id) |
|
| 3689 | { |
|
| 3690 | $table_user_tag = Database::get_main_table(TABLE_MAIN_TAG); |
|
| 3691 | $tag_id = intval($tag_id); |
|
| 3692 | $field_id = intval($field_id); |
|
| 3693 | $sql = "SELECT id FROM $table_user_tag |
|
| 3694 | WHERE id = '$tag_id' AND field_id = $field_id"; |
|
| 3695 | $result = Database::query($sql); |
|
| 3696 | if (Database::num_rows($result) > 0) { |
|
| 3697 | $row = Database::fetch_array($result, 'ASSOC'); |
|
| 3698 | return $row['id']; |
|
| 3699 | } else { |
|
| 3700 | return false; |
|
| 3701 | } |
|
| 3702 | } |
|
| 3703 | ||
| 3704 | /** |
|
| 3705 | * Adds a user-tag value |
|
| @@ 3117-3137 (lines=21) @@ | ||
| 3114 | * @param array $courseInfo |
|
| 3115 | * @return int |
|
| 3116 | */ |
|
| 3117 | function getWorkCommentCount($id, $courseInfo = array()) |
|
| 3118 | { |
|
| 3119 | if (empty($courseInfo)) { |
|
| 3120 | $courseInfo = api_get_course_info(); |
|
| 3121 | } |
|
| 3122 | ||
| 3123 | $commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT); |
|
| 3124 | $id = intval($id); |
|
| 3125 | ||
| 3126 | $sql = "SELECT count(*) as count |
|
| 3127 | FROM $commentTable |
|
| 3128 | WHERE work_id = $id AND c_id = ".$courseInfo['real_id']; |
|
| 3129 | ||
| 3130 | $result = Database::query($sql); |
|
| 3131 | if (Database::num_rows($result)) { |
|
| 3132 | $comment = Database::fetch_array($result); |
|
| 3133 | return $comment['count']; |
|
| 3134 | } |
|
| 3135 | ||
| 3136 | return 0; |
|
| 3137 | } |
|
| 3138 | ||
| 3139 | /** |
|
| 3140 | * Get comment count for a specific parent |
|