예제 #1
0
 /**
  * Maps a user status with JomSocial's user status
  *
  *	@param	Array	User values
  **/
 public function mapStatus($userId)
 {
     $result = $this->facebook->api('/me/statuses');
     $status = isset($result['data'][0]) ? $result['data'][0] : '';
     if (empty($status)) {
         return;
     }
     CFactory::load('helpers', 'linkgenerator');
     $connectModel = CFactory::getModel('Connect');
     $status = $status['message'];
     $rawStatus = $status;
     // @rule: Do not strip html tags but escape them.
     CFactory::load('helpers', 'string');
     $status = CStringHelper::escape($status);
     // @rule: Autolink hyperlinks
     $status = CLinkGeneratorHelper::replaceURL($status);
     // @rule: Autolink to users profile when message contains @username
     $status = CLinkGeneratorHelper::replaceAliasURL($status);
     // Reload $my from CUser so we can use some of the methods there.
     $my = CFactory::getUser($userId);
     $params = $my->getParams();
     // @rule: For existing statuses, do not set them.
     if ($connectModel->statusExists($status, $userId)) {
         return;
     }
     CFactory::load('libraries', 'activities');
     $act = new stdClass();
     $act->cmd = 'profile.status.update';
     $act->actor = $userId;
     $act->target = $userId;
     $act->title = '{actor} ' . $status;
     $act->content = '';
     $act->app = 'profile';
     $act->cid = $userId;
     $act->access = $params->get('privacyProfileView');
     $act->comment_id = CActivities::COMMENT_SELF;
     $act->comment_type = 'profile.status';
     $act->like_id = CActivities::LIKE_SELF;
     $act->like_type = 'profile.status';
     CActivityStream::add($act);
     //add user points
     CFactory::load('libraries', 'userpoints');
     CUserPoints::assignPoint('profile.status.update');
     // Update status from facebook.
     $my->setStatus($rawStatus);
 }
예제 #2
0
/**
 * Deprecated since 1.8
 * Use CLinkGeneratorHelper::replaceURL instead.
 */
function cGenerateURILinks($message)
{
    return CLinkGeneratorHelper::replaceURL($message);
}
예제 #3
0
 /**
  * Update the status of current user
  */
 public function ajaxUpdate($message = '')
 {
     $filter = JFilterInput::getInstance();
     $message = $filter->clean($message, 'string');
     $cache = CFactory::getFastCache();
     $cache->clean(array('activities'));
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $objResponse = new JAXResponse();
     //@rule: In case someone bypasses the status in the html, we enforce the character limit.
     $config = CFactory::getConfig();
     if (JString::strlen($message) > $config->get('statusmaxchar')) {
         $message = JHTML::_('string.truncate', $message, $config->get('statusmaxchar'));
     }
     //trim it here so that it wun go into activities stream.
     $message = JString::trim($message);
     $my = CFactory::getUser();
     $status = $this->getModel('status');
     // @rule: Spam checks
     if ($config->get('antispam_akismet_status')) {
         //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=' . $my->id));
         $filter->setType('message');
         $filter->setIP($_SERVER['REMOTE_ADDR']);
         if ($filter->isSpam()) {
             $objResponse->addAlert(JText::_('COM_COMMUNITY_STATUS_MARKED_SPAM'));
             return $objResponse->sendResponse();
         }
     }
     $status->update($my->id, $message);
     //set user status for current session.
     $today = JFactory::getDate();
     $message2 = empty($message) ? ' ' : $message;
     $my->set('_status', $message2);
     $my->set('_posted_on', $today->toSql());
     $profileid = $jinput->get->get('userid', 0, 'INT');
     //JRequest::getVar('userid' , 0 , 'GET');
     if (COwnerHelper::isMine($my->id, $profileid)) {
         $objResponse->addScriptCall("joms.jQuery('#profile-status span#profile-status-message').html('" . addslashes($message) . "');");
     }
     //CFactory::load( 'helpers' , 'string' );
     // $message		= CStringHelper::escape( $message );
     if (!empty($message)) {
         $act = new stdClass();
         $act->cmd = 'profile.status.update';
         $act->actor = $my->id;
         $act->target = $my->id;
         //CFactory::load( 'helpers' , 'linkgenerator' );
         // @rule: Autolink hyperlinks
         $message = CLinkGeneratorHelper::replaceURL($message);
         // @rule: Autolink to users profile when message contains @username
         $message = CUserHelper::replaceAliasURL($message);
         $privacyParams = $my->getParams();
         $act->title = $message;
         $act->content = '';
         $act->app = 'profile';
         $act->cid = $my->id;
         $act->access = $privacyParams->get('privacyProfileView');
         $act->comment_id = CActivities::COMMENT_SELF;
         $act->comment_type = 'profile.status';
         $act->like_id = CActivities::LIKE_SELF;
         $act->like_type = 'profile.status';
         //add user points
         //CFactory::load( 'libraries' , 'userpoints' );
         if (CUserPoints::assignPoint('profile.status.update')) {
             //only assign act if user points is set to true
             CActivityStream::add($act);
         }
         //now we need to reload the activities streams (since some report regarding update status from hello me we disabled update the stream, cuz hellome usually called  out from jomsocial page)
         $friendsModel = CFactory::getModel('friends');
         $memberSince = CTimeHelper::getDate($my->registerDate);
         $friendIds = $friendsModel->getFriendIds($my->id);
         //include_once(JPATH_COMPONENT .'/libraries/activities.php');
         $act = new CActivityStream();
         $params = $my->getParams();
         $limit = !empty($params) ? $params->get('activityLimit', '') : '';
         //$html	= $act->getHTML($my->id, $friendIds, $memberSince, $limit );
         $status = $my->getStatus();
         $status = str_replace(array("\r\n", "\n", "\r"), "", $status);
         $status = addslashes($status);
         // also update hellome module if available
         $script = "joms.jQuery('.joms-js--mod-hellome-label').html('" . $status . "');";
         $script .= "joms.jQuery('.joms-js--mod-hellome-loading').hide();";
         $objResponse->addScriptCall($script);
     }
     return $objResponse->sendResponse();
 }
