function testExistence() { $i = new folksoDBinteract($this->dbc); $this->assertTrue($i->resourcep('http://example.com/1'), 'Not reporting existence of example.com/1 (resourcep)'); $dbc2 = new folksoDBconnect('localhost', 'tester_dude', 'testy', 'testostonomie'); $i2 = new folksoDBinteract($dbc2); $this->assertTrue($i2->tagp('tagone'), 'Not reporting existence of "tagone"'); $this->assertFalse($i2->db_error(), 'tagp() is returning an DB error'); $this->assertTrue($i2->tagp(1), 'numeric tagp not reporting existence of tag 1'); $this->assertEqual($i2->db->real_escape_string('tagone'), 'tagone', 'Strangeness using real_escape_string'); $this->assertFalse($i2->tagp('false tag'), 'Reporting existence of non-existant tag'); $this->assertFalse($i2->tagp(199), 'Reporting existence of non-existant tag (numeric)'); }
/** * rename tag * * rename, newname * */ function renameTag(folksoQuery $q, folksoDBconnect $dbc, folksoSession $fks) { $r = new folksoResponse(); $u = $fks->userSession(null, 'folkso', 'admin'); if (!$u instanceof folksoUser || !$u->checkUserRight('folkso', 'admin')) { return $r->unAuthorized($u); } try { $i = new folksoDBinteract($dbc); if (!$i->tagp($q->tag)) { $r->setError(404, 'Tag not found', 'Nothing to rename. No such tag: ' . $q->tag); return $r; } $query = "UPDATE tag\n SET tagdisplay = '" . $i->dbescape($q->get_param('newname')) . "', " . "tagnorm = normalize_tag('" . $i->dbescape($q->get_param('newname')) . "') " . "where "; if (is_numeric($q->tag)) { $query .= " id = " . $q->tag; } else { $query .= " tagnorm = normalize_tag('" . $i->dbescape($q->tag) . "')"; } $i->query($query); } catch (dbException $e) { return $r->handleDBexception($e); } $r->setOk(204, 'Tag renamed'); return $r; }