Пример #1
0
 function onProfileStatusUpdate(&$userid, &$old_status, &$new_status)
 {
     JPlugin::loadLanguage('plg_statustowall', JPATH_ADMINISTRATOR);
     $my =& CFactory::getUser();
     $user =& CFactory::getUser($userid);
     include_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'wall.php';
     CWallLibrary::saveWall($userid, JText::sprintf('STATUS UPDATE', $new_status), 'user', $my, $my->id == $user->id);
 }
Пример #2
0
 /**
  * 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
  *
  * */
 public function ajaxSaveWall($message, $uniqueId, $appId = null, $photoId = 0)
 {
     $filter = JFilterInput::getInstance();
     $message = $filter->clean($message, 'string');
     $uniqueId = $filter->clean($uniqueId, 'int');
     $appId = $filter->clean($appId, 'int');
     $photoId = $filter->clean($photoId, 'int');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $json = array();
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $message = strip_tags($message);
     $photo = JTable::getInstance('Photo', 'CTable');
     $photo->load($uniqueId);
     $album = JTable::getInstance('Album', 'CTable');
     $album->load($photo->albumid);
     $handler = $this->_getHandler($album);
     if (!$handler->isWallsAllowed($photo->id)) {
         echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_POST_COMMENT');
         return;
     }
     // If the content is false, the message might be empty.
     if (empty($message) && $photoId == 0) {
         $json['error'] = JText::_('COM_COMMUNITY_WALL_EMPTY_MESSAGE');
     } else {
         // @rule: Spam checks
         if ($config->get('antispam_akismet_walls')) {
             $filter = CSpamFilter::getFilter();
             $filter->setAuthor($my->getDisplayName());
             $filter->setMessage($message);
             $filter->setEmail($my->email);
             $filter->setURL(CRoute::_('index.php?option=com_community&view=photos&task=photo&albumid=' . $photo->albumid) . '&photoid=' . $photo->id);
             $filter->setType('message');
             $filter->setIP($_SERVER['REMOTE_ADDR']);
             if ($filter->isSpam()) {
                 $json['error'] = JText::_('COM_COMMUNITY_WALLS_MARKED_SPAM');
                 die(json_encode($json));
             }
         }
         $wall = CWallLibrary::saveWall($uniqueId, $message, 'photos', $my, $my->id == $photo->creator, 'photos,photo', 'wall/content', 0, $photoId);
         $url = $photo->getRawPhotoURI();
         $param = new CParameter('');
         $param->set('photoid', $uniqueId);
         $param->set('action', 'wall');
         $param->set('wallid', $wall->id);
         $param->set('url', $url);
         // Get the album type
         $app = $album->type;
         // Add activity logging based on app's type
         $permission = $this->_getAppPremission($app, $album);
         /**
          * We don't need to check for permission to create activity
          * Activity will follow album privacy
          * @since 3.2
          */
         if ($app == 'user' || $app == 'group') {
             $group = JTable::getInstance('Group', 'CTable');
             $group->load($album->groupid);
             $event = null;
             $this->_addActivity('photos.wall.create', $my->id, 0, '', $message, 'photos.comment', $uniqueId, $group, $event, $param->toString(), $permission);
         }
         // Add notification
         $params = new CParameter('');
         $params->set('url', $photo->getRawPhotoURI());
         $params->set('message', CUserHelper::replaceAliasURL($message));
         $params->set('photo', JText::_('COM_COMMUNITY_SINGULAR_PHOTO'));
         $params->set('photo_url', $url);
         // @rule: Send notification to the photo owner.
         if ($my->id !== $photo->creator) {
             CNotificationLibrary::add('photos_submit_wall', $my->id, $photo->creator, JText::sprintf('COM_COMMUNITY_PHOTO_WALL_EMAIL_SUBJECT'), '', 'photos.wall', $params);
         } else {
             //for activity reply action
             //get relevent users in the activity
             $wallModel = CFactory::getModel('wall');
             $users = $wallModel->getAllPostUsers('photos', $photo->id, $photo->creator);
             if (!empty($users)) {
                 CNotificationLibrary::add('photos_reply_wall', $my->id, $users, JText::sprintf('COM_COMMUNITY_PHOTO_WALLREPLY_EMAIL_SUBJECT'), '', 'photos.wallreply', $params);
             }
         }
         //email and add notification if user are tagged
         $info = array('type' => 'image-comment', 'album_id' => $album->id, 'image_id' => $photo->id);
         CUserHelper::parseTaggedUserNotification($message, CFactory::getUser($photo->creator), $wall, $info);
         // Add user points
         CUserPoints::assignPoint('photos.wall.create');
         // Log user engagement
         CEngagement::log('photo.comment', $my->id);
         $json['success'] = true;
         $json['html'] = $wall->content;
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES));
     die(json_encode($json));
 }
