Beispiel #1
0
 public static function activitiesCommentAdd($userId, $assetId, $obj = NULL)
 {
     //$obj = func_get_arg(2);
     $params = func_get_args();
     $obj = !isset($params[2]) ? NULL : $params[2];
     $model = CFactory::getModel('activities');
     $result = false;
     $config = CFactory::getConfig();
     // Guest can never leave a comment
     if ($userId == 0) {
         return false;
     }
     // If global config allow all members to comment, allow it
     if ($config->get('allmemberactivitycomment') == '1') {
         return true;
     }
     $allow_comment = false;
     // if all activity comment is allowed, return true
     $config = CFactory::getConfig();
     if ($config->get('allmemberactivitycomment') == '1' && COwnerHelper::isRegisteredUser()) {
         $allow_comment = true;
     }
     if ($obj instanceof CTableEvent || $obj instanceof CTableGroup) {
         //event or group activities only
         if ($obj->isMember($userId)) {
             $allow_comment = true;
         }
     } else {
         if ($config->get('allmemberactivitycomment') == '1' && COwnerHelper::isRegisteredUser()) {
             // if all activity comment is allowed, return true
             $allow_comment = true;
         }
     }
     if (!isset($obj->params)) {
         $params = '{}';
     } else {
         $params = $obj->params;
     }
     $params = new CParameter($params);
     $commentPermission = $params->get('commentPermission', NULL);
     if ($commentPermission == false && !is_null($commentPermission)) {
         $allow_comment = false;
     }
     if ($allow_comment || CFriendsHelper::isConnected($assetId, $userId) || COwnerHelper::isCommunityAdmin()) {
         $result = true;
     }
     return $result;
 }
Beispiel #2
0
 public static function activitiesCommentAdd($userId, $assetId)
 {
     $obj = func_get_arg(0);
     $model =& CFactory::getModel('activities');
     $result = false;
     $config = CFactory::getConfig();
     // Guest can never leave a comment
     if ($userId == 0) {
         return false;
     }
     // If global config allow all members to comment, allow it
     if ($config->get('allmemberactivitycomment') == '1') {
         return true;
     }
     $allow_comment = false;
     // if all activity comment is allowed, return true
     $config = CFactory::getConfig();
     if ($config->get('allmemberactivitycomment') == '1' && COwnerHelper::isRegisteredUser()) {
         $allow_comment = true;
     }
     if ($obj instanceof CTableEvent || $obj instanceof CTableGroup) {
         //event or group activities only
         if ($obj->isMember($userId)) {
             $allow_comment = true;
         }
     } else {
         if ($config->get('allmemberactivitycomment') == '1' && COwnerHelper::isRegisteredUser()) {
             // if all activity comment is allowed, return true
             $allow_comment = true;
         }
     }
     if ($allow_comment || CFriendsHelper::isConnected($assetId, $userId) || COwnerHelper::isCommunityAdmin()) {
         $result = true;
     }
     return $result;
 }
Beispiel #3
0
 /**
  * Method to display the create group form
  **/
 public function create()
 {
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->blockUnregister();
     }
     $config = CFactory::getConfig();
     if (!$config->get('enablegroups')) {
         echo JText::_('CC GROUPS DISABLED');
         return;
     }
     CFactory::load('helpers', 'owner');
     if ($config->get('creategroups') && (COwnerHelper::isCommunityAdmin() || COwnerHelper::isRegisteredUser() && $my->canCreateGroups())) {
         CFactory::load('helpers', 'limits');
         if (CLimitsHelper::exceededGroupCreation($my->id)) {
             $groupLimit = $config->get('groupcreatelimit');
             echo JText::sprintf('CC GROUPS CREATION REACH LIMIT', $groupLimit);
             return;
         }
         $document =& JFactory::getDocument();
         $viewType = $document->getType();
         $viewName = JRequest::getCmd('view', $this->getName());
         $view =& $this->getView($viewName, '', $viewType);
         $model =& $this->getModel('groups');
         $data = new stdClass();
         $data->categories = $model->getCategories();
         if (JRequest::getVar('action', '', 'POST') == 'save') {
             CFactory::load('libraries', 'apps');
             $appsLib =& CAppPlugins::getInstance();
             $saveSuccess = $appsLib->triggerEvent('onFormSave', array('jsform-groups-forms'));
             if (empty($saveSuccess) || !in_array(false, $saveSuccess)) {
                 $gid = $this->save();
                 if ($gid !== FALSE) {
                     $mainframe =& JFactory::getApplication();
                     $group =& JTable::getInstance('Group', 'CTable');
                     $group->load($gid);
                     //trigger for onGroupCreate
                     $this->triggerGroupEvents('onGroupCreate', $group);
                     $url = CRoute::_('index.php?option=com_community&view=groups&task=created&groupid=' . $gid, false);
                     $mainframe->redirect($url, JText::sprintf('CC GROUP CREATED NOTICE', $group->name));
                     return;
                 }
             }
         }
     } else {
         echo JText::_('CC GROUPS CREATION DISABLED');
         return;
     }
     echo $view->get(__FUNCTION__, $data);
 }
Beispiel #4
0
                <li><a href="<?php 
        echo CRoute::_('index.php?option=com_community&view=events&task=import&groupid=' . $group->id);
        ?>
"><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_IMPORT_EVENT');
        ?>
</a></li>
            <?php 
    }
    ?>



            <?php 
    // @TODO: CAccess - Leave group
    if ($isMember && !$isMine && !$waitingApproval && COwnerHelper::isRegisteredUser()) {
        ?>
                <li><a href="javascript:" onclick="joms.api.groupLeave('<?php 
        echo $group->id;
        ?>
');"><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_LEAVE');
        ?>
</a></li>
            <?php 
    }
    ?>


            <?php 
    // @TODO: CAccess - Grou padmin actions
Beispiel #5
0
 public function addSubmenus($view)
 {
     $config = CFactory::getConfig();
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $task = $jinput->get->get('task', '');
     //JRequest::getVar( 'task' , '' , 'GET' );
     $backLink = array('invitefriends', 'viewguest', 'uploadavatar', 'edit', 'sendmail', 'app');
     $categoryId = JRequest::getInt('categoryid', 0);
     if (in_array($task, $backLink)) {
         $eventid = $jinput->get->get('eventid', '', 'INT');
         //JRequest::getVar( 'eventid' , '' , 'GET' );
         $view->addSubmenuItem('index.php?option=com_community&view=events&task=viewevent&eventid=' . $eventid, JText::_('COM_COMMUNITY_EVENTS_BACK_BUTTON'));
     } else {
         $view->addSubmenuItem('index.php?option=com_community&view=events&task=display', JText::_('COM_COMMUNITY_EVENTS_ALL'));
         if (COwnerHelper::isRegisteredUser()) {
             $view->addSubmenuItem('index.php?option=com_community&view=events&task=myevents&userid=' . $this->my->id, JText::_('COM_COMMUNITY_EVENTS_MINE'));
             $view->addSubmenuItem('index.php?option=com_community&view=events&task=myinvites&userid=' . $this->my->id, JText::_('COM_COMMUNITY_EVENTS_PENDING_INVITATIONS'));
         }
         // Even guest should be able to view old events
         $view->addSubmenuItem('index.php?option=com_community&view=events&task=pastevents', JText::_('COM_COMMUNITY_EVENTS_PAST_TITLE'));
         $my = CFactory::getUser();
         if (COwnerHelper::isRegisteredUser() && $config->get('createevents') && $my->canCreateEvents() || COwnerHelper::isCommunityAdmin()) {
             //$view->addSubmenuItem('index.php?option=com_community&view=events&task=create', JText::_('COM_COMMUNITY_EVENTS_CREATE') , '' , SUBMENU_RIGHT );
             if ($config->get('event_import_ical')) {
                 $view->addSubmenuItem('index.php?option=com_community&view=events&task=import', JText::_('COM_COMMUNITY_EVENTS_IMPORT'), '', SUBMENU_RIGHT);
             }
         }
         if (!$config->get('enableguestsearchevents') && COwnerHelper::isRegisteredUser() || $config->get('enableguestsearchevents')) {
             $tmpl = new CTemplate();
             $tmpl->set('url', CRoute::_('index.php?option=com_community&view=events&task=search'));
             $html = $tmpl->fetch('events.search.submenu');
             //$view->addSubmenuItem('index.php?option=com_community&view=events&task=search', JText::_('COM_COMMUNITY_EVENTS_SEARCH'), 'joms.events.toggleSearchSubmenu(this)', false, $html);
         }
     }
 }