예제 #4
0
파일: twitter.php 프로젝트: bizanto/Hooked
        function _getTwitterHTML($userId)
        {
            $this->loadUserParams();
            $my = CFactory::getUser($userId);
            $this->userparams = $my->getAppParams($this->_name);
            $showFriends = $this->userparams->get('showFriends', false);
            $oauth =& JTable::getInstance('Oauth', 'CTable');
            $loaded = $oauth->load($my->id, 'twitter');
            ob_start();
            if ($loaded && !is_null($oauth->accesstoken) && !empty($oauth->accesstoken)) {
                $count = $this->userparams->get('count', 5);
                $accessToken = unserialize($oauth->accesstoken);
                $client = $accessToken->getHttpClient(plgCommunityTwitter::getConfiguration());
                $timeline = $showFriends ? 'home' : 'user';
                $client->setUri($this->timelines[$timeline]);
                $client->setMethod(Zend_Http_Client::GET);
                $client->setParameterGet('count', $count);
                if ($showFriends) {
                    $client->setParameterGet('id', $accessToken->getParam('screen_name'));
                }
                $response = $client->request();
                $data = Zend_Json::decode($response->getBody(), Zend_Json::TYPE_OBJECT);
                $client->setUri($this->users['show']);
                $client->setMethod(Zend_Http_Client::GET);
                $client->setParameterGet('screen_name', $accessToken->getParam('screen_name'));
                $response = $client->request();
                $userinfo = Zend_Json::decode($response->getBody(), Zend_Json::TYPE_OBJECT);
                if (!$userinfo) {
                    ?>
				<div><?php 
                    echo JText::_('PLG_TWITTER UNABLE TO CONTACT SERVER');
                    ?>
</div>
			<?php 
                } else {
                    ?>
				<div id="application-twitter">
            		<ul>
           				<li>
							<!-- start twitter avatar-->
							<div class="twitter-user-avatar">
								<a href="http://twitter.com/<?php 
                    echo $userinfo->screen_name;
                    ?>
" target="blank"><img class="avatar" src="<?php 
                    echo $userinfo->profile_image_url;
                    ?>
" alt="<?php 
                    echo $userinfo->screen_name;
                    ?>
"/></a>
							</div>
							<!--end twitter avatar-->
							<!--start twitter post-->
							<div class="twitter-user-detail">
	                            <a href="http://twitter.com/<?php 
                    echo $userinfo->screen_name;
                    ?>
" target="blank"><strong><?php 
                    echo $userinfo->name;
                    ?>
</strong></a>
	                            <br />
								<i class="small">
	                                <?php 
                    echo $userinfo->statuses_count;
                    ?>
 tweets, <?php 
                    echo $userinfo->followers_count;
                    ?>
 followers
	                            </i>
			  				    <div class="small"><?php 
                    echo $userinfo->description;
                    ?>
</div>

			  				</div>
			  				<!--end twitter post-->
		  				</li>
	            		<?php 
                    if (is_object($data)) {
                        if (isset($data->error)) {
                            echo $data->error;
                        }
                    } else {
                        CFactory::load('helpers', 'linkgenerator');
                        for ($i = 0; $i < count($data); $i++) {
                            $tweet =& $data[$i];
                            $date = JFactory::getDate($tweet->created_at);
                            $text = CLinkGeneratorHelper::replaceURL($tweet->text, true, true);
                            $text = $this->replaceAliasURL($text);
                            ?>
								<li>
									<?php 
                            if ($i == 0 && $showFriends || $showFriends) {
                                ?>
									<!--twitter avatar-->
									<div class="twitter-avatar">
									<a href="http://twitter.com/<?php 
                                echo $tweet->user->screen_name;
                                ?>
" target="blank">
										<img width="23" height="23" class="avatar" src="<?php 
                                echo $tweet->user->profile_image_url;
                                ?>
" alt="<?php 
                                echo $tweet->user->screen_name;
                                ?>
"/>
									</a>
									</div>
									<!--twitter avatar-->
									<?php 
                            }
                            ?>
									<!--twitter post-->
									<div class="twitter-post">
					  				    <?php 
                            echo $text;
                            ?>
					  				</div>
				  					<div class="clr"></div>
				  					<!--twitter avatar-->
				  					<div class="small"><?php 
                            echo $date->toFormat(JText::_('DATE_FORMAT_LC2'));
                            ?>
</div>
				  				</li>
		                    <?php 
                        }
                    }
                    ?>
	            </ul>
	            </div>
	            <div class="clr"></div>
            <?php 
                }
            } else {
                ?>
	            <div class="icon-nopost">
	                <img src="<?php 
                echo JURI::base();
                ?>
components/com_community/assets/error.gif" alt="" />
	            </div>
	            <div class="content-nopost">
	                <?php 
                echo JText::_('PLG_TWITTER NOT UPDATES');
                ?>
	            </div>
            <?php 
            }
            $html = ob_get_contents();
            ob_end_clean();
            return $html;
        }
