Code Duplication    Length = 10-16 lines in 6 locations

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

@@ 202-214 (lines=13) @@
199
     * @param int $career_id
200
     * @return bool
201
     */
202
    public function get_status($career_id)
203
    {
204
        $TBL_CAREER             = Database::get_main_table(TABLE_CAREER);
205
        $career_id = intval($career_id);
206
        $sql 	= "SELECT status FROM $TBL_CAREER WHERE id = '$career_id'";
207
        $result = Database::query($sql);
208
        if (Database::num_rows($result) > 0) {
209
            $data = Database::fetch_array($result);
210
            return $data['status'];
211
        } else {
212
            return false;
213
        }
214
    }
215
216
    /**
217
     * @param array $params

main/newscorm/resourcelinker.inc.php 1 location

@@ 1342-1353 (lines=12) @@
1339
/**
1340
 * This function checks wether there are added resources or not
1341
 */
1342
function check_added_resources($type, $id) {
1343
    $course_id = api_get_course_int_id();
1344
    $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES);
1345
    $sql = "SELECT * FROM $TABLERESOURCE
1346
            WHERE c_id = $course_id AND source_type='$type' and source_id='$id'";
1347
    $result = Database::query($sql);
1348
    $number_added = Database::num_rows($result);
1349
    if ($number_added != 0)
1350
        return true;
1351
    else
1352
        return false;
1353
}
1354
1355
/**
1356
 * this function is to load the resources that were added to a specific item

main/resourcelinker/resourcelinker.inc.php 1 location

@@ 1468-1479 (lines=12) @@
1465
/**
1466
* this function checks wether there are added resources or not
1467
*/
1468
function check_added_resources($type, $id)
1469
{
1470
	global $_course, $origin;
1471
	$TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
1472
	$sql="SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'";
1473
	$result=Database::query($sql);
1474
	$number_added=Database::num_rows($result);
1475
	if ($number_added<>0)
1476
		return true;
1477
	else
1478
		return false;
1479
}
1480
1481
1482
/**

plugin/ticket/src/ticket.class.php 1 location

@@ 168-177 (lines=10) @@
165
     *
166
     * @return bool
167
     */
168
    public static function userIsAssignedToCategory($userId, $categoryId)
169
    {
170
        $table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER);
171
        $userId = intval($userId);
172
        $categoryId = intval($categoryId);
173
        $sql = "SELECT * FROM $table WHERE category_id = $categoryId AND user_id = $userId";
174
        $result = Database::query($sql);
175
176
        return Database::num_rows($result) > 0;
177
    }
178
179
    /**
180
     * @param int $categoryId

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

@@ 2710-2724 (lines=15) @@
2707
     * @param string session category ID
2708
     * @return mixed false if the session category does not exist, array if the session category exists
2709
     */
2710
    public static function get_session_category($id)
2711
    {
2712
        $tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
2713
        $id = intval($id);
2714
        $sql = "SELECT id, name, date_start, date_end
2715
                FROM $tbl_session_category
2716
                WHERE id= $id";
2717
        $result = Database::query($sql);
2718
        $num = Database::num_rows($result);
2719
        if ($num > 0) {
2720
            return Database::fetch_array($result);
2721
        } else {
2722
            return false;
2723
        }
2724
    }
2725
2726
    /**
2727
     * Get all session categories (filter by access_url_id)

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

@@ 847-862 (lines=16) @@
844
     * @param array $list
845
     * @return array
846
     */
847
    public static function getCourseCategoryNotInList($list)
848
    {
849
        $table = Database::get_main_table(TABLE_MAIN_CATEGORY);
850
        if (empty($list)) {
851
            return array();
852
        }
853
854
        $list = array_map('intval', $list);
855
        $listToString = implode("','", $list);
856
857
        $sql = "SELECT * FROM $table
858
            WHERE id NOT IN ('$listToString') AND (parent_id IS NULL) ";
859
        $result = Database::query($sql);
860
861
        return Database::store_result($result, 'ASSOC');
862
    }
863
864
    /**
865
     * @param string $keyword