Beispiel #6
0
 /**
  * Response cWindow content
  * User avatar uploaded from profile page
  * @param strin $type
  * @param int $id
  * @param string $custom
  * @return type
  */
 public function ajaxUploadAvatar($type, $id, $custom = '')
 {
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $isCustom = false;
     $aCustom = json_decode($custom, true);
     $cTable = JTable::getInstance(ucfirst($type), 'CTable');
     $cTable->load($id);
     /* get large avatar use for cropping */
     $img = $cTable->getLargeAvatar();
     $response = new JAXResponse();
     $my = CFactory::getUser();
     $customHTML = '';
     $customArg = '';
     // Replace content with custom value.
     if (isset($aCustom['content'])) {
         $customHTML = '<br>' . $aCustom['content'];
         $isCustom = true;
     } else {
         if (isset($aCustom['call'])) {
             // Replace content with object output.
             // Require library.
             if (isset($aCustom['library'])) {
             }
             // Require function call to output custom content.
             if (isset($aCustom['call'][0]) && isset($aCustom['call'][1])) {
                 $obj = $aCustom['call'][0];
                 $method = $aCustom['call'][1];
                 $params = count($aCustom['call']) > 2 ? array_slice($aCustom['call'], 2) : array();
                 if (!empty($obj) && !empty($method) && $obj == 'CEvents' && $method == "getEventRepeatSaveHTML") {
                     $customHTML = '<br>' . call_user_func_array(array($obj, $method), $params);
                 }
             }
             // Arguement to post.
             if (isset($aCustom['arg'])) {
                 $customArg .= '+';
                 foreach ($aCustom['arg'] as $argType => $argValue) {
                     //$customArg .= '\'&' . $value . '=\' + joms.jQuery(\'#' . $value.'\').val()';
                     if ($argType == 'radio') {
                         $customArg .= '\'&' . $argValue . '=\' + joms.jQuery(\'input[name=' . $argValue . ']:checked\').val()';
                     }
                 }
             }
             $isCustom = ', true';
         }
     }
     $onClickJS = 'joms.jQuery(\'#filedata\').click();';
     /**
      * @todo Replace JBrowser by CBrowser
      */
     jimport('joomla.environment.browser');
     $browser = JBrowser::getInstance();
     /*
     $formAction = CRoute::_(
         'index.php?option=com_community&view=photos&task=changeAvatar&type=' . $type . '&id=' . $id
     );
     $content = '<form id="jsform-uploadavatar" action="' . $formAction . '" method="POST" enctype="multipart/form-data">';
     $content .= $customHTML;
     $content .= '<div id="avatar-upload">';
     $action = 'joms.jQuery(\'#jsform-uploadavatar\').attr(\'action\', joms.jQuery(\'#jsform-uploadavatar\').attr(\'action\')' . $customArg . ')';
     $content .= '<p>' . JText::_('COM_COMMUNIT_SELECT_IMAGE_INSTR') . '</p>';
     $content .= '<label class="label-filetype">';
     $content .= '<a class="btn btn-primary input-block-level" href="javascript:' . $onClickJS . 'void(0);">' . JText::_(
             'COM_COMMUNITY_PHOTOS_UPLOAD'
         ) . '</a>';
     $content .= '<input onchange="' . $action . ';joms.photos.ajaxUpload(\'' . $type . '\',' . $id . $isCustom . ')" type="file" size="50" name="filedata" id="filedata" class="js-file-upload" >';
     $content .= '</label>'; //close
     $content .= '</div>';
     $content .= '</form>';
     
     //set call back
     $callBack = null;
     $actions = '';
     
     //check if default avatar is loaded
     if (!empty($cTable->avatar)) {
         $content .= '<div id="avatar-cropper">';
         $content .= '<strong>' . JText::_('COM_COMMUNITY_CROP_AVATAR_TITLE') . '</strong>';
         $content .= '<div class="crop-msg" style="margin: 0 0 10px">' . JText::_(
                 'COM_COMMUNITY_CROP_AVATAR_INSTR'
             ) . '</div>';
         // $content .= '<div id="update-thumbnail-guide" style="display: none;">' . JText::_('COM_COMMUNITY_UPDATE_THUMBNAIL_GUIDE') . '</div>';
         $content .= '<div class="crop-wrapper">';
         $content .= '<div id="thumb-crop"><img id="large-avatar-pic" style="width: auto; height:auto; max-width: none; max-height:none;" src=' . $img . ' /></div>'; //style="width: auto; height:auto;"
         $content .= '<div id="thumb-preview">';
         $content .= '<strong>' . JText::_('COM_COMMUNITY_PREVIEW') . '</strong>';
         $content .= '<div class="thumb-desc" style="margin-bottom:5px">';
         $content .= '<span>' . JText::_('COM_COMMUNITY_AVATAR_THUMBDESC') . '</span>';
         $content .= '</div>';
         $content .= '<div class="preview">';
         $content .= '<div id="thumb-hold" style="float:left;position:relative;overflow:hidden;width:64px;height:64px"><img style="position:relative;max-width:none;max-height:none;" src=' . $img . ' /></div>';
         $content .= '</div></div>';
         $content .= '<div class="clear"></div>';
         $content .= '</div></div>';
         $callBack = "joms.photos.loadImgSelect();";
     }
     
     // Replace action with custom value.
     if (!isset($aCustom['action'])) {
         $actions .= "<button class=\"btn\" onclick=\"cWindowHide();return false;\">" . JText::_(
                 'COM_COMMUNITY_BUTTON_CLOSE_BUTTON'
             ) . "</button>";
         if (!empty($cTable->avatar)) {
             $actions .= "<button class=\"btn\" onclick=\"location.href='" . CRoute::_(
                     'index.php?option=com_community&view=photos&task=removeAvatar&type=' . $type . '&id=' . $id
                 ) . "';cWindowHide();return false;\">" . JText::_(
                     'COM_COMMUNITY_REMOVE_AVATAR_BUTTON'
                 ) . "</button>";
             $actions .= "<button class=\"btn btn-primary pull-right\" onclick=\"joms.photos.saveThumb('$type','$id');cWindowHide();return false;\">" . JText::_(
                     'COM_COMMUNITY_SAVE_BUTTON'
                 ) . "</button>";
         }
     } else {
         $action .= $aCustom['action'];
     }
     
     $response->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_CHANGE_AVATAR'));
     
     $response->addScriptCall('cWindowAddContent', $content, $actions, $callBack);
     */
     $template = new CTemplate();
     $html = $template->set('type', $type)->set('id', $id)->set('img', empty($cTable->avatar) ? false : $img)->fetch('ajax.uploadavatar');
     $json = array('title' => JText::_('COM_COMMUNITY_CHANGE_AVATAR'), 'html' => $html, 'btnSave' => JText::_('COM_COMMUNITY_SAVE_BUTTON'), 'btnRemove' => JText::_('COM_COMMUNITY_REMOVE_AVATAR_BUTTON'));
     die(json_encode($json));
     // return $response->sendResponse();
 }
Beispiel #7
0
					<!-- Join Event -->
					<li class="event-menu">
							<a class="event-join" href="javascript:void(0);" onclick="javascript:joms.events.join('<?php 
        echo $event->id;
        ?>
');"><?php 
        echo JText::_('CC TAB REQUEST INVITE');
        ?>