예제 #5
0
        protected function _getTwitterHTML($userId)
        {
            $this->loadUserParams();
            $my = CFactory::getUser($userId);
            $this->userparams = $my->getAppParams($this->_name);
            $showFriends = $this->userparams->get('showFriends', false);
            $oauth = JTable::getInstance('Oauth', 'CTable');
            $loaded = $oauth->load($my->id, 'twitter');
            $accesstoken = unserialize($oauth->accesstoken);
            ob_start();
            if ($loaded && !is_null($accesstoken) && !empty($accesstoken)) {
                $client = new tmhOAuth(self::getConfiguration());
                $timeline = $showFriends ? 'home' : 'user';
                $count = $this->userparams->get('count', 5);
                //echo $timeline;die();
                // get user info/
                $code = $client->request('GET', $client->url($this->users['show']), array('screen_name' => $accesstoken['screen_name']));
                if ($code == 200) {
                    $userinfo = json_decode($client->response['response']);
                    // get tweets
                    $code = $client->request('GET', $client->url($this->timelines[$timeline]), array('count' => $count, 'screen_name' => $userinfo->screen_name));
                    if ($code == 200) {
                        $data = json_decode($client->response['response']);
                    } else {
                        $data = null;
                    }
                } else {
                    $userinfo = null;
                }
                if (!$userinfo) {
                    ?>
                    <div><?php 
                    echo JText::_('PLG_TWITTER_UNABLE_TO_CONTACT_SERVER');
                    ?>
</div>
                    <?php 
                } else {
                    ?>
                    <div id="application-twitter">

                            <div class="joms-stream__header">
                                <div class="joms-avatar--stream">
                                    <a href="http://twitter.com/<?php 
                    echo $userinfo->screen_name;
                    ?>
" target="blank" class="joms-avatar">
                                    <img src="<?php 
                    echo $userinfo->profile_image_url;
                    ?>
" alt="<?php 
                    echo $userinfo->screen_name;
                    ?>
"/>
                                    </a>
                                </div>
                                <!--start twitter post-->
                                <div class="joms-stream__meta ">
                                    <a href="http://twitter.com/<?php 
                    echo $userinfo->screen_name;
                    ?>
" target="blank" class="cThumb-Title"><?php 
                    echo $userinfo->name;
                    ?>
</a>
                                    <span class="joms-block"><?php 
                    echo $userinfo->statuses_count;
                    ?>
 tweets, <?php 
                    echo $userinfo->followers_count;
                    ?>
 followers</span>
                                    <small><?php 
                    echo $userinfo->description;
                    ?>
</small>
                                </div>
                                <!--end twitter post-->
                            </div>
                            <div class="joms-gap"></div>
                            <?php 
                    if (is_object($data)) {
                        if (isset($data->error)) {
                            echo $data->error;
                        }
                    } else {
                        //CFactory::load( 'helpers' , 'linkgenerator' );
                        for ($i = 0; $i < count($data); $i++) {
                            $tweet = $data[$i];
                            //$date   = cGetDate($tweet->created_at); //JFactory::getDate( $tweet->created_at );
                            $date = CTimeHelper::getDate($tweet->created_at);
                            $text = CLinkGeneratorHelper::replaceURL($tweet->text, true, true);
                            $text = $this->replaceAliasURL($text);
                            ?>
                                    <div class="joms-stream__header">
                                        <?php 
                            if ($i == 0 && $showFriends || $showFriends) {
                                ?>
                                            <div class="joms-avatar--stream">
                                                <a href="http://twitter.com/<?php 
                                echo $tweet->user->screen_name;
                                ?>
" target="blank" ><img src="<?php 
                                echo $tweet->user->profile_image_url;
                                ?>
" alt="<?php 
                                echo $tweet->user->screen_name;
                                ?>
"></a>
                                            </div>
                                        <?php 
                            }
                            ?>
                                        <div class="joms-stream__meta">
                                            <?php 
                            echo CStringHelper::formatLinks($text);
                            ?>
                                            <div class="small joms-text--light"><?php 
                            echo $date->format(JText::_('DATE_FORMAT_LC2'));
                            ?>
</div>
                                        </div>
                                        <!--twitter avatar-->
                                    </div>
                                    <div class="joms-gap"></div>
                                    <?php 
                        }
                    }
                    ?>

                    </div>

                    <?php 
                }
            } else {
                ?>
                <!-- <div class="icon-nopost">
                        <img src="<?php 
                echo JURI::base();
                ?>
components/com_community/assets/error.gif" alt="" />
                </div> -->
                <div class="content-nopost">
                    <?php 
                echo JText::_('PLG_TWITTER_NOT_UPDATES');
                ?>
                </div>
                <?php 
            }
            $html = ob_get_contents();
            ob_end_clean();
            return $html;
        }