Пример #3
0
        /**
         * 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;
        }
Пример #4
0
 public function ajaxUpdateWall($wallId, $message, $editableFunc, $photoId = 0)
 {
     $filter = JFilterInput::getInstance();
     $wallId = $filter->clean($wallId, 'int');
     $editableFunc = $filter->clean($editableFunc, 'string');
     $wall = JTable::getInstance('Wall', 'CTable');
     $wall->load($wallId);
     $objResponse = new JAXresponse();
     $json = array();
     if (empty($message)) {
         $json['error'] = JText::_('COM_COMMUNITY_EMPTY_MESSAGE');
         die(json_encode($json));
     }
     $isEditable = CWall::isEditable($editableFunc, $wall->id);
     if (!$isEditable) {
         $json['error'] = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_EDIT');
         die(json_encode($json));
     }
     // We don't want to touch the comments data.
     $comments = CComment::getRawCommentsData($wall->comment);
     $wall->comment = $message;
     $wall->comment .= $comments;
     $my = CFactory::getUser();
     $data = CWallLibrary::saveWall($wall->contentid, $wall->comment, $wall->type, $my, false, $editableFunc, 'wall/content', $wall->id, $photoId);
     $wall->originalComment = $wall->comment;
     $CComment = new CComment();
     $wall->comment = $CComment->stripCommentData($wall->comment);
     $wall->comment = CStringHelper::autoLink($wall->comment);
     $wall->comment = nl2br($wall->comment);
     $wall->comment = CUserHelper::replaceAliasURL($wall->comment);
     $wall->comment = CStringHelper::getEmoticon($wall->comment);
     $wall->comment = CStringHelper::converttagtolink($wall->comment);
     // convert to hashtag
     $json['success'] = true;
     $json['comment'] = $wall->comment;
     $json['originalComment'] = $wall->originalComment;
     die(json_encode($json));
 }
Пример #5
0
 /**
  * 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
  *
  **/
 public function ajaxSaveWall($message, $uniqueId)
 {
     $response = new JAXResponse();
     $my = CFactory::getUser();
     $filter = JFilterInput::getInstance();
     $message = $filter->clean($message, 'string');
     $uniqueId = $filter->clean($uniqueId, 'int');
     // Load necessary libraries
     CFactory::load('libraries', 'wall');
     CFactory::load('helpers', 'url');
     CFactory::load('libraries', 'activities');
     $model =& $this->getModel('events');
     $event =& JTable::getInstance('Event', 'CTable');
     $event->load($uniqueId);
     $message = strip_tags($message);
     // Only those who response YES/NO/MAYBE can write on wall
     $eventMembers =& JTable::getInstance('EventMembers', 'CTable');
     $eventMembers->load($my->id, $uniqueId);
     $allowedStatus = array(COMMUNITY_EVENT_STATUS_ATTEND, COMMUNITY_EVENT_STATUS_WONTATTEND, COMMUNITY_EVENT_STATUS_MAYBE);
     CFactory::load('helpers', 'owner');
     $config = CFactory::getConfig();
     if (!in_array($eventMembers->status, $allowedStatus) && !COwnerHelper::isCommunityAdmin() && $config->get('lockeventwalls') || $my->id == 0) {
         // Should not even be here unless use try to manipulate ajax call
         JError::raiseError(500, 'PERMISSION DENIED');
     }
     // If the content is false, the message might be empty.
     if (empty($message)) {
         $response->addAlert(JText::_('COM_COMMUNITY_EMPTY_MESSAGE'));
     } else {
         $isAdmin = $event->isAdmin($my->id);
         // @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=events&task=viewevent&eventid=' . $uniqueId));
             $filter->setType('message');
             $filter->setIP($_SERVER['REMOTE_ADDR']);
             if ($filter->isSpam()) {
                 $response->addAlert(JText::_('COM_COMMUNITY_WALLS_MARKED_SPAM'));
                 return $response->sendResponse();
             }
         }
         // Save the wall content
         $wall = CWallLibrary::saveWall($uniqueId, $message, 'events', $my, $isAdmin, 'events,events');
         $event->addWallCount();
         CFactory::load('helpers', 'event');
         $handler = CEventHelper::getHandler($event);
         if ($handler->isPublic()) {
             $actor = $my->id;
             $target = 0;
             $content = $message;
             $cid = $uniqueId;
             $app = 'events';
             $act = $handler->getActivity('events.wall.create', $actor, $target, $content, $cid, $app);
             $act->eventid = $event->id;
             $params = new CParameter('');
             $params->set('event_url', $handler->getFormattedLink('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false, true, false));
             $params->set('action', 'events.wall.create');
             $params->set('wallid', $wall->id);
             CFactory::load('libraries', 'activities');
             CActivityStream::add($act, $params->toString());
         }
         // @rule: Add user points
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('events.wall.create');
         $response->addScriptCall('joms.walls.insert', $wall->content);
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_EVENTS, COMMUNITY_CACHE_TAG_ACTIVITIES));
     return $response->sendResponse();
 }