</a>
					</li>
					<?php 
    }
    ?>
		
					<?php 
    if (!$isMine && !$waitingRespond && COwnerHelper::isRegisteredUser()) {
        ?>
					<!-- Leave Event -->
					<li class="event-menu important">
							<a class="event-leave" href="javascript:void(0);" onclick="joms.events.leave('<?php 
        echo $event->id;
        ?>
');"><?php 
        echo JText::_('CC EVENTS IGNORE');
        ?>
</a>
					</li>
					<?php 
    }
    ?>
		
            if ($config->get('activitydateformat') == COMMUNITY_DATE_FIXED) {
                ?>
			<li class="ctitle newly-added" style="display:none"><?php 
                echo $act->title;
                ?>
</li>
		<?php 
            }
            ?>
	<?php 
        } else {
            $actor = CFactory::getUser($act->actor);
            $target = CFactory::getUser($act->target);
            // Disallow User who is non-friend to Administrator from Commenting on Custom Post
            $allowComment = $act->commentAllowed && ($act->isMyEvent || $act->isMyGroup || $act->isFriend || $isSuperAdmin) && $showComment;
            $allowComment = $allowComment || $config->get('allmemberactivitycomment') == 1 && COwnerHelper::isRegisteredUser();
            $allowLike = $act->likeAllowed && $showLike;
            // 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, $act->title);
            ?>
		
		<?php 
            if ($act->compactView) {
                ?>
			<!-- start compact view -->
			<li <?php 
                if ($latestId > 0) {
                    echo 'style="display:none"';
Beispiel #9
0
 /**
  * Called by status box to add new stream data
  *
  * @param type $message
  * @param type $attachment
  * @return type
  */
 public function ajaxStreamAdd($message, $attachment, $streamFilter = FALSE)
 {
     $streamHTML = '';
     // $attachment pending filter
     $cache = CFactory::getFastCache();
     $cache->clean(array('activities'));
     $my = CFactory::getUser();
     $userparams = $my->getParams();
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     //@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'));
     }
     $message = JString::trim($message);
     $objResponse = new JAXResponse();
     $rawMessage = $message;
     // @rule: Autolink hyperlinks
     // @rule: Autolink to users profile when message contains @username
     // $message     = CUserHelper::replaceAliasURL($message); // the processing is done on display side
     $emailMessage = CUserHelper::replaceAliasURL($rawMessage, true);
     // @rule: Spam checks
     if ($config->get('antispam_akismet_status')) {
         $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);
     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');
                         /* If no privacy in attachment than we apply default: Public */
                         if (!isset($attachment['privacy'])) {
                             $attachment['privacy'] = COMMUNITY_STATUS_PRIVACY_PUBLIC;
                         }
                         $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->toSql());
                         // 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) . "');");
                     }
                     //if actor posted something to target, the privacy should be under target's profile privacy settings
                     if (!COwnerHelper::isMine($my->id, $attachment['target']) && $attachment['target'] != '') {
                         $attachment['privacy'] = CFactory::getUser($attachment['target'])->getParams()->get('privacyProfileView');
                     }
                     //push to activity stream
                     $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';
                     $activityParams = new CParameter('');
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $headMeta = new CParameter('');
                     if (isset($attachment['fetch'])) {
                         $headMeta->set('title', $attachment['fetch'][2]);
                         $headMeta->set('description', $attachment['fetch'][3]);
                         $headMeta->set('image', $attachment['fetch'][1]);
                         $headMeta->set('link', $attachment['fetch'][0]);
                         //do checking if this is a video link
                         $video = JTable::getInstance('Video', 'CTable');
                         $isValidVideo = @$video->init($attachment['fetch'][0]);
                         if ($isValidVideo) {
                             $headMeta->set('type', 'video');
                             $headMeta->set('video_provider', $video->type);
                             $headMeta->set('video_id', $video->getVideoId());
                             $headMeta->set('height', $video->getHeight());
                             $headMeta->set('width', $video->getWidth());
                         }
                         $activityParams->set('headMetas', $headMeta->toString());
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $activityParams->set('mood', $attachment['mood']);
                     }
                     $act->params = $activityParams->toString();
                     //CActivityStream::add($act);
                     //check if the user points is enabled
                     if (CUserPoints::assignPoint('profile.status.update')) {
                         /* Let use our new CApiStream */
                         $activityData = CApiActivities::add($act);
                         CTags::add($activityData);
                         $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);
                         $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                         $params->set('stream_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $activityData->actor . '&actid=' . $activityData->id));
                         CNotificationLibrary::add('profile_status_update', $my->id, $attachment['target'], JText::sprintf('COM_COMMUNITY_FRIEND_WALL_POST', $my->getDisplayName()), '', 'wall.post', $params);
                         //email and add notification if user are tagged
                         CUserHelper::parseTaggedUserNotification($message, $my, $activityData, array('type' => 'post-comment'));
                     }
                     break;
                     // Message posted from Group page
                 // Message posted from Group page
                 case '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) && $config->get('lockgroupwalls')) {
                         $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';
                     $activityParams = new CParameter('');
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $headMeta = new CParameter('');
                     if (isset($attachment['fetch'])) {
                         $headMeta->set('title', $attachment['fetch'][2]);
                         $headMeta->set('description', $attachment['fetch'][3]);
                         $headMeta->set('image', $attachment['fetch'][1]);
                         $headMeta->set('link', $attachment['fetch'][0]);
                         //do checking if this is a video link
                         $video = JTable::getInstance('Video', 'CTable');
                         $isValidVideo = @$video->init($attachment['fetch'][0]);
                         if ($isValidVideo) {
                             $headMeta->set('type', 'video');
                             $headMeta->set('video_provider', $video->type);
                             $headMeta->set('video_id', $video->getVideoId());
                             $headMeta->set('height', $video->getHeight());
                             $headMeta->set('width', $video->getWidth());
                         }
                         $activityParams->set('headMetas', $headMeta->toString());
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $activityParams->set('mood', $attachment['mood']);
                     }
                     $act->params = $activityParams->toString();
                     $activityData = CApiActivities::add($act);
                     CTags::add($activityData);
                     CUserPoints::assignPoint('group.wall.create');
                     $recipient = CFactory::getUser($attachment['target']);
                     $params = new CParameter('');
                     $params->set('message', $emailMessage);
                     $params->set('group', $group->name);
                     $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
                     $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, true, false, true);
                     $membersArray = array();
                     if (!is_null($members)) {
                         foreach ($members as $row) {
                             if ($my->id != $row->id) {
                                 $membersArray[] = $row->id;
                             }
                         }
                     }
                     $groupParams = new CParameter($group->params);
                     if ($groupParams->get('wallnotification')) {
                         CNotificationLibrary::add('groups_wall_create', $my->id, $membersArray, JText::sprintf('COM_COMMUNITY_NEW_WALL_POST_NOTIFICATION_EMAIL_SUBJECT', $my->getDisplayName(), $group->name), '', 'groups.post', $params);
                     }
                     //@since 4.1 when a there is a new post in group, dump the data into group stats
                     $statsModel = CFactory::getModel('stats');
                     $statsModel->addGroupStats($group->id, 'post');
                     // Add custom stream
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true));
                     break;
                     // Message posted from Event page
                 // Message posted from Event page
                 case '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) && $config->get('lockeventwalls')) {
                         $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;
                     //
                     $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';
                     $activityParams = new CParameter('');
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $headMeta = new CParameter('');
                     if (isset($attachment['fetch'])) {
                         $headMeta->set('title', $attachment['fetch'][2]);
                         $headMeta->set('description', $attachment['fetch'][3]);
                         $headMeta->set('image', $attachment['fetch'][1]);
                         $headMeta->set('link', $attachment['fetch'][0]);
                         //do checking if this is a video link
                         $video = JTable::getInstance('Video', 'CTable');
                         $isValidVideo = @$video->init($attachment['fetch'][0]);
                         if ($isValidVideo) {
                             $headMeta->set('type', 'video');
                             $headMeta->set('video_provider', $video->type);
                             $headMeta->set('video_id', $video->getVideoId());
                             $headMeta->set('height', $video->getHeight());
                             $headMeta->set('width', $video->getWidth());
                         }
                         $activityParams->set('headMetas', $headMeta->toString());
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $activityParams->set('mood', $attachment['mood']);
                     }
                     $act->params = $activityParams->toString();
                     $activityData = CApiActivities::add($act);
                     CTags::add($activityData);
                     // add points
                     CUserPoints::assignPoint('event.wall.create');
                     $params = new CParameter('');
                     $params->set('message', $emailMessage);
                     $params->set('event', $event->title);
                     $params->set('event_url', 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id);
                     $params->set('url', CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false));
                     //Get event member emails
                     $members = $event->getMembers(COMMUNITY_EVENT_STATUS_ATTEND, 12, CC_RANDOMIZE);
                     $membersArray = array();
                     if (!is_null($members)) {
                         foreach ($members as $row) {
                             if ($my->id != $row->id) {
                                 $membersArray[] = $row->id;
                             }
                         }
                     }
                     CNotificationLibrary::add('events_wall_create', $my->id, $membersArray, JText::sprintf('COM_COMMUNITY_NEW_WALL_POST_NOTIFICATION_EMAIL_SUBJECT_EVENTS', $my->getDisplayName(), $event->title), '', 'events.post', $params);
                     //@since 4.1 when a there is a new post in event, dump the data into event stats
                     $statsModel = CFactory::getModel('stats');
                     $statsModel->addEventStats($event->id, 'post');
                     // Reload the stream with new stream data
                     $streamHTML = $eventLib->getStreamHTML($event, array('showLatestActivityOnTop' => true));
                     break;
             }
             $objResponse->addScriptCall('__callback', '');
             // /}
             break;
         case 'photo':
             switch ($attachment['element']) {
                 case 'profile':
                     $photoIds = $attachment['id'];
                     //use User Preference for Privacy
                     //$privacy = $userparams->get('privacyPhotoView'); //$privacy = $attachment['privacy'];
                     $photo = JTable::getInstance('Photo', 'CTable');
                     if (!isset($photoIds[0]) || $photoIds[0] <= 0) {
                         //$objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                         exit;
                     }
                     //always get album id from the photo itself, do not let it assign by params from user post data
                     $photoModel = CFactory::getModel('photos');
                     $photo = $photoModel->getPhoto($photoIds[0]);
                     /* OK ! If album_id is not provided than we use album id from photo ( it should be default album id ) */
                     $albumid = isset($attachment['album_id']) ? $attachment['album_id'] : $photo->albumid;
                     $album = JTable::getInstance('Album', 'CTable');
                     $album->load($albumid);
                     $privacy = $album->permissions;
                     //limit checking
                     //                        $photoModel = CFactory::getModel( 'photos' );
                     //                        $config       = CFactory::getConfig();
                     //                        $total        = $photoModel->getTotalToday( $my->id );
                     //                        $max      = $config->getInt( 'limit_photo_perday' );
                     //                        $remainingUploadCount = $max - $total;
                     $params = array();
                     foreach ($photoIds as $key => $photoId) {
                         if (CLimitsLibrary::exceedDaily('photos')) {
                             unset($photoIds[$key]);
                             continue;
                         }
                         $photo->load($photoId);
                         $photo->permissions = $privacy;
                         $photo->published = 1;
                         $photo->status = 'ready';
                         $photo->albumid = $albumid;
                         /* We must update this photo into correct album id */
                         $photo->store();
                         $params[] = clone $photo;
                     }
                     if ($config->get('autoalbumcover') && !$album->photoid) {
                         $album->photoid = $photoIds[0];
                         $album->store();
                     }
                     // Break if no photo added, which is likely because of daily limit.
                     if (count($photoIds) < 1) {
                         $objResponse->addScriptCall('__throwError', JText::_('COM_COMMUNITY_PHOTO_UPLOAD_LIMIT_EXCEEDED'));
                         return $objResponse->sendResponse();
                     }
                     // Trigger onPhotoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $apps->triggerEvent('onPhotoCreate', array($params));
                     $act = new stdClass();
                     $act->cmd = 'photo.upload';
                     $act->actor = $my->id;
                     $act->access = $privacy;
                     //$attachment['privacy'];
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->title = $message;
                     $act->content = '';
                     // Generated automatically by stream. No need to add anything
                     $act->app = 'photos';
                     $act->cid = $albumid;
                     $act->location = $album->location;
                     /* Comment and like for individual photo upload is linked
                      * to the photos itsel
                      */
                     $act->comment_id = $photo->id;
                     $act->comment_type = 'photos';
                     $act->like_id = $photo->id;
                     $act->like_type = 'photo';
                     $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');
                     $params->set('photo_url', $photoUrl);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     $params->set('photosId', implode(',', $photoIds));
                     if (count($photoIds > 1)) {
                         $params->set('count', count($photoIds));
                         $params->set('batchcount', count($photoIds));
                     }
                     //Store mood in param
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     // Add activity logging
                     // CActivityStream::remove($act->app, $act->cid);
                     $activityData = CActivityStream::add($act, $params->toString());
                     // Add user points
                     CUserPoints::assignPoint('photo.upload');
                     //add a notification to the target user if someone posted photos on target's profile
                     if ($my->id != $attachment['target']) {
                         $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);
                         $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                         $params->set('stream_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $activityData->actor . '&actid=' . $activityData->id));
                         CNotificationLibrary::add('profile_status_update', $my->id, $attachment['target'], JText::sprintf('COM_COMMUNITY_NOTIFICATION_STREAM_PHOTO_POST', count($photoIds)), '', 'wall.post', $params);
                     }
                     //email and add notification if user are tagged
                     CUserHelper::parseTaggedUserNotification($message, $my, $activityData, array('type' => 'post-comment'));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                     break;
                 case 'events':
                     $event = JTable::getInstance('Event', 'CTable');
                     $event->load($attachment['target']);
                     $privacy = 0;
                     //if this is a group event, we need to follow the group privacy
                     if ($event->type == 'group' && $event->contentid) {
                         $group = JTable::getInstance('Group', 'CTable');
                         $group->load(${$event}->contentid);
                         $privacy = $group->approvals ? PRIVACY_GROUP_PRIVATE_ITEM : 0;
                     }
                     $photoIds = $attachment['id'];
                     $photo = JTable::getInstance('Photo', 'CTable');
                     $photo->load($photoIds[0]);
                     $albumid = isset($attachment['album_id']) ? $attachment['album_id'] : $photo->albumid;
                     $album = JTable::getInstance('Album', 'CTable');
                     $album->load($albumid);
                     $params = array();
                     foreach ($photoIds as $photoId) {
                         $photo->load($photoId);
                         $photo->caption = $message;
                         $photo->permissions = $privacy;
                         $photo->published = 1;
                         $photo->status = 'ready';
                         $photo->albumid = $albumid;
                         $photo->store();
                         $params[] = clone $photo;
                     }
                     // Trigger onPhotoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $apps->triggerEvent('onPhotoCreate', array($params));
                     $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->eventid = $event->id;
                     $act->group_access = $privacy;
                     // just in case this event belongs to a group
                     //$act->access      = $attachment['privacy'];
                     /* Comment and like for individual photo upload is linked
                      * to the photos itsel
                      */
                     $act->comment_id = $photo->id;
                     $act->comment_type = 'photos';
                     $act->like_id = $photo->id;
                     $act->like_type = 'photo';
                     $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);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     $params->set('photosId', implode(',', $photoIds));
                     // Add activity logging
                     if (count($photoIds > 1)) {
                         $params->set('count', count($photoIds));
                         $params->set('batchcount', count($photoIds));
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     // CActivityStream::remove($act->app, $act->cid);
                     $activityData = CActivityStream::add($act, $params->toString());
                     // Add user points
                     CUserPoints::assignPoint('photo.upload');
                     // Reload the stream with new stream data
                     $eventLib = new CEvents();
                     $event = JTable::getInstance('Event', 'CTable');
                     $event->load($attachment['target']);
                     $streamHTML = $eventLib->getStreamHTML($event, array('showLatestActivityOnTop' => true));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                     break;
                 case 'groups':
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($attachment['target']);
                     $photoIds = $attachment['id'];
                     $privacy = $group->approvals ? PRIVACY_GROUP_PRIVATE_ITEM : 0;
                     $photo = JTable::getInstance('Photo', 'CTable');
                     $photo->load($photoIds[0]);
                     $albumid = isset($attachment['album_id']) ? $attachment['album_id'] : $photo->albumid;
                     $album = JTable::getInstance('Album', 'CTable');
                     $album->load($albumid);
                     $params = array();
                     foreach ($photoIds as $photoId) {
                         $photo->load($photoId);
                         $photo->caption = $message;
                         $photo->permissions = $privacy;
                         $photo->published = 1;
                         $photo->status = 'ready';
                         $photo->albumid = $albumid;
                         $photo->store();
                         $params[] = clone $photo;
                     }
                     // Trigger onPhotoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $apps->triggerEvent('onPhotoCreate', array($params));
                     $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;
                     $act->comment_type = 'photos';
                     $act->like_id = $photo->id;
                     $act->like_type = 'photo';
                     $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);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     $params->set('photosId', implode(',', $photoIds));
                     // Add activity logging
                     if (count($photoIds > 1)) {
                         $params->set('count', count($photoIds));
                         $params->set('batchcount', count($photoIds));
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     // CActivityStream::remove($act->app, $act->cid);
                     $activityData = CActivityStream::add($act, $params->toString());
                     // Add user points
                     CUserPoints::assignPoint('photo.upload');
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                     break;
                     dafault:
                     return;
             }
             break;
         case 'video':
             switch ($attachment['element']) {
                 case 'profile':
                     // attachment id
                     $fetch = $attachment['fetch'];
                     $cid = $fetch[0];
                     $privacy = isset($attachment['privacy']) ? $attachment['privacy'] : COMMUNITY_STATUS_PRIVACY_PUBLIC;
                     $video = JTable::getInstance('Video', 'CTable');
                     $video->load($cid);
                     $video->set('creator_type', VIDEO_USER_TYPE);
                     $video->set('status', 'ready');
                     $video->set('permissions', $privacy);
                     $video->set('title', $fetch[3]);
                     $video->set('description', $fetch[4]);
                     $video->set('category_id', $fetch[5]);
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         $video->set('location', $attachment['location'][0]);
                         $video->set('latitude', $attachment['location'][1]);
                         $video->set('longitude', $attachment['location'][2]);
                     }
                     // Add activity logging
                     $url = $video->getViewUri(false);
                     $act = new stdClass();
                     $act->cmd = 'videos.linking';
                     $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.linking';
                     $act->content = '';
                     $act->cid = $video->id;
                     $act->location = $video->location;
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $act->comment_id = $video->id;
                     $act->comment_type = 'videos.linking';
                     $act->like_id = $video->id;
                     $act->like_type = 'videos.linking';
                     $params = new CParameter('');
                     $params->set('video_url', $url);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     //
                     $activityData = CActivityStream::add($act, $params->toString());
                     //this video must be public because it's posted on someone else's profile
                     if ($my->id != $attachment['target']) {
                         $video->set('permissions', COMMUNITY_STATUS_PRIVACY_PUBLIC);
                         $params = new CParameter();
                         $params->set('activity_id', $activityData->id);
                         // activity id is used to remove the activity if someone deleted this video
                         $params->set('target_id', $attachment['target']);
                         $video->params = $params->toString();
                         //also send a notification to the user
                         $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);
                         $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                         $params->set('stream_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $activityData->actor . '&actid=' . $activityData->id));
                         CNotificationLibrary::add('profile_status_update', $my->id, $attachment['target'], JText::_('COM_COMMUNITY_NOTIFICATION_STREAM_VIDEO_POST'), '', 'wall.post', $params);
                     }
                     $video->store();
                     // @rule: Add point when user adds a new video link
                     //
                     CUserPoints::assignPoint('video.add', $video->creator);
                     //email and add notification if user are tagged
                     CUserHelper::parseTaggedUserNotification($message, $my, $activityData, array('type' => 'post-comment'));
                     // Trigger for onVideoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $params = array();
                     $params[] = $video;
                     $apps->triggerEvent('onVideoCreate', $params);
                     $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
                     $fetch = $attachment['fetch'];
                     $cid = $fetch[0];
                     $privacy = 0;
                     //$attachment['privacy'];
                     $video = JTable::getInstance('Video', 'CTable');
                     $video->load($cid);
                     $video->set('status', 'ready');
                     $video->set('groupid', $attachment['target']);
                     $video->set('permissions', $privacy);
                     $video->set('creator_type', VIDEO_GROUP_TYPE);
                     $video->set('title', $fetch[3]);
                     $video->set('description', $fetch[4]);
                     $video->set('category_id', $fetch[5]);
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         $video->set('location', $attachment['location'][0]);
                         $video->set('latitude', $attachment['location'][1]);
                         $video->set('longitude', $attachment['location'][2]);
                     }
                     $video->store();
                     //
                     $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.linking';
                     $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;
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $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);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     $activityData = CActivityStream::add($act, $params->toString());
                     // @rule: Add point when user adds a new video link
                     CUserPoints::assignPoint('video.add', $video->creator);
                     // Trigger for onVideoCreate
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $params = array();
                     $params[] = $video;
                     $apps->triggerEvent('onVideoCreate', $params);
                     $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, array('showLatestActivityOnTop' => true));
                     break;
                 case 'events':
                     //event videos
                     $fetch = $attachment['fetch'];
                     $cid = $fetch[0];
                     $privacy = 0;
                     //$attachment['privacy'];
                     $video = JTable::getInstance('Video', 'CTable');
                     $video->load($cid);
                     $video->set('status', 'ready');
                     $video->set('eventid', $attachment['target']);
                     $video->set('permissions', $privacy);
                     $video->set('creator_type', VIDEO_EVENT_TYPE);
                     $video->set('title', $fetch[3]);
                     $video->set('description', $fetch[4]);
                     $video->set('category_id', $fetch[5]);
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         $video->set('location', $attachment['location'][0]);
                         $video->set('latitude', $attachment['location'][1]);
                         $video->set('longitude', $attachment['location'][2]);
                     }
                     $video->store();
                     //
                     $eventLib = new CEvents();
                     $event = JTable::getInstance('Event', 'CTable');
                     $event->load($attachment['target']);
                     $group = new stdClass();
                     if ($event->type == 'group' && $event->contentid) {
                         // check if this a group event, and follow the permission
                         $group = JTable::getInstance('Group', 'CTable');
                         $group->load($event->contentid);
                     }
                     // Add activity logging
                     $url = $video->getViewUri(false);
                     $act = new stdClass();
                     $act->cmd = 'videos.linking';
                     $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 = 0;
                     $act->group_access = isset($group->approvals) ? $group->approvals : 0;
                     // if this is a group event
                     $act->location = $video->location;
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $act->eventid = $event->id;
                     $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);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     $activityData = CActivityStream::add($act, $params->toString());
                     // @rule: Add point when user adds a new video link
                     CUserPoints::assignPoint('video.add', $video->creator);
                     // Trigger for onVideoCreate
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $params = array();
                     $params[] = $video;
                     $apps->triggerEvent('onVideoCreate', $params);
                     $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 = $eventLib->getStreamHTML($event, array('showLatestActivityOnTop' => true));
                     break;
                 default:
                     return;
             }
             break;
         case 'event':
             switch ($attachment['element']) {
                 case 'profile':
                     require_once COMMUNITY_COM_PATH . '/controllers/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('window.location="' . $event->getLink() . '";');
                     if (CFactory::getConfig()->get('event_moderation')) {
                         $objResponse->addAlert(JText::sprintf('COM_COMMUNITY_EVENTS_MODERATION_NOTICE', $event->title));
                     }
                     break;
                 case 'groups':
                     require_once COMMUNITY_COM_PATH . '/controllers/events.php';
                     $eventController = new CommunityEventsController();
                     //
                     $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);
                     CEvents::addGroupNotification($event);
                     $objResponse->addScriptCall('window.location="' . $event->getLink() . '";');
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true));
                     if (CFactory::getConfig()->get('event_moderation')) {
                         $objResponse->addAlert(JText::sprintf('COM_COMMUNITY_EVENTS_MODERATION_NOTICE', $event->title));
                     }
                     break;
             }
             break;
         case 'link':
             break;
     }
     //no matter what kind of message it is, always filter the hashtag if there's any
     if (!empty($act->title) && isset($activityData->id) && $activityData->id) {
         //use model to check if this has a tag in it and insert into the table if possible
         $hashtags = CContentHelper::getHashTags($act->title);
         if (count($hashtags)) {
             //$hashTag
             $hashtagModel = CFactory::getModel('hashtags');
             foreach ($hashtags as $tag) {
                 $hashtagModel->addActivityHashtag($tag, $activityData->id);
             }
         }
     }
     // Frontpage filter
     if ($streamFilter != false) {
         $streamFilter = json_decode($streamFilter);
         $filter = $streamFilter->filter;
         $value = $streamFilter->value;
         $extra = false;
         // Append added data to the list.
         if (isset($activityData) && $activityData->id) {
             $model = CFactory::getModel('Activities');
             $extra = $model->getActivity($activityData->id);
         }
         switch ($filter) {
             case 'privacy':
                 if ($value == 'me-and-friends' && $my->id != 0) {
                     $streamHTML = CActivities::getActivitiesByFilter('active-user-and-friends', $my->id, 'frontpage', true, array(), $extra);
                 } else {
                     $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array(), $extra);
                 }
                 break;
             case 'apps':
                 $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array('apps' => array($value)), $extra);
                 break;
             case 'hashtag':
                 $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array($filter => $value), $extra);
                 break;
             default:
                 $defaultFilter = $config->get('frontpageactivitydefault');
                 if ($defaultFilter == 'friends' && $my->id != 0) {
                     $streamHTML = CActivities::getActivitiesByFilter('active-user-and-friends', $my->id, 'frontpage', true, array(), $extra);
                 } else {
                     $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array(), $extra);
                 }
                 break;
         }
     }
     if (!isset($attachment['filter'])) {
         $attachment['filter'] = '';
         $filter = $config->get('frontpageactivitydefault');
         $filter = explode(':', $filter);
         $attachment['filter'] = isset($filter[1]) ? $filter[1] : $filter[0];
     }
     if (empty($streamHTML)) {
         if (!isset($attachment['target'])) {
             $attachment['target'] = '';
         }
         if (!isset($attachment['element'])) {
             $attachment['element'] = '';
         }
         $streamHTML = CActivities::getActivitiesByFilter($attachment['filter'], $attachment['target'], $attachment['element'], true, array('show_featured' => true, 'showLatestActivityOnTop' => true));
     }
     $objResponse->addAssign('activity-stream-container', 'innerHTML', $streamHTML);
     // Log user engagement
     CEngagement::log($attachment['type'] . '.share', $my->id);
     return $objResponse->sendResponse();
 }
