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/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/sessionmanager.lib.php 2 locations

@@ 1706-1717 (lines=12) @@
1703
     *
1704
     * @return bool
1705
     */
1706
    public static function clear_session_ref_promotion($id)
1707
    {
1708
        $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
1709
        $id = intval($id);
1710
        $sql = "UPDATE $tbl_session 
1711
                SET promotion_id = 0
1712
                WHERE promotion_id = $id";
1713
        if (Database::query($sql)) {
1714
            return true;
1715
        } else {
1716
            return false;
1717
        }
1718
    }
1719
1720
    /**
@@ 3165-3182 (lines=18) @@
3162
     * @param int $sessionId
3163
     * @return bool
3164
     */
3165
    public static function removeAllDrhFromSession($sessionId)
3166
    {
3167
        $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
3168
        $sessionId = (int) $sessionId;
3169
3170
        if (empty($sessionId)) {
3171
            return false;
3172
        }
3173
3174
        $sql = "DELETE FROM $tbl_session_rel_user
3175
                WHERE
3176
                    session_id = $sessionId AND                            
3177
                    relation_type =".SESSION_RELATION_TYPE_RRHH;
3178
        Database::query($sql);
3179
3180
        return true;
3181
    }
3182
3183
    /**
3184
     * Subscribes sessions to human resource manager (Dashboard feature)
3185
     * @param array $userInfo Human Resource Manager info

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

@@ 4897-4905 (lines=9) @@
4894
    /**
4895
     * @param int $userId
4896
     */
4897
    public static function remove_user_admin($userId)
4898
    {
4899
        $table_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
4900
        $userId = intval($userId);
4901
        if (self::is_admin($userId)) {
4902
            $sql = "DELETE FROM $table_admin WHERE user_id = $userId";
4903
            Database::query($sql);
4904
        }
4905
    }
4906
4907
    /**
4908
     * @param string $from