Пример #6
0
 /**
  * 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
  * 
  **/
 public function ajaxSaveWall($message, $uniqueId, $appId = null)
 {
     $filter = JFilterInput::getInstance();
     $message = $filter->clean($message, 'string');
     $uniqueId = $filter->clean($uniqueId, 'int');
     $appId = $filter->clean($appId, 'int');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $response = new JAXResponse();
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $message = strip_tags($message);
     // Load libraries
     CFactory::load('models', 'photos');
     CFactory::load('libraries', 'wall');
     CFactory::load('helpers', 'url');
     CFactory::load('libraries', 'activities');
     CFactory::load('helpers', 'owner');
     CFactory::load('helpers', 'friends');
     CFactory::load('helpers', 'group');
     $photo =& JTable::getInstance('Photo', 'CTable');
     $photo->load($uniqueId);
     $album =& JTable::getInstance('Album', 'CTable');
     $album->load($photo->albumid);
     $handler = $this->_getHandler($album);
     if (!$handler->isWallsAllowed($photo->id)) {
         echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_POST_COMMENT');
         return;
     }
     // If the content is false, the message might be empty.
     if (empty($message)) {
         $response->addAlert(JText::_('COM_COMMUNITY_WALL_EMPTY_MESSAGE'));
     } else {
         // @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=photos&task=photo&albumid=' . $photo->albumid) . '#photoid=' . $photo->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, 'photos', $my, $my->id == $photo->creator, 'photos,photo');
         $url = $photo->getPhotoURI();
         $param = new CParameter('');
         $param->set('photoid', $uniqueId);
         $param->set('action', 'wall');
         $param->set('wallid', $wall->id);
         $param->set('url', $url);
         // Get the album type
         $app = $album->type;
         // Add activity logging based on app's type
         $permission = $this->_getAppPremission($app, $album);
         if ($app == 'user' && $permission == '0' || $app == 'user' && $permission == PRIVACY_PUBLIC) {
             $group = JTable::getInstance('Group', 'CTable');
             $group->load($album->groupid);
             $event = null;
             $this->_addActivity('photos.wall.create', $my->id, 0, JText::sprintf('COM_COMMUNITY_ACTIVITIES_WALL_POST_PHOTO', $url, $photo->caption), $message, 'photos', $uniqueId, $group, $event, $param->toString());
         }
         // @rule: Send notification to the photo owner.
         if ($my->id !== $photo->creator) {
             // Add notification
             CFactory::load('libraries', 'notification');
             $params = new CParameter('');
             $params->set('url', $url);
             $params->set('message', $message);
             CNotificationLibrary::add('etype_photos_submit_wall', $my->id, $photo->creator, JText::sprintf('COM_COMMUNITY_PHOTO_WALL_EMAIL_SUBJECT', $my->getDisplayName()), '', 'photos.wall', $params);
         }
         //add user points
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('photos.wall.create');
         $response->addScriptCall('joms.walls.insert', $wall->content);
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES));
     return $response->sendResponse();
 }
