X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FQnA%2Fclasses%2FQnA_Answer.php;h=d04159f9b9375e529240ffdb49d71ed331c7830c;hb=d6b28c64830f632bb2f4b6f3c9369b9e56ad217a;hp=9db52985adfa604f8741b225cff0c7050f47b0a8;hpb=7d191f8062e5d117ac234737bc7ab838859dc4d6;p=quix0rs-gnu-social.git diff --git a/plugins/QnA/classes/QnA_Answer.php b/plugins/QnA/classes/QnA_Answer.php index 9db52985ad..d04159f9b9 100644 --- a/plugins/QnA/classes/QnA_Answer.php +++ b/plugins/QnA/classes/QnA_Answer.php @@ -48,6 +48,7 @@ class QnA_Answer extends Managed_DataObject public $__table = 'qna_answer'; // table name public $id; // char(36) primary key not null -> UUID + public $uri; // varchar(191) not 255 because utf8mb4 takes more space public $question_id; // char(36) -> question.id UUID public $profile_id; // int -> question.id public $best; // (boolean) int -> whether the question asker has marked this as the best answer @@ -66,24 +67,25 @@ class QnA_Answer extends Managed_DataObject 'id' => array( 'type' => 'char', 'length' => 36, - 'not null' => true, 'description' => 'UUID of the response'), - 'uri' => array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => true, - 'description' => 'UUID to the answer notice' - ), - 'question_id' => array( - 'type' => 'char', - 'length' => 36, - 'not null' => true, - 'description' => 'UUID of question being responded to' - ), - 'content' => array('type' => 'text'), // got a better name? - 'best' => array('type' => 'int', 'size' => 'tiny'), - 'revisions' => array('type' => 'int'), - 'profile_id' => array('type' => 'int'), - 'created' => array('type' => 'datetime', 'not null' => true), + 'not null' => true, 'description' => 'UUID of the response', + ), + 'uri' => array( + 'type' => 'varchar', + 'length' => 191, + 'not null' => true, + 'description' => 'UUID to the answer notice', + ), + 'question_id' => array( + 'type' => 'char', + 'length' => 36, + 'not null' => true, + 'description' => 'UUID of question being responded to', + ), + 'content' => array('type' => 'text'), // got a better name? + 'best' => array('type' => 'int', 'size' => 'tiny'), + 'revisions' => array('type' => 'int'), + 'profile_id' => array('type' => 'int'), + 'created' => array('type' => 'datetime', 'not null' => true), ), 'primary key' => array('id'), 'unique keys' => array( @@ -103,7 +105,7 @@ class QnA_Answer extends Managed_DataObject * * @return QnA_Answer found response or null */ - static function getByNotice($notice) + static function getByNotice(Notice $notice) { $answer = self::getKV('uri', $notice->uri); if (empty($answer)) { @@ -122,7 +124,7 @@ class QnA_Answer extends Managed_DataObject return Notice::getKV('uri', $this->uri); } - static function fromNotice($notice) + static function fromNotice(Notice $notice) { return QnA_Answer::getKV('uri', $notice->uri); } @@ -177,7 +179,7 @@ class QnA_Answer extends Managed_DataObject ); } - static function toHTML($profile, $question, $answer) + static function toHTML(Profile $profile, $question, $answer) { $notice = $question->getNotice(); @@ -235,12 +237,8 @@ class QnA_Answer extends Managed_DataObject * * @return Notice saved notice */ - static function saveNew($profile, $question, $text, $options = null) + static function saveNew(Profile $profile, $question, $text, array $options = array()) { - if (empty($options)) { - $options = array(); - } - $answer = new QnA_Answer(); $answer->id = UUID::gen(); $answer->profile_id = $profile->id; @@ -254,7 +252,7 @@ class QnA_Answer extends Managed_DataObject array('id' => $answer->id) ); - common_log(LOG_DEBUG, "Saving answer: $answer->id, $answer->uri"); + common_debug("Saving answer: $answer->id, $answer->uri"); $answer->insert(); $content = sprintf(