コード例 #1
0
 /**
  * Test topic creation
  *
  * @param KunenaForumTopic $topic
  * @return KunenaForumTopic
  * @depends testNew
  */
 public function testCreate(KunenaForumTopic $topic)
 {
     // Creation should fail if there's not enough data
     $this->assertFalse($topic->save());
     $this->assertFalse($topic->exists());
     $this->assertNull($topic->id);
     /*		$topic->category_id = 2;
     		$topic->subject = 'Topic';
     		$this->assertTrue($topic->save());
     		$this->assertTrue($topic->exists());
     		$this->assertGreaterThan(1, $topic->id);
     		$topic2 = KunenaForumTopic::getInstance($topic->id);
     		// TODO: Do we want this?
     		//$this->assertSame($topic, $topic2);
     		$this->assertSame($topic->id, $topic2->id);
     		$this->assertSame($topic->name, $topic2->name);
     		return $topic2;*/
 }
コード例 #2
0
ファイル: kunena.php プロジェクト: jfquestiaux/fabrik
 /**
  * Post to Kunena 3.x
  *
  * @return  void
  */
 protected function post3x()
 {
     // Load front end language file as well
     $lang = $this->lang;
     $lang->load('com_kunena', JPATH_SITE . '/components/com_kunena');
     $params = $this->getParams();
     $app = $this->app;
     $formModel = $this->getModel();
     $input = $app->input;
     $user = $this->user;
     $now = $this->date;
     $w = new FabrikWorker();
     $catid = $params->get('kunena_category', 0);
     // Added action in request
     $msg = $w->parseMessageForPlaceHolder($params->get('kunena_content'), $formModel->fullFormData);
     $subject = $params->get('kunena_title');
     $subject = $w->parseMessageForPlaceHolder($subject, $formModel->fullFormData);
     // Added subject in request
     $origId = $input->get('id');
     $input->set('id', 0);
     $topic = new KunenaForumTopic();
     $topic->category_id = $catid;
     $topic->subject = $subject;
     $topic->first_post_time = $topic->last_post_time = $now->toUnix();
     $topic->first_post_userid = $topic->last_post_userid = $user->get('id');
     $topic->first_post_message = $topic->last_post_message = $msg;
     $topic->posts = 1;
     if ($topic->save()) {
         $message = new KunenaForumMessage();
         $message->setTopic($topic);
         $message->subject = $subject;
         $message->catid = $catid;
         $message->name = $user->get('name');
         $message->time = $now->toUnix();
         $message->message = $msg;
         if (!$message->save()) {
             $app->enqueueMessage(FText::_('PLG_FORM_KUNENA_ERR_DIDNT_SAVE_MESSAGE') . ': ' . $message->getError(), 'error');
         }
     } else {
         $app->enqueueMessage(FText::_('PLG_FORM_KUNENA_ERR_DIDNT_SAVE_TOPIC') . ': ' . $topic->getError(), 'error');
     }
     $input->set('id', $origId);
 }