Пример #7
0
 /**
  * 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
  * 
  **/
 public function ajaxSaveWall($message, $uniqueId, $appId = null)
 {
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $response = new JAXResponse();
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $message = strip_tags($message);
     // Load libraries
     CFactory::load('models', 'photos');
     CFactory::load('libraries', 'wall');
     CFactory::load('helpers', 'url');
     CFactory::load('libraries', 'activities');
     CFactory::load('helpers', 'owner');
     CFactory::load('helpers', 'friends');
     CFactory::load('helpers', 'group');
     $photo =& JTable::getInstance('Photo', 'CTable');
     $photo->load($uniqueId);
     $album =& JTable::getInstance('Album', 'CTable');
     $album->load($photo->albumid);
     $handler = $this->_getHandler($album);
     if (!$handler->isWallsAllowed($photo->id)) {
         echo JText::_('CC NOT ALLOWED TO POST COMMENT');
         return;
     }
     // If the content is false, the message might be empty.
     if (empty($message)) {
         $response->addAlert(JText::_('CC EMPTY WALL MESSAGE'));
     } else {
         $wall = CWallLibrary::saveWall($uniqueId, $message, 'photos', $my, $my->id == $photo->creator, 'photos,photo');
         $url = $handler->getPhotoURI($photo->albumid, $photo->id, false);
         $param = new JParameter('');
         $param->set('photoid', $uniqueId);
         $param->set('action', 'wall');
         $param->set('wallid', $wall->id);
         $param->set('url', $url);
         /** HTGMOD **/
         // trigger plugin event when a comment is posted to a photo
         CFactory::load('libraries', 'apps');
         $appsLib =& CAppPlugins::getInstance();
         $appsLib->loadApplications();
         $params = array();
         $params[] = $uniqueId;
         $params[] = $message;
         $appsLib->triggerEvent('onPhotoComment', $params);
         /** END HTGMOD **/
         // Get the album type
         $app = $album->type;
         // Add activity logging based on app's type
         switch ($app) {
             case 'user':
                 $user = CFactory::getUser($album->creator);
                 $params = $user->getParams();
                 $permission = $params->get('privacyPhotoView');
                 break;
             case 'event':
             case 'group':
                 CFactory::load('models', 'group');
                 $group =& JTable::getInstance('Group', 'CTable');
                 $group->load($album->groupid);
                 $permission = $group->approvals;
                 break;
         }
         if ($app == 'user' && $permission == '0' || $app == 'user' && $permission == PRIVACY_PUBLIC || $app == 'group' && $permission == COMMUNITY_PUBLIC_GROUP) {
             $this->_addActivity('photos.wall.create', $my->id, 0, JText::sprintf('CC ACTIVITIES WALL POST PHOTO', $url, $photo->caption), $message, 'photos', $uniqueId, $param->toString());
         }
         // @rule: Send notification to the photo owner.
         if ($my->id !== $photo->creator) {
             // Add notification
             CFactory::load('libraries', 'notification');
             $params = new JParameter('');
             $params->set('url', $handler->getPhotoURI($photo->albumid, $photo->id, false));
             $params->set('message', $message);
             CNotificationLibrary::add('photos.submit.wall', $my->id, $photo->creator, JText::sprintf('CC PHOTO WALL EMAIL SUBJECT', $my->getDisplayName()), '', 'photos.wall', $params);
         }
         //add user points
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('photos.wall.create');
         $response->addScriptCall('joms.walls.insert', $wall->content);
     }
     return $response->sendResponse();
 }
