Code Duplication    Length = 15-21 lines in 2 locations

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

@@ 3584-3598 (lines=15) @@
3581
     *
3582
     * @return int 0 if fails otherwise the tag id
3583
     */
3584
    public static function get_tag_id_from_id($tag_id, $field_id)
3585
    {
3586
        $table_user_tag = Database::get_main_table(TABLE_MAIN_TAG);
3587
        $tag_id = intval($tag_id);
3588
        $field_id = intval($field_id);
3589
        $sql = "SELECT id FROM $table_user_tag
3590
                WHERE id = '$tag_id' AND field_id = $field_id";
3591
        $result = Database::query($sql);
3592
        if (Database::num_rows($result) > 0) {
3593
            $row = Database::fetch_array($result, 'ASSOC');
3594
            return $row['id'];
3595
        } else {
3596
            return false;
3597
        }
3598
    }
3599
3600
    /**
3601
     * Adds a user-tag value

main/work/work.lib.php 1 location

@@ 2942-2962 (lines=21) @@
2939
 * @param array $courseInfo
2940
 * @return int
2941
 */
2942
function getWorkCommentCount($id, $courseInfo = array())
2943
{
2944
    if (empty($courseInfo)) {
2945
        $courseInfo = api_get_course_info();
2946
    }
2947
2948
    $commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT);
2949
    $id = intval($id);
2950
2951
    $sql = "SELECT count(*) as count
2952
            FROM $commentTable
2953
            WHERE work_id = $id AND c_id = ".$courseInfo['real_id'];
2954
2955
    $result = Database::query($sql);
2956
    if (Database::num_rows($result)) {
2957
        $comment = Database::fetch_array($result);
2958
        return $comment['count'];
2959
    }
2960
2961
    return 0;
2962
}
2963
2964
/**
2965
 * Get comment count for a specific parent