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/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

@@ 1777-1785 (lines=9) @@
1774
    * @param int $id id message to delete.
1775
    * @return bool status query
1776
    */
1777
    public static function deleteMessage($id)
1778
    {
1779
        $id = intval($id);
1780
        $tblMessage = Database::get_main_table(TABLE_MESSAGE);
1781
        $statusMessage = MESSAGE_STATUS_WALL_DELETE;
1782
        $sql = "UPDATE $tblMessage SET msg_status = '$statusMessage' WHERE id = '{$id}' ";
1783
1784
        return Database::query($sql);
1785
    }
1786
1787
    /**
1788
     * Generate the social block for a user

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

@@ 1666-1677 (lines=12) @@
1663
     *
1664
     * @return bool
1665
     */
1666
    public static function clear_session_ref_promotion($id)
1667
    {
1668
        $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
1669
        $id = intval($id);
1670
        $sql = "UPDATE $tbl_session 
1671
                SET promotion_id = 0
1672
                WHERE promotion_id = $id";
1673
        if (Database::query($sql)) {
1674
            return true;
1675
        } else {
1676
            return false;
1677
        }
1678
    }
1679
1680
    /**
@@ 3061-3078 (lines=18) @@
3058
     * @param int $sessionId
3059
     * @return bool
3060
     */
3061
    public static function removeAllDrhFromSession($sessionId)
3062
    {
3063
        $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
3064
3065
        $sessionId = (int) $sessionId;
3066
3067
        if (empty($sessionId)) {
3068
            return false;
3069
        }
3070
3071
        $sql = "DELETE FROM $tbl_session_rel_user
3072
                WHERE
3073
                    session_id = $sessionId AND                            
3074
                    relation_type =" . SESSION_RELATION_TYPE_RRHH;
3075
        Database::query($sql);
3076
3077
        return true;
3078
    }
3079
3080
    /**
3081
     * Subscribes sessions to human resource manager (Dashboard feature)

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

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

main/inc/lib/TicketManager.php 2 locations

@@ 230-238 (lines=9) @@
227
     *
228
     * @return array
229
     */
230
    public static function getUsersInCategory($categoryId)
231
    {
232
        $table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER);
233
        $categoryId = intval($categoryId);
234
        $sql = "SELECT * FROM $table WHERE category_id = $categoryId";
235
        $result = Database::query($sql);
236
237
        return Database::store_result($result);
238
    }
239
240
    /**
241
     * @param int $categoryId
@@ 243-249 (lines=7) @@
240
    /**
241
     * @param int $categoryId
242
     */
243
    public static function deleteAllUserInCategory($categoryId)
244
    {
245
        $table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER);
246
        $categoryId = intval($categoryId);
247
        $sql = "DELETE FROM $table WHERE category_id = $categoryId";
248
        Database::query($sql);
249
    }
250
251
    /**
252
     * Get all possible tickets statuses

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

@@ 5190-5198 (lines=9) @@
5187
    /**
5188
     * @param int $userId
5189
     */
5190
    public static function remove_user_admin($userId)
5191
    {
5192
        $table_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
5193
        $userId = intval($userId);
5194
        if (self::is_admin($userId)) {
5195
            $sql = "DELETE FROM $table_admin WHERE user_id = $userId";
5196
            Database::query($sql);
5197
        }
5198
    }
5199
5200
    /**
5201
     * @param string $from