Пример #8
0
 /**
  * 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
  *
  **/
 public function ajaxSaveWall($message, $uniqueId)
 {
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $response = new JAXResponse();
     $my = CFactory::getUser();
     $video = JTable::getInstance('Video', 'CTable');
     $video->load($uniqueId);
     // If the content is false, the message might be empty.
     if (empty($message)) {
         $response->addAlert(JText::_('CC EMPTY WALL MESSAGE'));
     } else {
         CFactory::load('libraries', 'wall');
         $wall = CWallLibrary::saveWall($uniqueId, $message, 'videos', $my, $my->id == $video->creator);
         // Add activity logging
         if ($video->isPublic()) {
             $url = $video->getViewUri(false);
             $params = new JParameter('');
             $params->set('videoid', $uniqueId);
             $params->set('action', 'wall');
             $params->set('wallid', $wall->id);
             $params->set('video_url', $url);
             $act = new stdClass();
             $act->cmd = 'videos.wall.create';
             $act->actor = $my->id;
             $act->target = 0;
             $act->title = JText::sprintf('CC ACTIVITIES WALL POST VIDEO', '{video_url}', $video->title);
             $act->app = 'videos';
             $act->cid = $uniqueId;
             $act->params = $params->toString();
             CFactory::load('libraries', 'activities');
             CActivityStream::add($act);
         }
         //add user points
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('videos.wall.create');
         $response->addScriptCall('joms.walls.insert', $wall->content);
     }
     return $response->sendResponse();
 }
Пример #9
0
 /**
  * @param $message    A message that is submitted by the user
  * @param $uniqueId    The unique id for this group
  * @param int $photoId
  */
 public function ajaxSaveWall($message, $uniqueId, $photoId = 0)
 {
     $filter = JFilterInput::getInstance();
     $uniqueId = $filter->clean($uniqueId, 'int');
     $photoId = $filter->clean($photoId, 'int');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $response = new JAXResponse();
     $json = array();
     $my = CFactory::getUser();
     $video = JTable::getInstance('Video', 'CTable');
     $video->load($uniqueId);
     // If the content is false, the message might be empty.
     if (empty($message) && $photoId == 0) {
         $json['error'] = JText::_('COM_COMMUNITY_WALL_EMPTY_MESSAGE');
     } else {
         $config = CFactory::getConfig();
         // @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=videos&task=video&videoid=' . $uniqueId));
             $filter->setType('message');
             $filter->setIP($_SERVER['REMOTE_ADDR']);
             if ($filter->isSpam()) {
                 $json['error'] = JText::_('COM_COMMUNITY_WALLS_MARKED_SPAM');
                 die(json_encode($json));
             }
         }
         //CFactory::load( 'libraries' , 'wall' );
         $wall = CWallLibrary::saveWall($uniqueId, $message, 'videos', $my, $my->id == $video->creator, 'videos,video', 'wall/content', 0, $photoId);
         // Add activity logging
         $url = $video->getViewUri(false);
         $params = new CParameter('');
         $params->set('videoid', $uniqueId);
         $params->set('action', 'wall');
         $params->set('wallid', $wall->id);
         $params->set('video_url', $url);
         $act = new stdClass();
         $act->cmd = 'videos.wall.create';
         $act->actor = $my->id;
         $act->access = $video->permissions;
         $act->target = 0;
         $act->title = JText::sprintf('COM_COMMUNITY_VIDEOS_ACTIVITIES_WALL_POST_VIDEO', '{video_url}', $video->title);
         $act->app = 'videos.comment';
         $act->cid = $uniqueId;
         $act->params = $params->toString();
         $act->groupid = $video->groupid;
         $act->eventid = $video->eventid;
         CActivityStream::add($act);
         // Add notification
         //CFactory::load( 'libraries' , 'notification' );
         $params = new CParameter('');
         $params->set('url', $url);
         $params->set('message', CUserHelper::replaceAliasURL($message));
         $params->set('video', $video->title);
         $params->set('video_url', $url);
         if ($my->id !== $video->creator) {
             CNotificationLibrary::add('videos_submit_wall', $my->id, $video->creator, JText::sprintf('COM_COMMUNITY_VIDEO_WALL_EMAIL_SUBJECT'), '', 'videos.wall', $params);
         } else {
             //for activity reply action
             //get relevent users in the activity
             $wallModel = CFactory::getModel('wall');
             $users = $wallModel->getAllPostUsers('videos', $video->id, $video->creator);
             if (!empty($users)) {
                 CNotificationLibrary::add('videos_reply_wall', $my->id, $users, JText::sprintf('COM_COMMUNITY_VIDEO_WALLREPLY_EMAIL_SUBJECT'), '', 'videos.wallreply', $params);
             }
         }
         //email and add notification if user are tagged
         $info = array('type' => 'video-comment', 'video_id' => $video->id);
         CUserHelper::parseTaggedUserNotification($message, CFactory::getUser($video->creator), $wall, $info);
         // Add user points
         CUserPoints::assignPoint('videos.comment');
         //@since 4.1 we dump the info into photo stats
         $statsModel = CFactory::getModel('stats');
         $statsModel->addVideoStats($video->id, 'comment');
         // Log user engagement
         CEngagement::log('video.comment', $my->id);
         $json['html'] = $wall->content;
         $json['success'] = true;
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES));
     die(json_encode($json));
 }
