Code Duplication    Length = 6-17 lines in 6 locations

main/inc/lib/specific_fields_manager.lib.php 2 locations

@@ 225-230 (lines=6) @@
222
 * @param string $tool_id tool id, from main.api.lib
223
 * @param int $ref_id intern id inside specific tool table
224
 */
225
function delete_all_specific_field_value($course_id, $id_specific_field, $tool_id, $ref_id) {
226
    $table_sf_values = Database::get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES);
227
    $sql = 'DELETE FROM %s WHERE course_code = \'%s\' AND tool_id = \'%s\' AND ref_id = %s AND field_id = %s';
228
    $sql = sprintf($sql, $table_sf_values, $course_id, $tool_id, $ref_id, $id_specific_field);
229
    Database::query($sql);
230
}
231
232
/**
233
 * Delete all values from a specific item (course_id, tool_id and ref_id).
@@ 239-244 (lines=6) @@
236
 * @param   string  Tool ID
237
 * @param   int     Internal ID used in specific tool table
238
 */
239
function delete_all_values_for_item($course_id, $tool_id, $ref_id) {
240
  $table_sf_values = Database::get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES);
241
  $sql = 'DELETE FROM %s WHERE course_code = \'%s\' AND tool_id = \'%s\' AND ref_id = %s';
242
  $sql = sprintf($sql, $table_sf_values, $course_id, $tool_id, $ref_id);
243
  Database::query($sql);
244
}
245
246
/**
247
 * Generates a code (one-letter string) for a given field name

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

@@ 21-37 (lines=17) @@
18
     * @param int $blog_id The internal ID of the blog
19
     * @return string Blog Title
20
     */
21
    public static function getBlogTitle($blog_id)
22
    {
23
        $course_id = api_get_course_int_id();
24
25
        if (is_numeric($blog_id)) {
26
            $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
27
28
            $sql = "SELECT blog_name
29
                    FROM $tbl_blogs
30
                    WHERE c_id = $course_id AND blog_id = ".intval($blog_id);
31
32
            $result = Database::query($sql);
33
            $blog = Database::fetch_array($result);
34
35
            return stripslashes($blog['blog_name']);
36
        }
37
    }
38
39
    /**
40
     * Get the description of a blog

main/inc/lib/TicketManager.php 2 locations

@@ 109-120 (lines=12) @@
106
     * @param int $id
107
     * @return array|mixed
108
     */
109
    public static function getCategory($id)
110
    {
111
        $table = Database::get_main_table(TABLE_TICKET_CATEGORY);
112
        $id = intval($id);
113
        $sql = "SELECT id, name, description, total_tickets
114
                FROM $table WHERE id = $id";
115
116
        $result = Database::query($sql);
117
        $category = Database::fetch_array($result);
118
119
        return $category;
120
    }
121
122
    /**
123
     * @return int
@@ 1482-1496 (lines=15) @@
1479
     * @param int $ticketId
1480
     * @param int $userId
1481
     */
1482
    public static function send_alert($ticketId, $userId)
1483
    {
1484
        $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
1485
        $now = api_get_utc_datetime();
1486
1487
        $ticketId = intval($ticketId);
1488
        $userId = intval($userId);
1489
1490
        $sql = "UPDATE $table_support_tickets SET
1491
                  priority_id = '".self::PRIORITY_HIGH."',
1492
                  sys_lastedit_user_id ='$userId',
1493
                  sys_lastedit_datetime ='$now'
1494
                WHERE id = '$ticketId'";
1495
        Database::query($sql);
1496
    }
1497
1498
    /**
1499
     * @param int $ticketId

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

@@ 2098-2110 (lines=13) @@
2095
        return $html;
2096
    }
2097
2098
    public function delete_topic($group_id, $topic_id)
2099
    {
2100
        $table_message = Database::get_main_table(TABLE_MESSAGE);
2101
        $topic_id = intval($topic_id);
2102
        $group_id = intval($group_id);
2103
        $sql = "UPDATE $table_message SET
2104
                msg_status = 3
2105
                WHERE
2106
                    group_id = $group_id AND
2107
                    (id = '$topic_id' OR parent_id = $topic_id)
2108
                ";
2109
        Database::query($sql);
2110
    }
2111
2112
    /**
2113
     * @param string $user_id