Beispiel #10
0
 function _addSubmenu()
 {
     $my = CFactory::getUser();
     $config =& CFactory::getConfig();
     $task = JRequest::getVar('task', '', 'REQUEST');
     $groupId = JRequest::getVar('groupid', '', 'GET');
     $group = JTable::getInstance('Group', 'CTable');
     $group->load($groupId);
     $isBanned = $group->isBanned($my->id);
     if (!empty($groupId)) {
         $this->addSubmenuItem('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId, JText::_('CC BACK TO GROUP'));
         $videos = $this->model->hasPendingVideos($groupId, VIDEO_GROUP_TYPE);
         if ($videos) {
             $this->addSubmenuItem('index.php?option=com_community&view=videos&task=mypendingvideos&groupid=' . $groupId, JText::_('CC PENDING GROUP VIDEOS'), '', SUBMENU_LEFT);
         }
         CFactory::load('helpers', 'group');
         $allowManageVideos = CGroupHelper::allowManageVideo($groupId);
         if ($allowManageVideos && !$isBanned) {
             $this->addSubmenuItem('', JText::_('CC ADD'), 'joms.videos.addVideo(\'' . VIDEO_GROUP_TYPE . '\', \'' . $groupId . '\')', SUBMENU_RIGHT);
         }
     } else {
         $this->addSubmenuItem('index.php?option=com_community&view=videos', JText::_('CC ALL VIDEOS'), '', SUBMENU_LEFT);
         if (!empty($my->id)) {
             $this->addSubmenuItem('index.php?option=com_community&view=videos&task=myvideos&userid=' . $my->id, JText::_('CC MY VIDEOS'), '', SUBMENU_LEFT);
             $this->addSubmenuItem('', JText::_('CC ADD'), 'joms.videos.addVideo()', SUBMENU_RIGHT);
         }
         if (!$config->get('enableguestsearchvideos') && COwnerHelper::isRegisteredUser() || $config->get('enableguestsearchvideos')) {
             $tmpl = new CTemplate();
             $tmpl->set('url', CRoute::_('index.php?option=com_community&view=videos&task=search'));
             $html = $tmpl->fetch('videos.search.submenu');
             $this->addSubmenuItem('index.php?option=com_community&view=videos&task=search', JText::_('CC SEARCH'), 'joms.videos.toggleSearchSubmenu(this)', SUBMENU_LEFT, $html);
         }
         $videos = $this->model->hasPendingVideos($my->id, VIDEO_USER_TYPE);
         if (!empty($my->id) && $videos) {
             $this->addSubmenuItem('index.php?option=com_community&view=videos&task=mypendingvideos&userid=' . $my->id, JText::_('CC PENDING VIDEOS'), '', SUBMENU_LEFT);
         }
     }
 }
Beispiel #11
0
 /**
  * This function will regenerate the thumbnail of videos
  * @param int $id
  * @param bool $returnThumb
  * @return bool
  */
 public function _fetchThumbnail($id = 0, $returnThumb = false)
 {
     if (!COwnerHelper::isRegisteredUser()) {
         return;
     }
     if (!$id) {
         return false;
     }
     $table = JTable::getInstance('Video', 'CTable');
     $table->load($id);
     $config = CFactory::getConfig();
     if ($table->type == 'file') {
         // We can only recreate the thumbnail for local video file only
         // it's not possible to process remote video file with ffmpeg
         if ($table->storage != 'file') {
             $this->setError(JText::_('COM_COMMUNITY_INVALID_FILE_REQUEST') . ': ' . 'FFmpeg cannot process remote video.');
             return false;
         }
         $videoLib = new CVideoLibrary();
         $videoFullPath = JPATH::clean(JPATH_ROOT . '/' . $table->path);
         if (!JFile::exists($videoFullPath)) {
             return false;
         }
         // Read duration
         $videoInfo = $videoLib->getVideoInfo($videoFullPath);
         if (!$videoInfo) {
             return false;
         } else {
             $videoFrame = CVideosHelper::formatDuration((int) ($videoInfo['duration']['sec'] / 2), 'HH:MM:SS');
             // Create thumbnail
             $oldThumb = $table->thumb;
             $thumbFolder = CVideoLibrary::getPath($table->creator, 'thumb');
             $thumbSize = CVideoLibrary::thumbSize();
             $thumbFilename = $videoLib->createVideoThumb($videoFullPath, $thumbFolder, $videoFrame, $thumbSize);
         }
         if (!$thumbFilename) {
             return false;
         }
     } else {
         if (!CRemoteHelper::curlExists()) {
             $this->setError(JText::_('COM_COMMUNITY_CURL_NOT_EXISTS'));
             return false;
         }
         $videoLib = new CVideoLibrary();
         $videoObj = $videoLib->getProvider($table->path);
         if ($videoObj == false) {
             $this->setError($videoLib->getError());
             return false;
         }
         if (!$videoObj->isValid()) {
             $this->setError($videoObj->getError());
             return false;
         }
         $remoteThumb = $videoObj->getThumbnail();
         $thumbData = CRemoteHelper::getContent($remoteThumb, true);
         if (empty($thumbData)) {
             $this->setError(JText::_('COM_COMMUNITY_INVALID_FILE_REQUEST') . ': ' . $remoteThumb);
             return false;
         }
         // split the header and body
         list($headers, $body) = explode("\r\n\r\n", $thumbData, 2);
         preg_match('/Content-Type: image\\/(.*)/i', $headers, $matches);
         if (!empty($matches)) {
             $thumbPath = CVideoLibrary::getPath($table->creator, 'thumb');
             $thumbFileName = CFileHelper::getRandomFilename($thumbPath);
             $tmpThumbPath = $thumbPath . '/' . $thumbFileName;
             if (!JFile::write($tmpThumbPath, $body)) {
                 $this->setError(JText::_('COM_COMMUNITY_INVALID_FILE_REQUEST') . ': ' . $thumbFileName);
                 return false;
             }
             // We'll remove the old or none working thumbnail after this
             $oldThumb = $table->thumb;
             // Get the image type first so we can determine what extensions to use
             $info = getimagesize($tmpThumbPath);
             $mime = image_type_to_mime_type($info[2]);
             $thumbExtension = CImageHelper::getExtension($mime);
             $thumbFilename = $thumbFileName . $thumbExtension;
             $thumbPath = $thumbPath . '/' . $thumbFilename;
             if (!JFile::move($tmpThumbPath, $thumbPath)) {
                 $this->setError(JText::_('WARNFS_ERR02') . ': ' . $thumbFileName);
                 return false;
             }
             // Resize the thumbnails
             //CImageHelper::resizeProportional( $thumbPath , $thumbPath , $mime , CVideoLibrary::thumbSize('width') , CVideoLibrary::thumbSize('height') );
             list($width, $height) = explode('x', $config->get('videosThumbSize'));
             CImageHelper::resizeAspectRatio($thumbPath, $thumbPath, $width, $height);
         } else {
             $this->setError(JText::_('COM_COMMUNITY_PHOTOS_IMAGE_NOT_PROVIDED_ERROR'));
             return false;
         }
     }
     // Update the DB with new thumbnail
     $thumb = $config->get('videofolder') . '/' . VIDEO_FOLDER_NAME . '/' . $table->creator . '/' . VIDEO_THUMB_FOLDER_NAME . '/' . $thumbFilename;
     $table->set('thumb', $thumb);
     $table->store();
     // If this video storage is not on local, we move it to remote storage
     // and remove the old thumb if existed
     if ($table->storage != 'file') {
         // && ($table->storage == $storageType))
         $config = CFactory::getConfig();
         $storageType = $config->getString('videostorage');
         $storage = CStorage::getStorage($storageType);
         $storage->delete($oldThumb);
         $localThumb = JPATH::clean(JPATH_ROOT . '/' . $table->thumb);
         $tempThumbname = JPATH::clean(JPATH_ROOT . '/' . md5($table->thumb));
         if (JFile::exists($localThumb)) {
             JFile::copy($localThumb, $tempThumbname);
         }
         if (JFile::exists($tempThumbname)) {
             $storage->put($table->thumb, $tempThumbname);
             JFile::delete($localThumb);
             JFile::delete($tempThumbname);
         }
     } else {
         if (JFile::exists(JPATH_ROOT . '/' . $oldThumb)) {
             JFile::delete(JPATH_ROOT . '/' . $oldThumb);
         }
     }
     if ($returnThumb) {
         return $table->getThumbnail();
     }
     return true;
 }
Beispiel #12
0
 /**
  * Ajax method to save video description
  *
  * @param    int $videoId The video id
  * @param    string $description The description of the video
  * */
 public function ajaxSaveDescription($videoId, $description)
 {
     $filter = JFilterInput::getInstance();
     $videoId = $filter->clean($videoId, 'int');
     $description = $filter->clean($description, 'string');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $json = array();
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $video = JTable::getInstance('Video', 'CTable');
     $video->load($videoId);
     $group = JTable::getInstance('Group', 'CTable');
     $group->load($video->groupid);
     if (COwnerHelper::isCommunityAdmin() || $video->creator == $my->id || $group->isAdmin($my->id)) {
         $video->description = $description;
         $video->store();
         $json['success'] = true;
         $json['caption'] = $video->description;
         $json['excerpt'] = JHTML::_('string.truncate', $video->description, $config->getInt('streamcontentlength'));
     } else {
         $json['error'] = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
     }
     die(json_encode($json));
 }
Beispiel #13
0
 public function addSubmenus($view)
 {
     $config = CFactory::getConfig();
     $task = JRequest::getVar('task', '', 'GET');
     $backLink = array('invitefriends', 'viewguest', 'uploadavatar', 'edit', 'sendmail', 'app');
     if (in_array($task, $backLink)) {
         $eventid = JRequest::getVar('eventid', '', 'GET');
         $view->addSubmenuItem('index.php?option=com_community&view=events&task=viewevent&eventid=' . $eventid, JText::_('CC BACK TO EVENT'));
     } else {
         $view->addSubmenuItem('index.php?option=com_community&view=events', JText::_('CC ALL EVENTS'));
         if (COwnerHelper::isRegisteredUser()) {
             $view->addSubmenuItem('index.php?option=com_community&view=events&task=myevents&userid=' . $this->my->id, JText::_('CC MY EVENTS'));
             $view->addSubmenuItem('index.php?option=com_community&view=events&task=myinvites&userid=' . $this->my->id, JText::_('CC EVENT PENDING INVITATIONS'));
         }
         // Even guest should be able to view old events
         $view->addSubmenuItem('index.php?option=com_community&view=events&task=pastevents', JText::_('CC PAST EVENTS TITLE'));
         if (COwnerHelper::isRegisteredUser() && $config->get('createevents') || COwnerHelper::isCommunityAdmin()) {
             $view->addSubmenuItem('index.php?option=com_community&view=events&task=create', JText::_('CC CREATE EVENT'), '', SUBMENU_RIGHT);
             if ($config->get('event_import_ical')) {
                 $view->addSubmenuItem('index.php?option=com_community&view=events&task=import', JText::_('CC EVENTS IMPORT'), '', SUBMENU_RIGHT);
             }
         }
         if (!$config->get('enableguestsearchevents') && COwnerHelper::isRegisteredUser() || $config->get('enableguestsearchevents')) {
             $tmpl = new CTemplate();
             $tmpl->set('url', CRoute::_('index.php?option=com_community&view=events&task=search'));
             $html = $tmpl->fetch('events.search.submenu');
             $view->addSubmenuItem('index.php?option=com_community&view=events&task=search', JText::_('CC SEARCH EVENTS'), 'joms.events.toggleSearchSubmenu(this)', false, $html);
         }
     }
 }
Beispiel #14
0
 /**
  * Delete profile video
  *
  * @param	int		$creator		The id of the video creator
  * @return	True on success or unsuccess
  **/
 private function _deleteProfileVideo($creator, $deletedvideoid)
 {
     if (!COwnerHelper::isRegisteredUser()) {
         return;
     }
     // Only the video creator can use the video as his/her profile video
     $user = CFactory::getUser($creator);
     // Set params to default(0 for no profile video)
     $params = $user->getParams();
     $videoid = $params->get('profileVideo', 0);
     // Check if the current profile video id same with the deleted video id
     if ($videoid == $deletedvideoid) {
         $params->set('profileVideo', 0);
         $user->save('params');
     }
     return;
 }
Beispiel #15
0
    /**
     * Show the connection request box
     */
    public function ajaxConnect($friendId)
    {
        // Block unregistered users.
        if (!COwnerHelper::isRegisteredUser()) {
            return $this->ajaxBlockUnregister();
        }
        $objResponse = new JAXResponse();
        //@todo filter paramater
        $model =& $this->getModel('friends');
        $blockModel =& $this->getModel('block');
        $my = CFactory::getUser();
        $view = $this->getView('friends');
        $user = CFactory::getUser($friendId);
        CFactory::load('libraries', 'block');
        $blockUser = new blockUser();
        CFactory::load('helpers', 'owner');
        // Block blocked users
        if ($blockModel->getBlockStatus($my->id, $friendId) && !COwnerHelper::isCommunityAdmin()) {
            $blockUser->ajaxBlockMessage();
        }
        // Warn owner that the user has been blocked, cannot add as friend
        if ($blockModel->getBlockStatus($friendId, $my->id)) {
            $blockUser->ajaxBlockWarn();
        }
        $connection = $model->getFriendConnection($my->id, $friendId);
        CFactory::load('helpers', 'string');
        //@todo disallow self add as a friend
        //@todo disallow add existing friend
        if ($my->id == $friendId) {
            $objResponse->addAssign('cWindowContent', 'innerHTML', JText::_('CC FRIEND CANNOT ADD SELF'));
            $objResponse->addScriptCall('cWindowResize', 100);
        } elseif (count($connection) > 0) {
            if ($connection[0]->connect_from == $my->id) {
                $objResponse->addAssign('cWindowContent', 'innerHTML', JText::sprintf('CC FRIEND REQUEST ALREADY SENT', $user->getDisplayName()));
            } else {
                $objResponse->addAssign('cWindowContent', 'innerHTML', JText::sprintf('CC FRIEND REQUEST ALREADY RECEIVED', $user->getDisplayName()));
            }
            $objResponse->addScriptCall('cWindowResize', 100);
        } else {
            ob_start();
            ?>
		<div id="addFriendContainer">
			<p><?php 
            echo JText::sprintf('CC CONFIRM ADD FRIEND', $user->getDisplayName());
            ?>
</p>
			<form name="addfriend" id="addfriend" method="post" action="">				
		        <img class="avatar" src="<?php 
            echo $user->getThumbAvatar();
            ?>
" alt="<?php 
            echo CStringHelper::escape($user->getDisplayName());
            ?>
" alt=""/>
				<textarea class="inputbox" name="msg"></textarea>
				<input type="hidden" class="button" name="userid" value="<?php 
            echo $user->id;
            ?>
"/>
			</form>
		</div>
		<?php 
            $html = ob_get_contents();
            ob_end_clean();
            $action = '<button class="button" onclick="joms.friends.addNow();" name="save">' . JText::_('CC BUTTON ADD FRIEND') . '</button>';
            $action .= '<button class="button" onclick="javascript:cWindowHide();" name="cancel">' . JText::_('CC BUTTON CANCEL') . '</button>';
            $objResponse->addAssign('cwin_logo', 'innerHTML', JText::_('CC FRIEND ADD'));
            $objResponse->addAssign('cWindowContent', 'innerHTML', $html);
            $objResponse->addScriptCall('cWindowActions', $action);
            $objResponse->addScriptCall('cWindowResize', 130);
        }
        return $objResponse->sendResponse();
    }
Beispiel #16
0
                    <button class="joms-button--neutral"><?php 
    echo JText::_('COM_COMMUNITY_SEARCH_GO');
    ?>
</button>
                </span>
                    <input type="hidden" name="option" value="com_community"/>
                    <input type="hidden" name="view" value="groups"/>
                    <input type="hidden" name="task" value="search"/>
                    <input type="hidden" name="Itemid" value="<?php 
    echo CRoute::getItemId();
    ?>
"/>
                </form>
            <?php 
}
if ($config->get('creategroups') && (COwnerHelper::isCommunityAdmin() || COwnerHelper::isRegisteredUser() && $my->canCreateGroups())) {
    ?>
            <button onclick="window.location='<?php 
    echo CRoute::_('index.php?option=com_community&view=groups&task=create');
    ?>
';" class="joms-button--add">
                <?php 
    echo JText::_('COM_COMMUNITY_GROUPS_CREATE_GROUP');
    ?>
                <svg class="joms-icon" viewBox="0 0 16 16">
                    <use xlink:href="<?php 
    echo CRoute::getURI();
    ?>
#joms-icon-plus"/>
                </svg>
            </button>
Beispiel #17
0
 /**
  *
  * @return string
  */
 public function getHTML($element, $itemId, $userId)
 {
     if ($userId == 0) {
         return false;
     }
     // @rule: Only display likes html codes when likes is allowed.
     $config = CFactory::getConfig();
     if (!$this->enabled($element)) {
         return;
     }
     $like = JTable::getInstance('Like', 'CTable');
     $like->loadInfo($element, $itemId);
     $userLiked = COMMUNITY_UNLIKE;
     $likesInArray = array();
     $dislikesInArray = array();
     $likes = 0;
     $dislikes = 0;
     if (!empty($like->like)) {
         $likesInArray = explode(',', trim($like->like, ','));
         $likes = count($likesInArray);
     }
     if (!empty($like->dislike)) {
         $dislikesInArray = explode(',', trim($like->dislike, ','));
         $dislikes = count($dislikesInArray);
     }
     $userLiked = $this->userLiked($element, $itemId, $userId);
     $tmpl = new CTemplate();
     // For rendering, we need to replace . with _ since it is not
     // a valid id
     $element = str_replace('.', '_', $element);
     $tmpl->set('likeId', 'like' . '-' . $element . '-' . $itemId);
     $tmpl->set('likes', $likes);
     $tmpl->set('dislikes', $dislikes);
     $tmpl->set('userLiked', $userLiked);
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->getHtmlPublic($element, $itemId);
     } else {
         return $tmpl->fetch('like.html');
     }
 }
