コード例 #1
0
ファイル: folksoTagQuery-test.php プロジェクト: josf/folkso
 function testUDeleteTag()
 {
     $tq = new folksoTagQuery();
     $this->assertPattern('/stuff/', $tq->userDeleteTag('stuff', 'gustav-001-2001'));
     $this->assertPattern('/\'gustav/', $tq->userDeleteTag('stuff', 'gustav-001-2001'));
     $this->assertPattern('/1984/', $tq->userDeleteTag(1984, 'gustav-001-2001'));
 }
コード例 #2
0
ファイル: tag.php プロジェクト: josf/folkso
/**
 * Delete all of a user's tag events marked with a given tag. For the
 * user, the tag "disappears" from her tags. Resources disappear too,
 * unless they are tagged with another tag.
 *
 */
function userDeleteTag(folksoQuery $q, folksoDBconnect $dbc, folksoSession $fks)
{
    $r = new folksoResponse();
    $u = $fks->userSession();
    if (!$u instanceof folksoUser) {
        // user must exist if object does... seriously
        return $r->unAuthorized($u);
    }
    try {
        $i = new folksoDBinteract($dbc);
        if (!$i->tagp($q->tag)) {
            $r->setError(404, 'Could not delete - tag not found', $q->tag . " does not exist in the database");
            return $r;
        }
        $tq = new folksoTagQuery();
        $sql = $tq->userDeleteTag($q->tag, $u->userid);
        print "<p><pre>" . $sql . "</pre></p>";
        $i->query($sql);
    } catch (dbException $e) {
        $r->handleDBexception($e);
        return $r;
    }
    $r->setOk(204, 'Tag deleted from users tags');
    return $r;
}