Example #1
0
 /**
  * Set Jcomments config for the actual product, and the value of $comments_enabled
  * 
  * @author Florian Voutzinos
  * @param object $product virtuemart product object
  * @param array	$excludedCatIds Ids of excluded category from plugin params
  * @return void
  */
 public static function applyConfig($product, $excludedCatIds)
 {
     $config = JCommentsFactory::getConfig();
     // {Jcomments} tag domines Excluded categories !
     // and {Jcomments OFF} domines everything
     // if {Jcomments OFF} tag found we disable comments by force
     if (self::isDisabled($product)) {
         $config->set('comments_on', 0);
         $config->set('comments_off', 1);
         self::$comments_enabled = false;
     } elseif (self::isEnabled($product)) {
         $config->set('comments_on', 1);
         $config->set('comments_off', 0);
         self::$comments_enabled = true;
     } else {
         // we enable comments if the product category is enabled
         if (self::isCategoryProductEnabled($product, $excludedCatIds)) {
             $config->set('comments_on', 1);
             $config->set('comments_off', 0);
             self::$comments_enabled = true;
         } else {
             $config->set('comments_on', 0);
             $config->set('comments_off', 1);
             self::$comments_enabled = false;
         }
     }
     $config->set('comments_locked', (int) self::isLocked($product));
 }
Example #2
0
 /**
  * We display Jcomments tpl, regarding the plugin config and the display config set previously
  * 
  * @author Florian Voutzinos
  * @param string $context
  * @param object reference $product virtuemart product object
  * @param object reference $params 
  * @param int $limitstart
  * @return string JComments display
  */
 function onContentAfterDisplay($context, &$product, &$params, $limitstart = 0)
 {
     // If the trigger comes from virtuemart productdetails and the plugin is activated in the config
     if ($context == 'com_virtuemart.productdetails' && $this->params->get('plugin_activated')) {
         // Do not display comments in modules
         $data = $params->toArray();
         if (isset($data['moduleclass_sfx'])) {
             return '';
         }
         // Display the comments if enabled
         if (VmJcommentsHelperPlugin::areCommentsEnabled()) {
             if (!class_exists('JComments')) {
                 require JCOMMENTS_BASE . '/jcomments.php';
             }
             return JComments::show($product->virtuemart_product_id, 'com_virtuemart', $product->product_name);
         }
         return '';
     }
     return '';
 }