Code Duplication    Length = 15-21 lines in 2 locations

main/work/work.lib.php 1 location

@@ 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

main/inc/lib/usermanager.lib.php 1 location

@@ 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