/** * flag/unflag topic * @param $topic_id topic id */ function flag($topic_id) { if (!$topic_id) { return '<ret>0</ret>'; } $u = $this->getLoginUser(); if (!$u) { return '<ret>0</ret>'; } $db = new DbForum(); if ($db->isFlagged((int) $topic_id, $u)) { if (!$db->unflag((int) $topic_id, $u)) { return '<ret>0</ret>'; } return '<ret>-1</ret>'; } if (!$db->flag((int) $topic_id, $u)) { return '<ret>0</ret>'; } return '<ret>1</ret>'; }