public function actionSubmit()
 {
     if (($message_text = Yii::$app->request->post('chatText', null)) == null) {
         // if nothing was submitted
         return;
     }
     $chat = new UserChatMessage();
     $chat->message = $message_text;
     $chat->save();
 }
示例#2
0
 public static function onDailyCron($event)
 {
     $controller = $event->sender;
     $controller->stdout("Deleting old chat_messages... ");
     $timeout = Setting::Get('timeout', 'humhubchat');
     if (!$timeout || $timeout == null || $timeout <= 0) {
         $controller->stdout('skipped! no timeout set.' . PHP_EOL, \yii\helpers\Console::FG_YELLOW);
         return;
     }
     // delete old chats
     UserChatMessage::deleteAll(['<', 'created_at', Yii::$app->formatter->asDatetime(strtotime("- {$timeout} day"), 'php:Y-m-d H:i:s')]);
     $controller->stdout('done.' . PHP_EOL, \yii\helpers\Console::FG_GREEN);
 }
 public function down()
 {
     $this->dropTable(UserChatMessage::tableName());
     return true;
 }
 public function down()
 {
     $this->dropTable(UserChatMessage::tableName());
     $this->createTable(UserChatMessage::tableName(), ['id' => $this->primaryKey(), 'author' => $this->string(16)->notNull(), 'gravatar' => $this->string(255)->notNull(), 'text' => $this->string(255)->notNull(), 'ts' => $this->timestamp()->notNull()->defaultValue('CURRENT_TIMESTAMP')]);
     return true;
 }