Code Duplication    Length = 26-26 lines in 2 locations

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

@@ 249-274 (lines=26) @@
246
     * used in the works tool to record informations when
247
     * an user upload 1 work
248
     */
249
    public static function event_upload($doc_id)
250
    {
251
        $TABLETRACK_UPLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_UPLOADS);
252
        $courseId = api_get_course_int_id();
253
        $reallyNow = api_get_utc_datetime();
254
        $user_id = api_get_user_id();
255
        $doc_id = intval($doc_id);
256
257
        $sql = "INSERT INTO ".$TABLETRACK_UPLOADS."
258
                    ( upload_user_id,
259
                      c_id,
260
                      upload_cours_id,
261
                      upload_work_id,
262
                      upload_date,
263
                      upload_session_id
264
                    )
265
                    VALUES (
266
                     ".$user_id.",
267
                     '".$courseId."',
268
                     '',
269
                     '".$doc_id."',
270
                     '".$reallyNow."',
271
                     '".api_get_session_id()."'
272
                    )";
273
        Database::query($sql);
274
275
        return 1;
276
    }
277
@@ 215-240 (lines=26) @@
212
     * and later again.
213
     * Doing this twice causes an error, I remove one of them.
214
     */
215
    public static function event_download($doc_url)
216
    {
217
        $tbl_stats_downloads = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
218
        $doc_url = Database::escape_string($doc_url);
219
220
        $reallyNow = api_get_utc_datetime();
221
        $user_id = "'".api_get_user_id()."'";
222
        $_cid = api_get_course_int_id();
223
224
        $sql = "INSERT INTO $tbl_stats_downloads (
225
                     down_user_id,
226
                     c_id,
227
                     down_doc_path,
228
                     down_date,
229
                     down_session_id
230
                    )
231
                    VALUES (
232
                     ".$user_id.",
233
                     '".$_cid."',
234
                     '".$doc_url."',
235
                     '".$reallyNow."',
236
                     '".api_get_session_id()."'
237
                    )";
238
        Database::query($sql);
239
        return 1;
240
    }
241
242
    /**
243
     * @param doc_id id of document (id in mainDb.document table)