Code Duplication    Length = 15-21 lines in 3 locations

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

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

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

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