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
@@ 1201-1222 (lines=22) @@
1198
    /**
1199
     * This function checks if wiki title exist
1200
     */
1201
    public function wiki_exist($title)
1202
    {
1203
        $tbl_wiki = $this->tbl_wiki;
1204
        $groupfilter = $this->groupfilter;
1205
        $condition_session = $this->condition_session;
1206
        $course_id = api_get_course_int_id();
1207
1208
        $sql = 'SELECT id FROM '.$tbl_wiki.'
1209
              WHERE
1210
                c_id = '.$course_id.' AND
1211
                title="'.Database::escape_string($title).'" AND
1212
                '.$groupfilter.$condition_session.'
1213
              ORDER BY id ASC';
1214
        $result = Database::query($sql);
1215
        $cant = Database::num_rows($result);
1216
        if ($cant > 0) {
1217
            return true;
1218
        } else {
1219
            return false;
1220
        }
1221
    }
1222
1223
    /**
1224
     * Checks if this navigation tab has to be set to active
1225
     * @author Patrick Cool <[email protected]>, Ghent University