function ajaxAddComment($response, $id, $cmt, $cacheId) { JPlugin::loadLanguage('plg_walls', JPATH_ADMINISTRATOR); ini_set('display_errors', 1); error_reporting(E_ALL); // Add the comment into the db CFactory::load('libraries', 'comment'); $my = CFactory::getUser(); // Extract thenumeric id from the wall-cmt-xxx $wallId = substr($id, 9); CFactory::load('models', 'wall'); $wall =& JTable::getInstance('Wall', 'CTable'); $wall->load($wallId); $cmt = trim($cmt); $config = CFactory::getConfig(); if ($config->get('antispam_akismet_walls')) { CFactory::load('libraries', 'spamfilter'); $filter = CSpamFilter::getFilter(); $filter->setAuthor($my->getDisplayName()); $filter->setMessage($cmt); $filter->setEmail($my->email); $filter->setURL(CRoute::_('index.php?option=com_community&view=profile&userid=' . $wall->contentid)); $filter->setType('message'); $filter->setIP($_SERVER['REMOTE_ADDR']); if ($filter->isSpam()) { $response->addScriptCall('joms.jQuery( "#' . $id . ' .wall-coc-errors" ).html("' . JText::_('COM_COMMUNITY_MARKED_SPAM') . '");'); $response->addScriptCall('joms.jQuery( "#' . $id . ' .wall-coc-errors" ).show();'); $response->addScriptCall('joms.jQuery( "#' . $id . ' .wall-coc-errors" ).css("color", "red");'); $response->addScriptCall('joms.jQuery("#' . $id . ' .wall-coc-form-action.add").attr("disabled", false);'); return $response->sendResponse(); } } if (empty($cmt)) { $response->addScriptCall('joms.jQuery( "#' . $id . ' .wall-coc-errors" ).html("' . JText::_('PLG_WALLS_COMMENT_EMPTY') . '");'); $response->addScriptCall('joms.jQuery( "#' . $id . ' .wall-coc-errors" ).show();'); $response->addScriptCall('joms.jQuery( "#' . $id . ' .wall-coc-errors" ).css("color", "red");'); $response->addScriptCall('joms.jQuery("#' . $id . ' .wall-coc-form-action.add").attr("disabled", false);'); } else { $comment = new CComment(); $wall->comment = $comment->add($my->id, $cmt, $wall->comment); $wall->store(); $newComment = new stdClass(); $date = new JDate(); $newComment->creator = $my->id; $newComment->text = $cmt; $newComment->date = $date->toUnix(); $handler = $comment->getCommentHandler($wall->type); if ($handler) { $handler->sendCommentNotification($wall, $newComment->text); } $html = $comment->renderComment($newComment, true); CFactory::load('helpers', 'string'); $html = cReplaceThumbnails($html); $response->addScriptCall('joms.comments.insert', $id, $html); // Clear wall cache $cache =& JFactory::getCache('plgCommunityWalls'); $cache->remove($cacheId); $cache =& JFactory::getCache('plgCommunityWalls_fullview'); $cache->remove($cacheId); } return $response; }
function ajaxAddComment($response, $id, $cmt, $cacheId) { JPlugin::loadLanguage('plg_walls', JPATH_ADMINISTRATOR); ini_set('display_errors', 1); error_reporting(E_ALL); // Add the comment into the db CFactory::load('libraries', 'comment'); $my = CFactory::getUser(); // Extract thenumeric id from the wall-cmt-xxx $wallId = substr($id, 9); CFactory::load('models', 'wall'); $wall =& JTable::getInstance('Wall', 'CTable'); $wall->load($wallId); $cmt = trim($cmt); if (empty($cmt)) { $response->addScriptCall('joms.jQuery( "#' . $id . ' .wall-coc-errors" ).html("' . JText::_('PLG_WALLS COMMENT EMPTY') . '");'); $response->addScriptCall('joms.jQuery( "#' . $id . ' .wall-coc-errors" ).show();'); $response->addScriptCall('joms.jQuery( "#' . $id . ' .wall-coc-errors" ).css("color", "red");'); $response->addScriptCall('joms.jQuery("#' . $id . ' .wall-coc-form-action.add").attr("disabled", false);'); } else { $comment = new CComment(); $wall->comment = $comment->add($my->id, $cmt, $wall->comment); $wall->store(); $newComment = new stdClass(); $date = new JDate(); $newComment->creator = $my->id; $newComment->text = $cmt; $newComment->date = $date->toUnix(); $handler = $comment->getCommentHandler($wall->type); if ($handler) { $handler->sendCommentNotification($wall, $newComment->text); } $html = $comment->renderComment($newComment, true); CFactory::load('helpers', 'string'); $html = cReplaceThumbnails($html); $response->addScriptCall('joms.comments.insert', $id, $html); // Clear wall cache $cache =& JFactory::getCache('plgCommunityWalls'); $cache->remove($cacheId); $cache =& JFactory::getCache('plgCommunityWalls_fullview'); $cache->remove($cacheId); } return $response; }