Beispiel #18
0
/**
 * Deprecated since 1.8
 */
function isRegisteredUser()
{
    return COwnerHelper::isRegisteredUser();
}
Beispiel #19
0
 public function _addSubmenu()
 {
     $task = JRequest::getVar('task', '', 'GET');
     $config =& CFactory::getConfig();
     $groupid = JRequest::getInt('groupid', '', 'GET');
     $categoryid = JRequest::getInt('categoryid', '', 'GET');
     $my =& CFactory::getUser();
     $backLink = array('sendmail', 'invitefriends', 'viewmembers', 'viewdiscussion', 'viewdiscussions', 'editdiscussion', 'viewbulletins', 'adddiscussion', 'addnews', 'viewbulletin', 'uploadavatar', 'edit', 'banlist');
     $groupsModel =& CFactory::getModel('groups');
     $isAdmin = $groupsModel->isAdmin($my->id, $groupid);
     $isSuperAdmin = COwnerHelper::isCommunityAdmin();
     // Load the group table.
     $group =& JTable::getInstance('Group', 'CTable');
     $group->load($groupid);
     $isBanned = $group->isBanned($my->id);
     if (in_array($task, $backLink)) {
         $this->addSubmenuItem('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupid, JText::_('COM_COMMUNITY_GROUPS_BACK_TO_GROUP'));
         $this->addSubmenuItem('index.php?option=com_community&view=groups&task=viewmembers&groupid=' . $groupid, JText::_('COM_COMMUNITY_GROUPS_ALL_MEMBERS'));
         if ($isAdmin || $isSuperAdmin) {
             $this->addSubmenuItem('index.php?option=com_community&view=groups&task=banlist&list=' . COMMUNITY_GROUP_BANNED . '&groupid=' . $groupid, JText::_('COM_COMMUNITY_GROUPS_BAN_LIST'));
         }
         if ($task == 'viewdiscussions' && !$isBanned) {
             $this->addSubmenuItem('index.php?option=com_community&view=groups&groupid=' . $groupid . '&task=adddiscussion', JText::_('COM_COMMUNITY_GROUPS_DISCUSSION_CREATE'), '', SUBMENU_RIGHT);
         }
         if ($task == 'viewbulletins' && ($isAdmin || $isSuperAdmin)) {
             $this->addSubmenuItem('index.php?option=com_community&view=groups&groupid=' . $groupid . '&task=addnews', JText::_('COM_COMMUNITY_GROUPS_BULLETIN_CREATE'), '', SUBMENU_RIGHT);
         }
         if ($task == 'viewmembers' && !$isBanned) {
             $friends = $groupsModel->getInviteFriendsList($my->id, $groupid);
             $userIds = '';
             $i = 0;
             if ($friends) {
                 foreach ($friends as $friend) {
                     if ($friend instanceof CUser) {
                         $userIds .= $friend->id;
                     } else {
                         $userIds .= $friend;
                     }
                     if ($i + 1 <= count($friend)) {
                         $userIds .= ',';
                     }
                     $i++;
                 }
             }
             $this->addSubmenuItem('index.php?option=com_community&view=groups&task=invitefriends&groupid=' . $groupid, JText::_('COM_COMMUNITY_TAB_INVITE'), 'joms.invitation.showForm(\'' . $userIds . '\', \'groups,inviteUsers\',' . $group->id . ',1,1);', SUBMENU_RIGHT);
         }
     } else {
         $this->addSubmenuItem('index.php?option=com_community&view=groups&task=display', JText::_('COM_COMMUNITY_GROUPS_ALL_GROUPS'));
         if (COwnerHelper::isRegisteredUser()) {
             $this->addSubmenuItem('index.php?option=com_community&view=groups&task=mygroups&userid=' . $my->id, JText::_('COM_COMMUNITY_GROUPS_MY_GROUPS'));
             $this->addSubmenuItem('index.php?option=com_community&view=groups&task=myinvites&userid=' . $my->id, JText::_('COM_COMMUNITY_GROUPS_PENDING_INVITES'));
         }
         if ($config->get('creategroups') && ($isSuperAdmin || COwnerHelper::isRegisteredUser() && $my->canCreateGroups())) {
             $creationLink = $categoryid ? 'index.php?option=com_community&view=groups&task=create&categoryid=' . $categoryid : 'index.php?option=com_community&view=groups&task=create';
             $this->addSubmenuItem($creationLink, JText::_('COM_COMMUNITY_GROUPS_CREATE'), '', SUBMENU_RIGHT);
         }
         if (!$config->get('enableguestsearchgroups') && COwnerHelper::isRegisteredUser() || $config->get('enableguestsearchgroups')) {
             $tmpl = new CTemplate();
             $html = $tmpl->set('url', CRoute::_('index.php?option=com_community&view=groups&task=search'))->fetch('groups.search.submenu');
             $this->addSubmenuItem('index.php?option=com_community&view=groups&task=search', JText::_('COM_COMMUNITY_GROUPS_SEARCH'), 'joms.groups.toggleSearchSubmenu(this)', false, $html);
         }
     }
 }
Beispiel #20
0
    /**
     * Show the connection request box
     */
    public function ajaxConnect($friendId)
    {
        // Block unregistered users.
        if (!COwnerHelper::isRegisteredUser()) {
            return $this->ajaxBlockUnregister();
        }
        $objResponse = new JAXResponse();
        $filter = JFilterInput::getInstance();
        $friendId = $filter->clean($friendId, 'int');
        //@todo filter paramater
        $model =& $this->getModel('friends');
        $blockModel =& $this->getModel('block');
        $my = CFactory::getUser();
        $view = $this->getView('friends');
        $user = CFactory::getUser($friendId);
        CFactory::load('libraries', 'block');
        $blockUser = new blockUser();
        $config = CFactory::getConfig();
        CFactory::load('helpers', 'owner');
        CFactory::load('libraries', 'limits');
        if (CLimitsLibrary::exceedDaily('friends')) {
            $actions = '<form method="post" action="" style="float:right;">';
            $actions .= '<input type="button" class="button" onclick="cWindowHide();return false;" name="cancel" value="' . JText::_('COM_COMMUNITY_BUTTON_CLOSE_BUTTON') . '" />';
            $actions .= '</form>';
            $html = JText::_('COM_COMMUNITY_LIMIT_FRIEND_REQUEST_REACHED');
            $objResponse->addScriptCall('cWindowAddContent', $html, $actions);
            return $objResponse->sendResponse();
        }
        // Block blocked users
        if ($blockModel->getBlockStatus($my->id, $friendId) && !COwnerHelper::isCommunityAdmin()) {
            $blockUser->ajaxBlockMessage();
        }
        // Warn owner that the user has been blocked, cannot add as friend
        if ($blockModel->getBlockStatus($friendId, $my->id)) {
            $blockUser->ajaxBlockWarn();
        }
        $connection = $model->getFriendConnection($my->id, $friendId);
        $html = '';
        $actions = '';
        CFactory::load('helpers', 'string');
        //@todo disallow self add as a friend
        //@todo disallow add existing friend
        if ($my->id == $friendId) {
            $html = JText::_('COM_COMMUNITY_FRIENDS_CANNOT_ADD_SELF');
        } elseif ($user->isBlocked()) {
            $html = JText::_('COM_COMMUNITY_FRIENDS_CANNOT_ADD_INACTIVE_USER');
        } elseif (count($connection) > 0) {
            if ($connection[0]->connect_from == $my->id) {
                $html = JText::sprintf('COM_COMMUNITY_FRIENDS_REQUEST_ALREADY_SENT', $user->getDisplayName());
            } else {
                $html = JText::sprintf('COM_COMMUNITY_FRIEND_REQUEST_ALREADY_RECEIVED', $user->getDisplayName());
            }
        } else {
            ob_start();
            ?>
			<div id="addFriendContainer">
				<p><?php 
            echo JText::sprintf('COM_COMMUNITY_CONFIRM_ADD_FRIEND', $user->getDisplayName());
            ?>
</p>
				<form name="addfriend" id="addfriend" method="post" action="">				
			        <img class="cAvatar" src="<?php 
            echo $user->getThumbAvatar();
            ?>
" alt="<?php 
            echo CStringHelper::escape($user->getDisplayName());
            ?>
" alt=""/>
					<textarea class="inputbox" name="msg"><?php 
            echo JText::_('COM_COMMUNITY_PROFILE_ADD_FRIEND_DEFAULT');
            ?>
</textarea>
					<input type="hidden" class="button" name="userid" value="<?php 
            echo $user->id;
            ?>
"/>
				</form>
			</div>
		<?php 
            $html = ob_get_contents();
            ob_end_clean();
            $actions = '<button class="button" onclick="joms.friends.addNow();" name="save">' . JText::_('COM_COMMUNITY_FRIENDS_ADD_BUTTON') . '</button>';
            $actions .= '<button class="button" onclick="javascript:cWindowHide();" name="cancel">' . JText::_('COM_COMMUNITY_CANCEL_BUTTON') . '</button>';
        }
        $objResponse->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_FRIENDS_ADD_NEW_FRIEND'));
        $objResponse->addScriptCall('cWindowAddContent', $html, $actions);
        return $objResponse->sendResponse();
    }
Beispiel #21
0
 public function ajaxRotatePhoto($photoId, $orientation)
 {
     CFactory::load('helpers', 'owner');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $photo =& JTable::getInstance('Photo', 'CTable');
     $photo->load($photoId);
     if ($photo->storage != 'file') {
         // we don't want to support s3
         return false;
     }
     if ($photo->storage != 'file') {
         // download the image files to local server
         CFactory::load('libraries', 'storage');
         $storage = CStorage::getStorage($photoStorage);
         $currentStorage = CStorage::getStorage($photo->storage);
         if ($currentStorage->exists($photo->image)) {
             $jconfig = JFactory::getConfig();
             $jTempPath = $jconfig->getValue('tmp_path');
             $tempFilename = $jTempPath . DS . md5($photo->image);
             $currentStorage->get($photo->image, $tempFilename);
             $thumbsTemp = $jTempPath . DS . 'thumb_' . md5($photo->thumbnail);
             $currentStorage->get($photo->thumbnail, $thumbsTemp);
             if (JFile::exists($tempFilename) && JFile::exists($thumbsTemp) && $storage->put($row->image, $tempFilename) && $storage->put($photo->thumbnail, $thumbsTemp)) {
                 $currentStorage->delete($photo->image);
                 $currentStorage->delete($photo->thumbnail);
                 JFile::delete($tempFilename);
                 JFile::delete($thumbsTemp);
             }
         }
     }
     $photoPath = JPath::clean(JPATH_ROOT . DS . $photo->image);
     $thumbPath = JPath::clean(JPATH_ROOT . DS . $photo->thumbnail);
     // Hash the image file name so that it gets as unique possible
     $fileName = JUtility::getHash($photo->image . time());
     $fileName = JString::substr($fileName, 0, 24);
     $fileName = $fileName . '.' . JFile::getExt($photo->image);
     $fileNameLength = strlen($photo->image) - strrpos($photo->image, '/') - 1;
     $newPhotoPath = substr_replace($photoPath, $fileName, -$fileNameLength);
     $newThumbPath = substr_replace($photoPath, 'thumb_' . $fileName, -$fileNameLength);
     $degrees = 0;
     if (JFile::exists($photoPath) && JFile::exists($thumbPath)) {
         switch ($orientation) {
             case 'left':
                 $degrees = 90;
                 break;
             case 'right':
                 $degrees = -90;
                 break;
             default:
                 $degrees = 0;
                 break;
         }
         if ($degrees !== 0) {
             CFactory::load('helpers', 'image');
             CImageHelper::rotate($photoPath, $newPhotoPath, $degrees);
             CImageHelper::rotate($thumbPath, $newThumbPath, $degrees);
             $newPhotoPath = JString::str_ireplace(JPATH_ROOT . DS, '', $newPhotoPath);
             $newThumbPath = JString::str_ireplace(JPATH_ROOT . DS, '', $newThumbPath);
             $newPhotoPath = JString::str_ireplace('\\', '/', $newPhotoPath);
             $newThumbPath = JString::str_ireplace('\\', '/', $newThumbPath);
             $photo->storage = 'file';
             //just to make sure it's in the local server
             $photo->image = $newPhotoPath;
             $photo->thumbnail = $newThumbPath;
             $photo->store();
         }
     }
     $response = new JAXResponse();
     $response->addScriptCall('__callback', $photo->id, $photo->getImageURI(), $photo->getThumbURI());
     return $response->sendResponse();
 }
Beispiel #22
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();
 }
