/** * Set up our tables (question and answer) * * @see Schema * @see ColumnDef * * @return boolean hook value; true means continue processing, false means stop. */ function onCheckSchema() { $schema = Schema::get(); $schema->ensureTable('qna_question', QnA_Question::schemaDef()); $schema->ensureTable('qna_answer', QnA_Answer::schemaDef()); $schema->ensureTable('qna_vote', QnA_Vote::schemaDef()); return true; }
/** * Save a vote on a question or answer * * @param Profile $profile * @param QnA_Question the question being voted on * @param QnA_Answer the answer being voted on * @param vote * @param array * * @return Void */ static function save($profile, $question, $answer, $vote) { $v = new QnA_Vote(); $v->id = UUID::gen(); $v->profile_id = $profile->id; $v->question_id = $question->id; $v->answer_id = $answer->id; $v->vote = $vote; $v->created = common_sql_now(); common_log(LOG_DEBUG, "Saving vote: {$v->id} {$v->vote}"); $v->insert(); }