Пример #10
0
 /**
  * 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
  *
  **/
 public function ajaxSaveWall($message, $groupId)
 {
     $response = new JAXResponse();
     $my = CFactory::getUser();
     // Load necessary libraries
     CFactory::load('libraries', 'wall');
     CFactory::load('helpers', 'url');
     CFactory::load('libraries', 'activities');
     $groupModel = CFactory::getModel('groups');
     $group =& JTable::getInstance('Group', 'CTable');
     $group->load($groupId);
     $config = CFactory::getConfig();
     // @rule: If configuration is set for walls in group to be restricted to memebers only,
     // we need to respect this.
     if ($config->get('lockgroupwalls') && !$group->isMember($my->id)) {
         $response->addScriptCall('alert', JText::_('CC ACCESS FORBIDDEN'));
         return $response->sendResponse();
     }
     $message = strip_tags($message);
     // If the content is false, the message might be empty.
     if (empty($message)) {
         $response->addAlert(JText::_('CC EMPTY MESSAGE'));
     } else {
         $isAdmin = $groupModel->isAdmin($my->id, $group->id);
         // Save the wall content
         $wall = CWallLibrary::saveWall($groupId, $message, 'groups', $my, $isAdmin, 'groups,group');
         // Store event will update all stats count data
         $group->updateStats();
         $group->store();
         // @rule: only add the activities of the wall if the group is not private.
         if ($group->approvals == COMMUNITY_PUBLIC_GROUP) {
             $params = new JParameter('');
             $params->set('action', 'group.wall.create');
             $params->set('wallid', $wall->id);
             $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId);
             $act = new stdClass();
             $act->cmd = 'group.wall.create';
             $act->actor = $my->id;
             $act->target = 0;
             $act->title = JText::sprintf('CC ACTIVITIES WALL POST GROUP', '{group_url}', $group->name);
             $act->content = $message;
             $act->app = 'groups';
             $act->cid = $groupId;
             CActivityStream::add($act, $params->toString());
         }
         // @rule: Add user points
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('group.wall.create');
         // @rule: Send email notification to members
         $groupParams = $group->getParams();
         if ($groupParams->get('wallnotification') == '1') {
             $model =& $this->getModel('groups');
             $members = $model->getMembers($groupId, null);
             $admins = $model->getAdmins($groupId, null);
             $membersArray = array();
             foreach ($members as $row) {
                 if ($my->id != $row->id) {
                     $membersArray[] = $row->id;
                 }
             }
             foreach ($admins as $row) {
                 if ($my->id != $row->id) {
                     $membersArray[] = $row->id;
                 }
             }
             unset($members);
             unset($admins);
             // Add notification
             CFactory::load('libraries', 'notification');
             $params = new JParameter('');
             $params->set('url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId);
             $params->set('group', $group->name);
             $params->set('message', $message);
             CNotificationLibrary::add('groups.wall.create', $my->id, $membersArray, JText::sprintf('CC NEW WALL POST NOTIFICATION EMAIL SUBJECT', $my->getDisplayName(), $group->name), '', 'groups.wall', $params);
         }
         $response->addScriptCall('joms.walls.insert', $wall->content);
     }
     return $response->sendResponse();
 }