예제 #6
0
 /**
  * Return formatted comment given the wall item
  */
 public static function formatComment($wall)
 {
     CFactory::load('helpers', 'owner');
     $my = CFactory::getUser();
     // Save processing time
     if (!$wall->comment) {
         return '';
     }
     // strip out the comment data
     CFactory::load('libraries', 'comment');
     $wall->comment = CComment::stripCommentData($wall->comment);
     // Need to perform basic formatting here
     // 1. support nl to br,
     // 2. auto-link text
     CFactory::load('helpers', 'linkgenerator');
     $wall->comment = CTemplate::escape($wall->comment);
     $wall->comment = CLinkGeneratorHelper::replaceURL($wall->comment);
     $wall->comment = nl2br($wall->comment);
     CFactory::load('helpers', 'time');
     $user = CFactory::getUser($wall->post_by);
     $commentsHTML = '';
     $commentsHTML .= '<div class="cComment wall-coc-item" id="wall-' . $wall->id . '"><a href="' . CUrlHelper::userLink($user->id) . '"><img src="' . $user->getThumbAvatar() . '" alt="" class="wall-coc-avatar" /></a>';
     $date = new JDate($wall->date);
     $commentsHTML .= '<a class="wall-coc-author" href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a> ';
     $commentsHTML .= $wall->comment;
     $commentsHTML .= '<span class="wall-coc-time">' . CTimeHelper::timeLapse($date);
     // Only site admin, or wall author can remove it
     // @todo: the target stream activity should also be able to delete it
     if (COwnerHelper::isCommunityAdmin() || $my->id == $wall->post_by) {
         $commentsHTML .= ' <span class="wall-coc-remove-link">&#x2022; <a onclick="joms.miniwall.remove(' . $wall->id . ');" href="#removeThisComment">' . JText::_('COM_COMMUNITY_WALL_REMOVE') . '</a></span>';
     }
     $commentsHTML .= '</span>';
     $commentsHTML .= '</div>';
     return $commentsHTML;
 }
예제 #7
0
 /**
  * Return current user status
  * @return	string	user status
  */
 public function getStatus($rawFormat = false)
 {
     jimport('joomla.filesystem.file');
     // @rule: If user requested for a raw format, we should pass back the raw status.
     $statusmodel = CFactory::getModel('status');
     $statusmodel = $statusmodel->get($this->_userid);
     $status = $statusmodel->status;
     if ($rawFormat) {
         return $status;
     }
     // @rule: We need to escape any unwanted stuffs here before proceeding.
     CFactory::load('helpers', 'string');
     $status = CStringHelper::escape($status);
     if (JFile::Exists(CPluginHelper::getPluginURI('community', 'wordfilter') . DS . 'wordfilter.php') && JPluginHelper::isEnabled('community', 'wordfilter')) {
         require_once CPluginHelper::getPluginURI('community', 'wordfilter') . DS . 'wordfilter.php';
         if (class_exists('plgCommunityWordfilter')) {
             $dispatcher =& JDispatcher::getInstance();
             $plugin =& JPluginHelper::getPlugin('community', 'wordfilter');
             $instance = new plgCommunityWordfilter($dispatcher, (array) $plugin);
         }
         $status = $instance->_censor($status);
     }
     // @rule: Create proper line breaks.
     $status = CStringHelper::nl2br($status);
     // @rule: Auto link statuses
     CFactory::load('helpers', 'linkgenerator');
     $status = CLinkGeneratorHelper::replaceURL($status);
     return $status;
 }
