/** * Ajax function to save a new wall entry * * @param message A message that is submitted by the user * @param uniqueId The unique id for this group * **/ function ajaxSaveWall($response, $message, $uniqueId, $cache_id = "") { $my = CFactory::getUser(); $user = CFactory::getUser($uniqueId); $config = CFactory::getConfig(); JPlugin::loadLanguage('plg_walls', JPATH_ADMINISTRATOR); // Load libraries CFactory::load('models', 'photos'); CFactory::load('libraries', 'wall'); CFactory::load('helpers', 'url'); CFactory::load('libraries', 'activities'); $message = JString::trim($message); $message = strip_tags($message); if (empty($message)) { $response->addAlert(JText::_('PLG_WALLS_PLEASE_ADD_MESSAGE')); } else { $maxchar = $this->params->get('charlimit', 0); if (!empty($maxchar)) { $msglength = strlen($message); if ($msglength > $maxchar) { $message = substr($message, 0, $maxchar); } } // @rule: Spam checks if ($config->get('antispam_akismet_walls')) { CFactory::load('libraries', 'spamfilter'); $filter = CSpamFilter::getFilter(); $filter->setAuthor($my->getDisplayName()); $filter->setMessage($message); $filter->setEmail($my->email); $filter->setURL(CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id)); $filter->setType('message'); $filter->setIP($_SERVER['REMOTE_ADDR']); if ($filter->isSpam()) { $response->addAlert(JText::_('COM_COMMUNITY_WALLS_MARKED_SPAM')); return $response->sendResponse(); } } $wall = CWallLibrary::saveWall($uniqueId, $message, 'user', $my, $my->id == $user->id, 'profile,profile'); CFactory::load('libraries', 'activities'); CFactory::load('helpers', 'videos'); $matches = cGetVideoLinkMatches($message); $activityParams = ''; // We only want the first result of the video to be in the activity if ($matches) { $videoLink = $matches[0]; CFactory::load('libraries', 'videos'); $videoLib = new CVideoLibrary(); $provider = $videoLib->getProvider($videoLink); $activityParams .= 'videolink=' . $videoLink . "\r\n"; if ($provider->isValid()) { $activityParams .= 'url=' . $provider->getThumbnail(); } } $act = new stdClass(); $act->cmd = 'profile.wall.create'; $act->actor = $my->id; $act->target = $uniqueId; $act->title = JText::_('COM_COMMUNITY_ACTIVITIES_WALL_POST_PROFILE'); $act->content = ''; $act->app = 'walls'; $act->cid = $wall->id; // Allow comments on all these $act->comment_id = CActivities::COMMENT_SELF; $act->comment_type = 'walls'; CActivityStream::add($act, $activityParams); // @rule: Send notification to the profile user. if ($my->id != $user->id) { CFactory::load('libraries', 'notification'); $params = new CParameter(''); $params->set('url', 'index.php?option=com_community&view=profile&userid=' . $user->id); $params->set('message', $message); CNotificationLibrary::add('etype_profile_submit_wall', $my->id, $user->id, JText::sprintf('PLG_WALLS_NOTIFY_EMAIL_SUBJECT', $my->getDisplayName()), '', 'profile.wall', $params); } //add user points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('profile.wall.create'); $response->addScriptCall('joms.walls.insert', $wall->content); $response->addScriptCall('if(joms.jQuery(".content-nopost").length){ joms.jQuery("#wall-empty-container").remove(); }'); $cache =& JFactory::getCache('plgCommunityWalls'); $cache->remove($cache_id); $cache =& JFactory::getCache('plgCommunityWalls_fullview'); $cache->remove($cache_id); } return $response; }
/** * Ajax function to save a new wall entry * * @param message A message that is submitted by the user * @param uniqueId The unique id for this group * **/ function ajaxSaveWall($response, $message, $uniqueId, $cache_id = "") { $my = CFactory::getUser(); $user = CFactory::getUser($uniqueId); JPlugin::loadLanguage('plg_walls', JPATH_ADMINISTRATOR); // Load libraries CFactory::load('models', 'photos'); CFactory::load('libraries', 'wall'); CFactory::load('helpers', 'url'); CFactory::load('libraries', 'activities'); $message = JString::trim($message); $message = strip_tags($message); if (empty($message)) { $response->addAlert(JText::_('PLG_WALLS PLEASE ADD MESSAGE')); } else { $maxchar = $this->params->get('charlimit', 0); if (!empty($maxchar)) { $msglength = strlen($message); if ($msglength > $maxchar) { $message = substr($message, 0, $maxchar); } } $wall = CWallLibrary::saveWall($uniqueId, $message, 'user', $my, $my->id == $user->id, 'profile,profile'); CFactory::load('libraries', 'activities'); CFactory::load('helpers', 'videos'); $matches = cGetVideoLinkMatches($message); $activityParams = ''; // We only want the first result of the video to be in the activity if ($matches) { $videoLink = $matches[0]; CFactory::load('libraries', 'videos'); $videoLib = new CVideoLibrary(); $provider = $videoLib->getProvider($videoLink); $activityParams .= 'videolink=' . $videoLink . "\r\n"; if ($provider->isValid()) { $activityParams .= 'url=' . $provider->getThumbnail(); } } $act = new stdClass(); $act->cmd = 'profile.wall.create'; $act->actor = $my->id; $act->target = $uniqueId; $act->title = JText::_('CC ACTIVITIES WALL POST PROFILE'); $act->content = '{plugins,walls,getWallActivityContent}'; $act->app = 'walls'; $act->cid = $wall->id; CActivityStream::add($act, $activityParams); // @rule: Send notification to the profile user. if ($my->id != $user->id) { CFactory::load('libraries', 'notification'); $params = new JParameter(''); $params->set('url', 'index.php?option=com_community&view=profile&userid=' . $user->id); $params->set('message', $message); CNotificationLibrary::add('profile.submit.wall', $my->id, $user->id, JText::sprintf('PLG_WALLS NOTIFY EMAIL SUBJECT', $my->getDisplayName()), '', 'profile.wall', $params); } //add user points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('profile.wall.create'); $response->addScriptCall('joms.walls.insert', $wall->content); $response->addScriptCall('if(joms.jQuery(".content-nopost").length){ joms.jQuery("#wall-empty-container").remove(); }'); $cache =& JFactory::getCache('plgCommunityWalls'); $cache->remove($cache_id); $cache =& JFactory::getCache('plgCommunityWalls_fullview'); $cache->remove($cache_id); } return $response; }