Code Duplication    Length = 15-21 lines in 2 locations

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

@@ 3313-3327 (lines=15) @@
3310
     * @param int field_id
3311
     * @return int 0 if fails otherwise the tag id
3312
     */
3313
    public static function get_tag_id_from_id($tag_id, $field_id)
3314
    {
3315
        $table_user_tag = Database::get_main_table(TABLE_MAIN_TAG);
3316
        $tag_id = intval($tag_id);
3317
        $field_id = intval($field_id);
3318
        $sql = "SELECT id FROM $table_user_tag
3319
                WHERE id = '$tag_id' AND field_id = $field_id";
3320
        $result = Database::query($sql);
3321
        if (Database::num_rows($result) > 0) {
3322
            $row = Database::fetch_array($result, 'ASSOC');
3323
            return $row['id'];
3324
        } else {
3325
            return false;
3326
        }
3327
    }
3328
3329
    /**
3330
     * Adds a user-tag value

main/work/work.lib.php 1 location

@@ 3090-3110 (lines=21) @@
3087
 * @param array $courseInfo
3088
 * @return int
3089
 */
3090
function getWorkCommentCount($id, $courseInfo = array())
3091
{
3092
    if (empty($courseInfo)) {
3093
        $courseInfo = api_get_course_info();
3094
    }
3095
3096
    $commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT);
3097
    $id = intval($id);
3098
3099
    $sql = "SELECT count(*) as count
3100
            FROM $commentTable
3101
            WHERE work_id = $id AND c_id = ".$courseInfo['real_id'];
3102
3103
    $result = Database::query($sql);
3104
    if (Database::num_rows($result)) {
3105
        $comment = Database::fetch_array($result);
3106
        return $comment['count'];
3107
    }
3108
3109
    return 0;
3110
}
3111
3112
/**
3113
 * Get comment count for a specific parent