예제 #8
0
파일: status.php 프로젝트: bizanto/Hooked
 /**
  * Update the status of current user
  */
 public function ajaxUpdate($message = '')
 {
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $mainframe =& JFactory::getApplication();
     $objResponse = new JAXResponse();
     //@rule: In case someone bypasses the status in the html, we enforce the character limit.
     $config = CFactory::getConfig();
     if (JString::strlen($message) > $config->get('statusmaxchar')) {
         $message = JString::substr($message, 0, $config->get('statusmaxchar'));
     }
     //trim it here so that it wun go into activities stream.
     $message = JString::trim($message);
     $my = CFactory::getUser();
     $status =& $this->getModel('status');
     $status->update($my->id, $message);
     //set user status for current session.
     $today =& JFactory::getDate();
     $message2 = empty($message) ? ' ' : $message;
     $my->set('_status', $message2);
     $my->set('_posted_on', $today->toMySQL());
     $profileid = JRequest::getVar('userid', 0, 'GET');
     if (COwnerHelper::isMine($my->id, $profileid)) {
         $objResponse->addScriptCall("joms.jQuery('#profile-status span#profile-status-message').html('" . addslashes($message) . "');");
     }
     CFactory::load('helpers', 'string');
     $message = CStringHelper::escape($message);
     if (!empty($message)) {
         $act = new stdClass();
         $act->cmd = 'profile.status.update';
         $act->actor = $my->id;
         $act->target = $my->id;
         CFactory::load('helpers', 'linkgenerator');
         // @rule: Autolink hyperlinks
         $message = CLinkGeneratorHelper::replaceURL($message);
         // @rule: Autolink to users profile when message contains @username
         $message = CLinkGeneratorHelper::replaceAliasURL($message);
         $privacyParams = $my->getParams();
         $act->title = '{actor} ' . $message;
         $act->content = '';
         $act->app = 'profile';
         $act->cid = $my->id;
         $act->access = $privacyParams->get('privacyProfileView');
         CFactory::load('libraries', 'activities');
         CActivityStream::add($act);
         //add user points
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('profile.status.update');
         //now we need to reload the activities streams
         $friendsModel = CFactory::getModel('friends');
         $memberSince = CTimeHelper::getDate($my->registerDate);
         $friendIds = $friendsModel->getFriendIds($my->id);
         include_once JPATH_COMPONENT . DS . 'libraries' . DS . 'activities.php';
         $act = new CActivityStream();
         $params =& $my->getParams();
         $limit = !empty($params) ? $params->get('activityLimit', '') : '';
         $html = $act->getHTML($my->id, $friendIds, $memberSince, $limit);
         $status = $my->getStatus();
         $status = addslashes($status);
         $objResponse->addScriptCall("joms.jQuery('#profile-status-message').html('" . $status . "');");
         $objResponse->addScriptCall("joms.jQuery('title').val('" . $status . "');");
         $objResponse->addAssign('activity-stream-container', 'innerHTML', $html);
     }
     return $objResponse->sendResponse();
 }
