Code Duplication    Length = 22-22 lines in 2 locations

main/wiki/wiki.inc.php 2 locations

@@ 72-93 (lines=22) @@
69
     * @return bool  False if title is already taken
70
     * @author Patrick Cool <[email protected]>, Ghent University
71
     **/
72
    public function checktitle($link)
73
    {
74
        $tbl_wiki = $this->tbl_wiki;
75
        $condition_session = $this->condition_session;
76
        $course_id = $this->course_id;
77
        $groupfilter = $this->groupfilter;
78
79
        $sql = 'SELECT * FROM '.$tbl_wiki.'
80
                WHERE
81
                    c_id = '.$course_id.' AND
82
                    reflink="'.Database::escape_string($link).'" AND
83
                    '.$groupfilter.$condition_session.'';
84
        $result = Database::query($sql);
85
        $numberofresults = Database::num_rows($result);
86
        // the value has not been found and is this available
87
        if ($numberofresults == 0) {
88
            return true;
89
        } else {
90
            // the value has been found
91
            return false;
92
        }
93
    }
94
95
    /**
96
     * check wikilinks that has a page
@@ 1346-1367 (lines=22) @@
1343
    /**
1344
     * This function checks if wiki title exist
1345
     */
1346
    public function wiki_exist($title)
1347
    {
1348
        $tbl_wiki = $this->tbl_wiki;
1349
        $groupfilter = $this->groupfilter;
1350
        $condition_session = $this->condition_session;
1351
        $course_id = api_get_course_int_id();
1352
1353
        $sql = 'SELECT id FROM '.$tbl_wiki.'
1354
              WHERE
1355
                c_id = '.$course_id.' AND
1356
                title="'.Database::escape_string($title).'" AND
1357
                '.$groupfilter.$condition_session.'
1358
              ORDER BY id ASC';
1359
        $result = Database::query($sql);
1360
        $cant = Database::num_rows($result);
1361
        if ($cant > 0) {
1362
            return true;
1363
        } else {
1364
            return false;
1365
        }
1366
    }
1367
1368
    /**
1369
     * Checks if this navigation tab has to be set to active
1370
     * @author Patrick Cool <[email protected]>, Ghent University