Пример #11
0
 /**
  * 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
  * @deprecated since 2.4
  *
  **/
 public function ajaxSaveWall($message, $groupId)
 {
     $filter = JFilterInput::getInstance();
     $message = $filter->clean($message, 'string');
     $groupId = $filter->clean($groupId, 'int');
     $response = new JAXResponse();
     $my = CFactory::getUser();
     // Load necessary libraries
     CFactory::load('libraries', 'wall');
     CFactory::load('helpers', 'url');
     CFactory::load('libraries', 'activities');
     $groupModel = CFactory::getModel('groups');
     $group =& JTable::getInstance('Group', 'CTable');
     $group->load($groupId);
     $config = CFactory::getConfig();
     // @rule: If configuration is set for walls in group to be restricted to memebers only,
     // we need to respect this.
     if (!$my->authorise('community.save', 'groups.wall.' . $groupId, $group)) {
         $response->addScriptCall('alert', JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN'));
         return $response->sendResponse();
     }
     $message = strip_tags($message);
     // If the content is false, the message might be empty.
     if (empty($message)) {
         $response->addAlert(JText::_('COM_COMMUNITY_EMPTY_MESSAGE'));
     } else {
         $isAdmin = $groupModel->isAdmin($my->id, $group->id);
         // @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=groups&task=viewgroup&groupid=' . $groupId));
             $filter->setType('message');
             $filter->setIP($_SERVER['REMOTE_ADDR']);
             if ($filter->isSpam()) {
                 $response->addAlert(JText::_('COM_COMMUNITY_WALLS_MARKED_SPAM'));
                 return $response->sendResponse();
             }
         }
         // Save the wall content
         $wall = CWallLibrary::saveWall($groupId, $message, 'groups', $my, $isAdmin, 'groups,group');
         // Store event will update all stats count data
         $group->updateStats();
         $group->store();
         // @rule: only add the activities of the wall if the group is not private.
         if ($group->approvals == COMMUNITY_PUBLIC_GROUP) {
             $params = new CParameter('');
             $params->set('action', 'group.wall.create');
             $params->set('wallid', $wall->id);
             $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId);
             $act = new stdClass();
             $act->cmd = 'group.wall.create';
             $act->actor = $my->id;
             $act->target = 0;
             $act->title = JText::sprintf('COM_COMMUNITY_GROUPS_WALL_POST_GROUP', '{group_url}', $group->name);
             $act->content = $message;
             $act->app = 'groups.wall';
             $act->cid = $wall->id;
             $act->groupid = $group->id;
             // Allow comments
             $act->comment_type = 'groups.wall';
             $act->comment_id = $wall->id;
             CActivityStream::add($act, $params->toString());
         }
         // @rule: Add user points
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('group.wall.create');
         // @rule: Send email notification to members
         $groupParams = $group->getParams();
         if ($groupParams->get('wallnotification') == '1') {
             $model =& $this->getModel('groups');
             $members = $model->getMembers($groupId, null);
             $admins = $model->getAdmins($groupId, null);
             $membersArray = array();
             foreach ($members as $row) {
                 if ($my->id != $row->id) {
                     $membersArray[] = $row->id;
                 }
             }
             foreach ($admins as $row) {
                 if ($my->id != $row->id) {
                     $membersArray[] = $row->id;
                 }
             }
             unset($members);
             unset($admins);
             // Add notification
             CFactory::load('libraries', 'notification');
             $params = new CParameter('');
             $params->set('url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId);
             $params->set('group', $group->name);
             $params->set('message', $message);
             CNotificationLibrary::add('etype_groups_wall_create', $my->id, $membersArray, JText::sprintf('COM_COMMUNITY_NEW_WALL_POST_NOTIFICATION_EMAIL_SUBJECT', $my->getDisplayName(), $group->name), '', 'groups.wall', $params);
         }
         $response->addScriptCall('joms.walls.insert', $wall->content);
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_GROUPS, COMMUNITY_CACHE_TAG_ACTIVITIES));
     return $response->sendResponse();
 }