예제 #9
0
 /**
  * Called by status box to add new stream data
  * 
  * @param type $message
  * @param type $attachment
  * @return type 
  */
 public function ajaxStreamAdd($message, $attachment)
 {
     //$filter = JFilterInput::getInstance();
     //$message = $filter->clean($message, 'string');
     $streamHTML = '';
     // $attachment pending filter
     $cache = CFactory::getFastCache();
     $cache->clean(array('activities'));
     $my = CFactory::getUser();
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     CFactory::load('libraries', 'activities');
     CFactory::load('libraries', 'userpoints');
     CFactory::load('helpers', 'linkgenerator');
     CFactory::load('libraries', 'notification');
     //@rule: In case someone bypasses the status in the html, we enforce the character limit.
     $config = CFactory::getConfig();
     if (JString::strlen($message) > $config->get('statusmaxchar')) {
         $message = JString::substr($message, 0, $config->get('statusmaxchar'));
     }
     $message = JString::trim($message);
     //$message	= CStringHelper::escape($message);
     //$inputFilter = CFactory::getInputFilter(true);
     //$message = $inputFilter->clean($message);
     $objResponse = new JAXResponse();
     $rawMessage = $message;
     // @rule: Autolink hyperlinks
     $message = CLinkGeneratorHelper::replaceURL($message);
     // @rule: Autolink to users profile when message contains @username
     $message = CLinkGeneratorHelper::replaceAliasURL($message);
     // @rule: Spam checks
     if ($config->get('antispam_akismet_status')) {
         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=' . $my->id));
         $filter->setType('message');
         $filter->setIP($_SERVER['REMOTE_ADDR']);
         if ($filter->isSpam()) {
             $objResponse->addAlert(JText::_('COM_COMMUNITY_STATUS_MARKED_SPAM'));
             return $objResponse->sendResponse();
         }
     }
     $attachment = json_decode($attachment, true);
     //respect wall setting before adding activity
     CFactory::load('helpers', 'friends');
     CFactory::load('helper', 'owner');
     //$objResponse->addScriptCall("alert('permission denied');");
     //return $objResponse->sendResponse();
     /*
     		$attachment['type'] = The content type, message/videos/photos/events
     		$attachment['element'] = The owner, profile, groups,events
     */
     switch ($attachment['type']) {
         case "message":
             if (!empty($message)) {
                 switch ($attachment['element']) {
                     case 'profile':
                         //only update user status if share messgage is on his profile
                         if (COwnerHelper::isMine($my->id, $attachment['target'])) {
                             //save the message
                             $status =& $this->getModel('status');
                             $status->update($my->id, $rawMessage, $attachment['privacy']);
                             //set user status for current session.
                             $today =& JFactory::getDate();
                             $message2 = empty($message) ? ' ' : $message;
                             $my->set('_status', $rawMessage);
                             $my->set('_posted_on', $today->toMySQL());
                             // Order of replacement
                             $order = array("\r\n", "\n", "\r");
                             $replace = '<br />';
                             // Processes \r\n's first so they aren't converted twice.
                             $messageDisplay = str_replace($order, $replace, $message);
                             $messageDisplay = CKses::kses($messageDisplay, CKses::allowed());
                             //update user status
                             $objResponse->addScriptCall("joms.jQuery('#profile-status span#profile-status-message').html('" . addslashes($messageDisplay) . "');");
                         }
                         //push to activity stream
                         $privacyParams = $my->getParams();
                         $act = new stdClass();
                         $act->cmd = 'profile.status.update';
                         $act->actor = $my->id;
                         $act->target = $attachment['target'];
                         $act->title = $message;
                         $act->content = '';
                         $act->app = $attachment['element'];
                         $act->cid = $my->id;
                         $act->access = $attachment['privacy'];
                         $act->comment_id = CActivities::COMMENT_SELF;
                         $act->comment_type = 'profile.status';
                         $act->like_id = CActivities::LIKE_SELF;
                         $act->like_type = 'profile.status';
                         CActivityStream::add($act);
                         CUserPoints::assignPoint('profile.status.update');
                         $recipient = CFactory::getUser($attachment['target']);
                         $params = new CParameter('');
                         $params->set('actorName', $my->getDisplayName());
                         $params->set('recipientName', $recipient->getDisplayName());
                         $params->set('url', CUrlHelper::userLink($act->target, false));
                         $params->set('message', $message);
                         CNotificationLibrary::add('etype_profile_status_update', $my->id, $attachment['target'], JText::sprintf('COM_COMMUNITY_FRIEND_WALL_POST', $my->getDisplayName()), '', 'wall.post', $params);
                         break;
                         // Message posted from Group page
                     // Message posted from Group page
                     case 'groups':
                         CFactory::load('libraries', 'groups');
                         $groupLib = new CGroups();
                         $group = JTable::getInstance('Group', 'CTable');
                         $group->load($attachment['target']);
                         // Permission check, only site admin and those who has
                         // mark their attendance can post message
                         if (!COwnerHelper::isCommunityAdmin() && !$group->isMember($my->id)) {
                             $objResponse->addScriptCall("alert('permission denied');");
                             return $objResponse->sendResponse();
                         }
                         $act = new stdClass();
                         $act->cmd = 'groups.wall';
                         $act->actor = $my->id;
                         $act->target = 0;
                         $act->title = $message;
                         $act->content = '';
                         $act->app = 'groups.wall';
                         $act->cid = $attachment['target'];
                         $act->groupid = $group->id;
                         $act->group_access = $group->approvals;
                         $act->eventid = 0;
                         $act->access = 0;
                         $act->comment_id = CActivities::COMMENT_SELF;
                         $act->comment_type = 'groups.wall';
                         $act->like_id = CActivities::LIKE_SELF;
                         $act->like_type = 'groups.wall';
                         CActivityStream::add($act);
                         CUserPoints::assignPoint('profile.status.update');
                         $recipient = CFactory::getUser($attachment['target']);
                         $params = new CParameter('');
                         $params->set('message', $message);
                         $params->set('group', $group->name);
                         $params->set('url', CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id, false));
                         //Get group member emails
                         $model = CFactory::getModel('Groups');
                         $members = $model->getMembers($attachment['target'], null);
                         $membersArray = array();
                         if (!is_null($members)) {
                             foreach ($members as $row) {
                                 if ($my->id != $row->id) {
                                     $membersArray[] = $row->id;
                                 }
                             }
                         }
                         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);
                         // Add custom stream
                         // Reload the stream with new stream data
                         $streamHTML = $groupLib->getStreamHTML($group);
                         break;
                         // Message posted from Event page
                     // Message posted from Event page
                     case 'events':
                         CFactory::load('libraries', 'events');
                         $eventLib = new CEvents();
                         $event = JTable::getInstance('Event', 'CTable');
                         $event->load($attachment['target']);
                         // Permission check, only site admin and those who has
                         // mark their attendance can post message
                         if (!COwnerHelper::isCommunityAdmin() && !$event->isMember($my->id)) {
                             $objResponse->addScriptCall("alert('permission denied');");
                             return $objResponse->sendResponse();
                         }
                         // If this is a group event, set the group object
                         $groupid = $event->type == 'group' ? $event->contentid : 0;
                         CFactory::load('libraries', 'groups');
                         $groupLib = new CGroups();
                         $group = JTable::getInstance('Group', 'CTable');
                         $group->load($groupid);
                         $act = new stdClass();
                         $act->cmd = 'events.wall';
                         $act->actor = $my->id;
                         $act->target = 0;
                         $act->title = $message;
                         $act->content = '';
                         $act->app = 'events.wall';
                         $act->cid = $attachment['target'];
                         $act->groupid = $event->type == 'group' ? $event->contentid : 0;
                         $act->group_access = $group->approvals;
                         $act->eventid = $event->id;
                         $act->event_access = $event->permission;
                         $act->access = 0;
                         $act->comment_id = CActivities::COMMENT_SELF;
                         $act->comment_type = 'events.wall';
                         $act->like_id = CActivities::LIKE_SELF;
                         $act->like_type = 'events.wall';
                         CActivityStream::add($act);
                         // Reload the stream with new stream data
                         $streamHTML = $eventLib->getStreamHTML($event);
                         break;
                 }
                 $objResponse->addScriptCall('__callback', '');
             }
             break;
         case "photo":
             switch ($attachment['element']) {
                 case 'profile':
                     $photoId = $attachment['id'];
                     $privacy = $attachment['privacy'];
                     $photo = JTable::getInstance('Photo', 'CTable');
                     $photo->load($photoId);
                     $photo->caption = $message;
                     $photo->permissions = $privacy;
                     $photo->published = 1;
                     $photo->status = 'ready';
                     $photo->store();
                     // Trigger onPhotoCreate
                     CFactory::load('libraries', 'apps');
                     $apps =& CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $params = array();
                     $params[] =& $photo;
                     $apps->triggerEvent('onPhotoCreate', $params);
                     $album = JTable::getInstance('Album', 'CTable');
                     $album->load($photo->albumid);
                     $act = new stdClass();
                     $act->cmd = 'photo.upload';
                     $act->actor = $my->id;
                     $act->access = $attachment['privacy'];
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->title = $message;
                     //JText::sprintf('COM_COMMUNITY_ACTIVITIES_UPLOAD_PHOTO' , '{photo_url}', $album->name );
                     $act->content = '';
                     // Generated automatically by stream. No need to add anything
                     $act->app = 'photos';
                     $act->cid = $album->id;
                     $act->location = $album->location;
                     /* Comment and like for individual photo upload is linked
                      * to the photos itsel
                      */
                     $act->comment_id = $photo->id;
                     //CActivities::COMMENT_SELF;
                     $act->comment_type = 'photos';
                     $act->like_id = $photo->id;
                     //CActivities::LIKE_SELF;
                     $act->like_type = 'photo';
                     // like type is 'photo' not 'photos'
                     $albumUrl = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $my->id;
                     $albumUrl = CRoute::_($albumUrl);
                     $photoUrl = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id . '&userid=' . $photo->creator . '#photoid=' . $photo->id;
                     $photoUrl = CRoute::_($photoUrl);
                     $params = new CParameter('');
                     $params->set('multiUrl', $albumUrl);
                     $params->set('photoid', $photo->id);
                     $params->set('action', 'upload');
                     $params->set('stream', '1');
                     // this photo uploaded from status stream
                     $params->set('photo_url', $photoUrl);
                     // Add activity logging
                     CFactory::load('libraries', 'activities');
                     CActivityStream::add($act, $params->toString());
                     // Add user points
                     CFactory::load('libraries', 'userpoints');
                     CUserPoints::assignPoint('photo.upload');
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                     break;
                 case 'groups':
                     CFactory::load('libraries', 'groups');
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($attachment['target']);
                     $photoId = $attachment['id'];
                     $privacy = $group->approvals ? PRIVACY_GROUP_PRIVATE_ITEM : 0;
                     $photo = JTable::getInstance('Photo', 'CTable');
                     $photo->load($photoId);
                     $photo->caption = $message;
                     $photo->permissions = $privacy;
                     $photo->published = 1;
                     $photo->status = 'ready';
                     $photo->store();
                     // Trigger onPhotoCreate
                     CFactory::load('libraries', 'apps');
                     $apps =& CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $params = array();
                     $params[] =& $photo;
                     $apps->triggerEvent('onPhotoCreate', $params);
                     $album = JTable::getInstance('Album', 'CTable');
                     $album->load($photo->albumid);
                     $act = new stdClass();
                     $act->cmd = 'photo.upload';
                     $act->actor = $my->id;
                     $act->access = $privacy;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->title = $message;
                     //JText::sprintf('COM_COMMUNITY_ACTIVITIES_UPLOAD_PHOTO' , '{photo_url}', $album->name );
                     $act->content = '';
                     // Generated automatically by stream. No need to add anything
                     $act->app = 'photos';
                     $act->cid = $album->id;
                     $act->location = $album->location;
                     $act->groupid = $group->id;
                     $act->group_access = $group->approvals;
                     $act->eventid = 0;
                     //$act->access		= $attachment['privacy'];
                     /* Comment and like for individual photo upload is linked
                      * to the photos itsel
                      */
                     $act->comment_id = $photo->id;
                     //CActivities::COMMENT_SELF;
                     $act->comment_type = 'photos';
                     $act->like_id = $photo->id;
                     //CActivities::LIKE_SELF;
                     $act->like_type = 'photo';
                     // like type is 'photo' not 'photos'
                     $albumUrl = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $my->id;
                     $albumUrl = CRoute::_($albumUrl);
                     $photoUrl = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id . '&userid=' . $photo->creator . '#photoid=' . $photo->id;
                     $photoUrl = CRoute::_($photoUrl);
                     $params = new CParameter('');
                     $params->set('multiUrl', $albumUrl);
                     $params->set('photoid', $photo->id);
                     $params->set('action', 'upload');
                     $params->set('stream', '1');
                     // this photo uploaded from status stream
                     $params->set('photo_url', $photoUrl);
                     // Add activity logging
                     CFactory::load('libraries', 'activities');
                     CActivityStream::add($act, $params->toString());
                     // Add user points
                     CFactory::load('libraries', 'userpoints');
                     CUserPoints::assignPoint('photo.upload');
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group);
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                     break;
             }
             break;
         case "video":
             switch ($attachment['element']) {
                 case 'profile':
                     // attachment id
                     $cid = $attachment['id'];
                     $privacy = $attachment['privacy'];
                     $video = JTable::getInstance('Video', 'CTable');
                     $video->load($cid);
                     $video->status = 'ready';
                     $video->permissions = $privacy;
                     $video->store();
                     // Add activity logging
                     $url = $video->getViewUri(false);
                     $act = new stdClass();
                     $act->cmd = 'videos.upload';
                     $act->actor = $my->id;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->access = $privacy;
                     //filter empty message
                     $act->title = $message;
                     $act->app = 'videos';
                     $act->content = '';
                     $act->cid = $video->id;
                     $act->location = $video->location;
                     $act->comment_id = $video->id;
                     $act->comment_type = 'videos';
                     $act->like_id = $video->id;
                     $act->like_type = 'videos';
                     $params = new CParameter('');
                     $params->set('video_url', $url);
                     CFactory::load('libraries', 'activities');
                     CActivityStream::add($act, $params->toString());
                     // @rule: Add point when user adds a new video link
                     CFactory::load('libraries', 'userpoints');
                     CUserPoints::assignPoint('video.add', $video->creator);
                     $this->cacheClean(array(COMMUNITY_CACHE_TAG_VIDEOS, COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_VIDEOS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_VIDEOS_UPLOAD_SUCCESS', $video->title));
                     break;
                 case 'groups':
                     // attachment id
                     $cid = $attachment['id'];
                     $privacy = 0;
                     //$attachment['privacy'];
                     $video = JTable::getInstance('Video', 'CTable');
                     $video->load($cid);
                     $video->status = 'ready';
                     $video->groupid = $attachment['target'];
                     $video->permissions = $privacy;
                     $video->store();
                     CFactory::load('libraries', 'groups');
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($attachment['target']);
                     // Add activity logging
                     $url = $video->getViewUri(false);
                     $act = new stdClass();
                     $act->cmd = 'videos.upload';
                     $act->actor = $my->id;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->access = $privacy;
                     //filter empty message
                     $act->title = $message;
                     $act->app = 'videos';
                     $act->content = '';
                     $act->cid = $video->id;
                     $act->groupid = $video->groupid;
                     $act->group_access = $group->approvals;
                     $act->location = $video->location;
                     $act->comment_id = $video->id;
                     $act->comment_type = 'videos';
                     $act->like_id = $video->id;
                     $act->like_type = 'videos';
                     $params = new CParameter('');
                     $params->set('video_url', $url);
                     CFactory::load('libraries', 'activities');
                     CActivityStream::add($act, $params->toString());
                     // @rule: Add point when user adds a new video link
                     CFactory::load('libraries', 'userpoints');
                     CUserPoints::assignPoint('video.add', $video->creator);
                     $this->cacheClean(array(COMMUNITY_CACHE_TAG_VIDEOS, COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_VIDEOS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_VIDEOS_UPLOAD_SUCCESS', $video->title));
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group);
                     break;
             }
             break;
         case "event":
             switch ($attachment['element']) {
                 case 'profile':
                     require_once COMMUNITY_COM_PATH . DS . 'controllers' . DS . 'events.php';
                     $eventController = new CommunityEventsController();
                     // Assign default values where necessary
                     $attachment['description'] = $message;
                     $attachment['ticket'] = 0;
                     $attachment['offset'] = 0;
                     $event = $eventController->ajaxCreate($attachment, $objResponse);
                     $objResponse->addScriptCall('__callback', '');
                     break;
             }
         case 'group':
             require_once COMMUNITY_COM_PATH . DS . 'controllers' . DS . 'events.php';
             $eventController = new CommunityEventsController();
             CFactory::load('libraries', 'groups');
             $groupLib = new CGroups();
             $group = JTable::getInstance('Group', 'CTable');
             $group->load($attachment['target']);
             // Assign default values where necessary
             $attachment['description'] = $message;
             $attachment['ticket'] = 0;
             $attachment['offset'] = 0;
             $event = $eventController->ajaxCreate($attachment, $objResponse);
             $objResponse->addScriptCall('__callback', '');
             // Reload the stream with new stream data
             $streamHTML = $groupLib->getStreamHTML($group);
             break;
             break;
         case "link":
             break;
     }
     // If no filter specified, we can assume it is for all
     if (!isset($attachment['filter'])) {
         $attachment['filter'] = '';
     }
     if (empty($streamHTML)) {
         $streamHTML = CActivities::getActivitiesByFilter($attachment['filter'], $attachment['target'], $attachment['element']);
     }
     $objResponse->addAssign('activity-stream-container', 'innerHTML', $streamHTML);
     return $objResponse->sendResponse();
 }