Code Duplication    Length = 15-21 lines in 3 locations

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

@@ 3277-3291 (lines=15) @@
3274
     * @param int field_id
3275
     * @return int 0 if fails otherwise the tag id
3276
     */
3277
    public static function get_tag_id_from_id($tag_id, $field_id)
3278
    {
3279
        $table_user_tag = Database::get_main_table(TABLE_MAIN_TAG);
3280
        $tag_id = intval($tag_id);
3281
        $field_id = intval($field_id);
3282
        $sql = "SELECT id FROM $table_user_tag
3283
                WHERE id = '$tag_id' AND field_id = $field_id";
3284
        $result = Database::query($sql);
3285
        if (Database::num_rows($result) > 0) {
3286
            $row = Database::fetch_array($result, 'ASSOC');
3287
            return $row['id'];
3288
        } else {
3289
            return false;
3290
        }
3291
    }
3292
3293
    /**
3294
     * Adds a user-tag value

main/work/work.lib.php 1 location

@@ 3002-3022 (lines=21) @@
2999
 * @param array $courseInfo
3000
 * @return int
3001
 */
3002
function getWorkCommentCount($id, $courseInfo = array())
3003
{
3004
    if (empty($courseInfo)) {
3005
        $courseInfo = api_get_course_info();
3006
    }
3007
3008
    $commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT);
3009
    $id = intval($id);
3010
3011
    $sql = "SELECT count(*) as count
3012
            FROM $commentTable
3013
            WHERE work_id = $id AND c_id = ".$courseInfo['real_id'];
3014
3015
    $result = Database::query($sql);
3016
    if (Database::num_rows($result)) {
3017
        $comment = Database::fetch_array($result);
3018
        return $comment['count'];
3019
    }
3020
3021
    return 0;
3022
}
3023
3024
/**
3025
 * Get comment count for a specific parent

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

@@ 2261-2278 (lines=18) @@
2258
     * @param array $courseInfo
2259
     * @return array with the post info
2260
     */
2261
    public function getAttachment($eventId, $courseInfo)
2262
    {
2263
        $tableAttachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT);
2264
        $courseId = intval($courseInfo['real_id']);
2265
        $eventId = intval($eventId);
2266
        $row = array();
2267
        $sql = "SELECT id, path, filename, comment
2268
                FROM $tableAttachment
2269
                WHERE
2270
                    c_id = $courseId AND
2271
                    agenda_id = $eventId";
2272
        $result = Database::query($sql);
2273
        if (Database::num_rows($result) != 0) {
2274
            $row = Database::fetch_array($result, 'ASSOC');
2275
        }
2276
2277
        return $row;
2278
    }
2279
2280
    /**
2281
     * Add an attachment file into agenda