Code Duplication    Length = 7-18 lines in 14 locations

main/inc/lib/urlmanager.lib.php 4 locations

@@ 177-187 (lines=11) @@
174
     * @param int $url_id
175
     * @return array
176
     * */
177
    public static function get_url_data_from_id($url_id)
178
    {
179
        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
180
        $sql = "SELECT id, url, description, active
181
                FROM $table
182
                WHERE id = ".intval($url_id);
183
        $res = Database::query($sql);
184
        $row = Database::fetch_array($res);
185
186
        return $row;
187
    }
188
189
    /**
190
     * Gets the inner join of users and urls table
@@ 258-268 (lines=11) @@
255
     *
256
     * @return int Database::num_rows($res);
257
     **/
258
    public static function getCountUrlRelCourse($courseId)
259
    {
260
        $courseId = intval($courseId);
261
        $tableUrlRelCourse = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
262
        $sql = "SELECT *
263
                FROM $tableUrlRelCourse
264
                WHERE c_id = '$courseId'";
265
        $res = Database::query($sql);
266
267
        return Database::num_rows($res);
268
    }
269
270
    /**
271
     * Gets the inner join of access_url and the session table
@@ 792-803 (lines=12) @@
789
     *
790
     * @return boolean true if success
791
     * */
792
    public static function deleteUserFromAllUrls($userId)
793
    {
794
        $table_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
795
        $result = true;
796
        if (!empty($userId)) {
797
            $sql= "DELETE FROM $table_url_rel_user
798
                   WHERE user_id = ".intval($userId);
799
            Database::query($sql);
800
        }
801
802
        return $result;
803
    }
804
805
    /**
806
    * Deletes an url and course relationship
@@ 831-840 (lines=10) @@
828
     *
829
     * @return boolean true if success
830
     * */
831
    public static function delete_url_rel_usergroup($userGroupId, $urlId)
832
    {
833
        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
834
        $sql= "DELETE FROM $table
835
               WHERE usergroup_id = '".intval($userGroupId)."' AND
836
                     access_url_id = ".intval($urlId);
837
        $result = Database::query($sql);
838
839
        return $result;
840
    }
841
842
    /**
843
     * Deletes an url and $userGroup relationship

main/inc/lib/TicketManager.php 2 locations

@@ 215-223 (lines=9) @@
212
     *
213
     * @return array
214
     */
215
    public static function getUsersInCategory($categoryId)
216
    {
217
        $table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER);
218
        $categoryId = intval($categoryId);
219
        $sql = "SELECT * FROM $table WHERE category_id = $categoryId";
220
        $result = Database::query($sql);
221
222
        return Database::store_result($result);
223
    }
224
225
    /**
226
     * @param int $categoryId
@@ 228-234 (lines=7) @@
225
    /**
226
     * @param int $categoryId
227
     */
228
    public static function deleteAllUserInCategory($categoryId)
229
    {
230
        $table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER);
231
        $categoryId = intval($categoryId);
232
        $sql = "DELETE FROM $table WHERE category_id = $categoryId";
233
        Database::query($sql);
234
    }
235
236
    /**
237
     * Get all possible tickets statuses

main/gradebook/lib/GradebookUtils.php 1 location

@@ 95-107 (lines=13) @@
92
     * @param    int     Link/Resource ID
93
     * @return   bool    false on error, true on success
94
     */
95
    public static function remove_resource_from_course_gradebook($link_id)
96
    {
97
        if (empty($link_id)) {
98
            return false;
99
        }
100
101
        // TODO find the corresponding category (the first one for this course, ordered by ID)
102
        $l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
103
        $sql = "DELETE FROM $l WHERE id = ".(int)$link_id;
104
        Database::query($sql);
105
106
        return true;
107
    }
108
109
    /**
110
     * Block students

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

@@ 166-172 (lines=7) @@
163
 * @param int User ID
164
 * @return void
165
 */
166
function LoginDelete($user_id)
167
{
168
    $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
169
    $user_id = intval($user_id);
170
    $query = "DELETE FROM " . $online_table . " WHERE login_user_id = $user_id";
171
    Database::query($query);
172
}
173
174
/**
175
 * @param int $user_id

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

@@ 1631-1639 (lines=9) @@
1628
    * @param int $id id message to delete.
1629
    * @return bool status query
1630
    */
1631
    public static function deleteMessage($id)
1632
    {
1633
        $id = intval($id);
1634
        $tblMessage = Database::get_main_table(TABLE_MESSAGE);
1635
        $statusMessage = MESSAGE_STATUS_WALL_DELETE;
1636
        $sql = "UPDATE $tblMessage SET msg_status = '$statusMessage' WHERE id = '{$id}' ";
1637
1638
        return Database::query($sql);
1639
    }
1640
1641
    /**
1642
     * Generate the social block for a user

main/inc/lib/sub_language.class.php 2 locations

@@ 359-367 (lines=9) @@
356
     * @param int The language id
357
     * @return void()
358
     */
359
    public static function make_unavailable_language($language_id)
360
    {
361
        $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
362
        $sql = "UPDATE $tbl_admin_languages SET available='0'
363
                WHERE id = " . intval($language_id) . "";
364
        $result = Database::query($sql);
365
366
        return $result !== false; //only return false on sql error
367
    }
368
369
    /**
370
     * Make available the language
@@ 374-382 (lines=9) @@
371
     * @param int The language id
372
     * @return void
373
     */
374
    public static function make_available_language($language_id)
375
    {
376
        $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
377
        $sql = "UPDATE $tbl_admin_languages SET available='1'
378
                WHERE id = " . intval($language_id) . "";
379
        $result = Database::query($sql);
380
381
        return $result !== false; //only return false on sql error
382
    }
383
384
    /**
385
     * Set platform language

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

@@ 1649-1660 (lines=12) @@
1646
     *
1647
     * @return bool
1648
     */
1649
    public static function clear_session_ref_promotion($id)
1650
    {
1651
        $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
1652
        $id = intval($id);
1653
        $sql = "UPDATE $tbl_session 
1654
                SET promotion_id = 0
1655
                WHERE promotion_id = $id";
1656
        if (Database::query($sql)) {
1657
            return true;
1658
        } else {
1659
            return false;
1660
        }
1661
    }
1662
1663
    /**
@@ 2984-3001 (lines=18) @@
2981
     * @param int $sessionId
2982
     * @return bool
2983
     */
2984
    public static function removeAllDrhFromSession($sessionId)
2985
    {
2986
        $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
2987
2988
        $sessionId = (int) $sessionId;
2989
2990
        if (empty($sessionId)) {
2991
            return false;
2992
        }
2993
2994
        $sql = "DELETE FROM $tbl_session_rel_user
2995
                WHERE
2996
                    session_id = $sessionId AND                            
2997
                    relation_type =" . SESSION_RELATION_TYPE_RRHH;
2998
        Database::query($sql);
2999
3000
        return true;
3001
    }
3002
3003
    /**
3004
     * Subscribes sessions to human resource manager (Dashboard feature)

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

@@ 5101-5109 (lines=9) @@
5098
    /**
5099
     * @param int $userId
5100
     */
5101
    public static function remove_user_admin($userId)
5102
    {
5103
        $table_admin = Database :: get_main_table(TABLE_MAIN_ADMIN);
5104
        $userId = intval($userId);
5105
        if (self::is_admin($userId)) {
5106
            $sql = "DELETE FROM $table_admin WHERE user_id = $userId";
5107
            Database::query($sql);
5108
        }
5109
    }
5110
5111
    /**
5112
     * @param string $from