Skip to content

Commit

Permalink
fixed: kunena form plugin was not working with kunena 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
pollen8 committed Jan 6, 2014
1 parent d355def commit 6cf1068
Showing 1 changed file with 75 additions and 15 deletions.
90 changes: 75 additions & 15 deletions plugins/fabrik_form/kunena/kunena.php
Expand Up @@ -38,18 +38,50 @@ public function onAfterProcess()
$formModel = $this->getModel();
$input = $app->input;
jimport('joomla.filesystem.file');
$files[] = COM_FABRIK_BASE . 'components/com_kunena/class.kunena.php';
$define = COM_FABRIK_BASE . 'components/com_kunena/lib/kunena.defines.php';
$files[] = COM_FABRIK_BASE . 'components/com_kunena/lib/kunena.defines.php';
$files[] = COM_FABRIK_BASE . 'components/com_kunena/lib/kunena.link.class.php';
$files[] = COM_FABRIK_BASE . 'components/com_kunena/lib/kunena.smile.class.php';
$define = COM_FABRIK_BASE . 'libraries/kunena/bootstrap.php';

if (!JFile::exists($define))
if (JFile::exists($define))
{
throw new RuntimeException('could not find the Kunena component', 404);
// Kunenea 3.x
require_once $define;
$this->post3x();
}
else
{
$define = COM_FABRIK_BASE . 'components/com_kunena/lib/kunena.defines.php';

if (JFile::exists($define))
{
require_once $define;
$this->post2x();
}
else
{
throw new RuntimeException('could not find the Kunena component', 404);
}
}
}

require_once $define;
/**
* Post to Kunena 2.x
*
* @return void
*/
protected function post2x()
{
$params = $this->getParams();
$app = JFactory::getApplication();
$formModel = $this->getModel();
$input = $app->input;
$w = new FabrikWorker;

$catid = $params->get('kunena_category', 0);
$parentid = 0;

$files[] = COM_FABRIK_BASE . 'components/com_kunena/class.kunena.php';
$files[] = COM_FABRIK_BASE . 'components/com_kunena/lib/kunena.defines.php';
$files[] = COM_FABRIK_BASE . 'components/com_kunena/lib/kunena.link.class.php';
$files[] = COM_FABRIK_BASE . 'components/com_kunena/lib/kunena.smile.class.php';

foreach ($files as $file)
{
Expand All @@ -65,13 +97,6 @@ public function onAfterProcess()
$postfile = KUNENA_PATH_TEMPLATE_DEFAULT . '/post.php';
}

$w = new FabrikWorker;

// $fbSession = CKunenaSession::getInstance();
// Don't need this, session is loaded in CKunenaPost

$catid = $params->get('kunena_category', 0);
$parentid = 0;
$action = 'post';

// Added action in request
Expand All @@ -98,4 +123,39 @@ public function onAfterProcess()
ob_end_clean();
$input->set('id', $origId);
}

/**
* Post to Kunena 3.x
*
* @return void
*/

protected function post3x()
{
$params = $this->getParams();
$app = JFactory::getApplication();
$formModel = $this->getModel();
$input = $app->input;
$w = new FabrikWorker;

$catid = $params->get('kunena_category', 0);
$parentid = 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);

$mypost = new KunenaForumTopic;
$mypost->category_id = $catid;
$mypost->subject = $subject;
$mypost->first_post_message = $msg;

$mypost->save();
$input->set('id', $origId);
}
}

0 comments on commit 6cf1068

Please sign in to comment.