Пример #12
0
 public function ajaxUpdateWall($wallId, $message, $editableFunc)
 {
     $wall =& JTable::getInstance('Wall', 'CTable');
     $wall->load($wallId);
     $objResponse = new JAXresponse();
     if (empty($message)) {
         $objResponse->addScriptCall('alert', JText::_('CC EMPTY MESSAGE'));
         return $objResponse->sendResponse();
     }
     CFactory::load('libraries', 'wall');
     $isEditable = CWall::isEditable($editableFunc, $wall->id);
     if (!$isEditable) {
         $objResponse->addAssign('cWindowContent', 'innerHTML', JText::_('CC NOT ALLOWED TO EDIT'));
         return $objResponse->sendResponse();
     }
     CFactory::load('libraries', 'comment');
     // We don't want to touch the comments data.
     $comments = CComment::getRawCommentsData($wall->comment);
     $wall->comment = $message;
     $wall->comment .= $comments;
     $my = CFactory::getUser();
     $data = CWallLibrary::saveWall($wall->contentid, $wall->comment, $wall->type, $my, false, $editableFunc, 'wall.content', $wall->id);
     $objResponse = new JAXResponse();
     $objResponse->addScriptCall('joms.walls.update', $wall->id, $data->content);
     return $objResponse->sendResponse();
 }
Пример #13
0
 public function ajaxUpdateWall($wallId, $message, $editableFunc)
 {
     $filter = JFilterInput::getInstance();
     $wallId = $filter->clean($wallId, 'int');
     $editableFunc = $filter->clean($editableFunc, 'string');
     $wall =& JTable::getInstance('Wall', 'CTable');
     $wall->load($wallId);
     $objResponse = new JAXresponse();
     if (empty($message)) {
         $objResponse->addScriptCall('alert', JText::_('COM_COMMUNITY_EMPTY_MESSAGE'));
         return $objResponse->sendResponse();
     }
     CFactory::load('libraries', 'wall');
     $isEditable = CWall::isEditable($editableFunc, $wall->id);
     if (!$isEditable) {
         $response->addScriptCall('cWindowAddContent', JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_EDIT'));
         return $objResponse->sendResponse();
     }
     CFactory::load('libraries', 'comment');
     // We don't want to touch the comments data.
     $comments = CComment::getRawCommentsData($wall->comment);
     $wall->comment = $message;
     $wall->comment .= $comments;
     $my = CFactory::getUser();
     $data = CWallLibrary::saveWall($wall->contentid, $wall->comment, $wall->type, $my, false, $editableFunc, 'wall.content', $wall->id);
     $objResponse = new JAXResponse();
     $objResponse->addScriptCall('joms.walls.update', $wall->id, $data->content);
     return $objResponse->sendResponse();
 }
Пример #14
0
        /**
         * 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;
        }