Beispiel #23
0
 public static function groupsWallDelete($userId, $groupId)
 {
     $groupModel = CFactory::getModel('groups');
     if (!COwnerHelper::isRegisteredUser()) {
         CAccess::setError('blockUnregister');
         return false;
     } else {
         if (!COwnerHelper::isCommunityAdmin() && !$groupModel->isAdmin($userId, $groupId)) {
             CAccess::setError(JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_REMOVE_WALL'));
             return false;
         } else {
             return true;
         }
     }
 }
Beispiel #24
0
 public function ajaxUpdateStatus($eventId, $status)
 {
     $filter = JFilterInput::getInstance();
     $eventId = $filter->clean($eventId, 'int');
     $status = $filter->clean($status, 'int');
     $target = NULL;
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $my = CFactory::getUser();
     $objResponse = new JAXResponse();
     $memberId = $my->id;
     $modal =& $this->getModel('events');
     $event =& JTable::getInstance('Event', 'CTable');
     $event->load($eventId);
     CFactory::load('helpers', 'event');
     $handler = CEventHelper::getHandler($event);
     if (!$handler->isAllowed()) {
         $objResponse->addAlert(JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN'));
         return $objResponse->sendResponse();
     }
     if ($event->ticket && ($status == COMMUNITY_EVENT_STATUS_ATTEND && $event->confirmedcount + 1 > $event->ticket)) {
         $objResponse->addAlert(JText::_('COM_COMMUNITY_EVENTS_TICKET_FULL'));
         return $objResponse->sendResponse();
     }
     $eventMember =& JTable::getInstance('EventMembers', 'CTable');
     $eventMember->load($memberId, $eventId);
     if ($eventMember->permission != 1 && $eventMember->permission != 2) {
         $eventMember->permission = 3;
     }
     $date =& JFactory::getDate();
     $eventMember->created = $date->toMYSQL();
     $eventMember->status = $status;
     $eventMember->store();
     $event->updateGuestStats();
     $event->store();
     //activities stream goes here.
     $url = $handler->getFormattedLink('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false);
     CFactory::load('helpers', 'event');
     // We update the activity only if a user attend an event and the event was set to public event
     if ($status == COMMUNITY_EVENT_STATUS_ATTEND && $handler->isPublic()) {
         $command = 'events.attendence.attend';
         $actor = $my->id;
         $target = 0;
         $content = '';
         $cid = $event->id;
         $app = 'events';
         $act = $handler->getActivity($command, $actor, $target, $content, $cid, $app);
         $act->eventid = $event->id;
         $params = new CParameter('');
         $action_str = 'events.attendence.attend';
         $params->set('eventid', $event->id);
         $params->set('action', $action_str);
         $params->set('event_url', $url);
         // Add activity logging
         CFactory::load('libraries', 'activities');
         CActivityStream::add($act, $params->toString());
     }
     //trigger goes here.
     CFactory::load('libraries', 'apps');
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $params = array();
     $params[] =& $event;
     $params[] = $my->id;
     $params[] = $status;
     if (!is_null($target)) {
         $params[] = $target;
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_EVENTS, COMMUNITY_CACHE_TAG_ACTIVITIES));
     CFactory::load('libraries', 'events');
     $html = CEvents::getEventMemberHTML($event->id);
     if ($status == COMMUNITY_EVENT_STATUS_ATTEND) {
         $RSVPmessage = JText::_('COM_COMMUNITY_EVENTS_ATTENDING_EVENT_MESSAGE');
     } else {
         $RSVPmessage = JText::_('COM_COMMUNITY_EVENTS_NOT_ATTENDING_EVENT_MESSAGE');
     }
     $objResponse->addScriptCall('__callback', $html);
     $objResponse->addScriptCall("joms.jQuery('#community-event-rsvp-alert .cdata').html('{$RSVPmessage}');");
     return $objResponse->sendResponse();
 }
Beispiel #25
0
<?php

/**
 * @package	JomSocial
 * @subpackage 	Template 
 * @copyright	(C) 2008 by Slashes & Dots Sdn Bhd - All rights reserved!
 * @license	GNU/GPL, see LICENSE.php
 * 
 */
defined('_JEXEC') or die;
if (COwnerHelper::isRegisteredUser()) {
    ?>
<span id="<?php 
    echo $likeId;
    ?>
" class="like-snippet">
	
	<?php 
    if ($likes > 0) {
        ?>
		<?php 
        if ($userLiked == COMMUNITY_LIKE) {
            ?>
			<a class="meLike" href="javascript:void(0);" onclick="joms.like.unlike(this);" title="<?php 
            echo JText::_('CC LIKE ITEM');
            ?>
. <?php 
            echo JText::_('CC UNLIKE');
            ?>
?"><?php 
            echo $likes;
Beispiel #26
0
 /**
  * Ajax function to decline Private Group Request
  *
  **/
 public function ajaxGroupRejectRequest($memberId, $groupId)
 {
     $filter = JFilterInput::getInstance();
     $groupId = $filter->clean($groupId, 'int');
     $memberId = $filter->clean($memberId, 'int');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $objResponse = new JAXResponse();
     $my = CFactory::getUser();
     $model = $this->getModel('groups');
     $group = JTable::getInstance('Group', 'CTable');
     $group->load($groupId);
     //CFactory::load( 'helpers' , 'owner' );
     if (!$group->isAdmin($my->id, $groupId) && !COwnerHelper::isCommunityAdmin()) {
         $objResponse->addScriptCall(JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION'));
     } else {
         //Load Necessary Table
         $groupMember = JTable::getInstance('GroupMembers', 'CTable');
         $data = new stdClass();
         $data->groupid = $groupId;
         $data->memberid = $memberId;
         $model->removeMember($data);
         //add user points
         //CFactory::load( 'libraries' , 'userpoints' );
         CUserPoints::assignPoint('group.member.remove', $memberId);
         //trigger for onGroupLeave
         $this->triggerEvents('onGroupLeave', $group, $memberId);
         $group->updateStats();
         $group->store();
         $url = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
         $objResponse->addScriptCall('joms.jQuery("#msg-request-' . $memberId . '").html("' . addslashes(JText::sprintf('COM_COMMUNITY_EVENTS_REJECTED', $group->name, $url)) . '");');
         $objResponse->addScriptCall('joms.notifications.updateNotifyCount();');
         $objResponse->addScriptCall('joms.jQuery("#noti-request-group-' . $memberId . '").fadeOut(1000, function() { joms.jQuery("#noti-request-group-' . $memberId . '").remove();} );');
         $objResponse->addScriptCall('aspan = joms.jQuery("#jsMenu .jsMenuIcon span"); aspan.html(parseInt(aspan.html())-1);');
     }
     return $objResponse->sendResponse();
 }
Beispiel #27
0
 /**
  * @todo: check permission and message ownership
  */
 public function ajaxCompose($id)
 {
     $filter = JFilterInput::getInstance();
     $id = $filter->clean($id, 'int');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $objResponse = new JAXResponse();
     $config = CFactory::getConfig();
     $user = CFactory::getUser($id);
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     //CFactory::load( 'helpers' , 'owner' );
     //CFactory::load( 'libraries' , 'block' );
     $getBlockStatus = new blockUser();
     // Block banned users
     if ($getBlockStatus->isUserBlocked($id, 'inbox') && !COwnerHelper::isCommunityAdmin()) {
         $this->ajaxblock();
     }
     $inboxModel = $this->getModel('inbox');
     $lastSent = $inboxModel->getLastSentTime($my->id);
     $dateNow = new JDate();
     // We need to make sure that this guy are not spamming other people inbox
     // by checking against his last message time. Make sure it doesn't exceed
     // pmFloodLimit config (in seconds).
     if ($dateNow->toUnix() - $lastSent->toUnix() < $config->get('floodLimit') && !COwnerHelper::isCommunityAdmin()) {
         $json = array();
         $json['title'] = JText::_('COM_COMMUNITY_NOTICE');
         $json['error'] = JText::sprintf('COM_COMMUNITY_PLEASE_WAIT_BEFORE_SENDING_MESSAGE', $config->get('floodLimit'));
         die(json_encode($json));
     }
     // Check if user exceeded daily limit.
     $maxSent = $config->get('pmperday');
     $totalSent = $inboxModel->getTotalMessageSent($my->id);
     if ($totalSent >= $maxSent && $maxSent != 0) {
         $json = array();
         $json['title'] = JText::_('COM_COMMUNITY_NOTICE');
         $json['error'] = JText::_('COM_COMMUNITY_PM_LIMIT_REACHED');
         die(json_encode($json));
     }
     //====================================
     $tmpl = new CTemplate();
     $tmpl->set('user', $user);
     $json = array('title' => JText::_('COM_COMMUNITY_INBOX_TITLE_WRITE'), 'html' => $tmpl->fetch('inbox.ajaxcompose'), 'btnSend' => JText::_('COM_COMMUNITY_SEND_BUTTON'), 'btnCancel' => JText::_('COM_COMMUNITY_CANCEL_BUTTON'));
     die(json_encode($json));
 }
Beispiel #28
0
 /**
  * Main events page display
  * @return type
  */
 public function myevents()
 {
     //if (!$this->accessAllowed('registered')) {
     //return;
     //}
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $document = JFactory::getDocument();
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     $userid = $jinput->get('userid', $my->id, 'INT');
     $currentUser = CFactory::getUser($userid);
     $groupId = $jinput->get->get('groupid', '', 'INT');
     //JRequest::getVar('groupid','', 'GET');
     $this->addPathway(JText::_('COM_COMMUNITY_EVENTS'), CRoute::_('index.php?option=com_community&view=events'));
     $this->addPathway(JText::sprintf('COM_COMMUNITY_USER_EVENTS', $currentUser->getDisplayName()), '');
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::sprintf('COM_COMMUNITY_USER_EVENTS', $currentUser->getDisplayName()));
     $feedLink = CRoute::_('index.php?option=com_community&view=events&userid=' . $userid . '&format=feed');
     $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_MY_EVENTS_FEED') . '" href="' . $feedLink . '"/>';
     $document->addCustomTag($feed);
     $data = new stdClass();
     $sorted = $jinput->get->get('sort', 'startdate', 'STRING');
     //JRequest::getVar( 'sort' , 'startdate' , 'GET' );
     $model = CFactory::getModel('events');
     // It is safe to pass 0 as the category id as the model itself checks for this value.
     $data->events = $model->getEvents(null, $userid, $sorted);
     // Get pagination object
     $data->pagination = $model->getPagination();
     // Get the template for the group lists
     $eventsHTML = $this->_cachedCall('_getEventsHTML', array($data->events, false, $data->pagination), '', array(COMMUNITY_CACHE_TAG_EVENTS));
     $tmpl = new CTemplate();
     $sortItems = array('latest' => JText::_('COM_COMMUNITY_EVENTS_SORT_CREATED'), 'startdate' => JText::_('COM_COMMUNITY_EVENTS_SORT_COMING'));
     $title = JText::_('COM_COMMUNITY_EVENTS_MINE');
     if ($groupId) {
         $title = JText::_('COM_COMMUNITY_EVENT_GROUP_MINE');
     } elseif ($userid != $my->id) {
         $title = JText::sprintf('COM_COMMUNITY_USER_EVENTS', CFactory::getUser($userid)->getDisplayName());
     }
     $config = CFactory::getConfig();
     $canSearch = !$config->get('enableguestsearchevents') && COwnerHelper::isRegisteredUser() || $config->get('enableguestsearchevents') ? true : false;
     $tmpl->set('eventsHTML', $eventsHTML)->set('canSearch', $canSearch)->set('pageTitle', $title)->set('config', $config)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('sortings', CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'startdate'))->set('submenu', $this->showSubmenu(false))->set('createLink', $groupId ? CRoute::_('index.php?option=com_community&view=events&groupid=' . $groupId . '&task=create') : CRoute::_('index.php?option=com_community&view=events&task=create'))->set('my', $my);
     if ($userid == $my->id) {
         $tmpl->set('canCreate', $my->authorise('community.create', 'events'));
     } else {
         $tmpl->set('canCreate', 0);
     }
     echo $tmpl->fetch('events/base');
 }
Beispiel #29
0
 /**
  *
  * @return string
  */
 public function getHTML($element, $itemId, $userId)
 {
     // @rule: Only display likes html codes when likes is allowed.
     $config =& CFactory::getConfig();
     if (!$config->get('likes_' . $element)) {
         return;
     }
     // TODO: WRAP into another function
     $likesModel =& CFactory::getModel('Like');
     $info = $likesModel->getInfo($element, $itemId);
     $likes = 0;
     $dislikes = 0;
     $userLiked = COMMUNITY_UNLIKE;
     if ($info) {
         $like =& JTable::getInstance('Like', 'CTable');
         $like->load($info->id);
         $likesInArray = array();
         $dislikesInArray = array();
         if ($like) {
             $likesInArray = explode(',', $like->like);
             $dislikesInArray = explode(',', $like->dislike);
         }
         $likes = count($likesInArray) - 1;
         $dislikes = count($dislikesInArray) - 1;
         $userLiked = $this->userLiked($element, $itemId, $userId);
     }
     $tmpl = new CTemplate();
     $tmpl->set('likeId', 'like' . '-' . $element . '-' . $itemId);
     $tmpl->set('likes', $likes);
     $tmpl->set('dislikes', $dislikes);
     $tmpl->set('userLiked', $userLiked);
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->getHtmlPublic($element, $itemId);
     } else {
         return $tmpl->fetch('like.html');
     }
 }
Beispiel #30
0
 /**
  * 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();
 }