static function getActivityContentHTML($act)
 {
     // Ok, the activity could be an upload OR a wall comment. In the future, the content should
     // indicate which is which
     $html = '';
     $param = new CParameter($act->params);
     $action = $param->get('action', false);
     $count = $param->get('count', false);
     $config = CFactory::getConfig();
     switch ($action) {
         case CAdminstreamsAction::TOP_USERS:
             $model = CFactory::getModel('user');
             $members = $model->getPopularMember($count);
             $html = '';
             //Get Template Page
             $tmpl = new CTemplate();
             $html = $tmpl->set('members', $members)->fetch('activity.members.popular');
             return $html;
             break;
         case CAdminstreamsAction::TOP_PHOTOS:
             $model = CFactory::getModel('photos');
             $photos = $model->getPopularPhotos($count, 0);
             $tmpl = new CTemplate();
             $html = $tmpl->set('photos', $photos)->fetch('activity.photos.popular');
             return $html;
             break;
         case CAdminstreamsAction::TOP_VIDEOS:
             $model = CFactory::getModel('videos');
             $videos = $model->getPopularVideos($count);
             $tmpl = new CTemplate();
             $html = $tmpl->set('videos', $videos)->fetch('activity.videos.popular');
             return $html;
             break;
     }
 }
Exemple #2
0
 /**
  * Inject data from paramter to content tags ({}) .
  *
  * @param	$content	Original content with content tags.
  * @param	$params	Text contain all values need to be replaced.
  * @param	$html	Auto detect url tag and insert inline.
  * @return	$text	The content after replacing.
  **/
 public static function injectTags($content, $paramsTxt, $html = false)
 {
     $params = new CParameter($paramsTxt);
     preg_match_all("/{(.*?)}/", $content, $matches, PREG_SET_ORDER);
     if (!empty($matches)) {
         foreach ($matches as $val) {
             $replaceWith = JString::trim($params->get($val[1], null));
             if (!is_null($replaceWith)) {
                 //if the replacement start with 'index.php', we can CRoute it
                 if (JString::strpos($replaceWith, 'index.php') === 0) {
                     $replaceWith = CRoute::getExternalURL($replaceWith);
                 }
                 if ($html) {
                     $replaceUrl = $params->get($val[1] . '_url', null);
                     if (!is_null($replaceUrl)) {
                         if ($val[1] == 'stream') {
                             $replaceUrl .= '#activity-stream-container';
                         }
                         //if the replacement start with 'index.php', we can CRoute it
                         if (JString::strpos($replaceUrl, 'index.php') === 0) {
                             $replaceUrl = CRoute::getExternalURL($replaceUrl);
                         }
                         $replaceWith = '<a href="' . $replaceUrl . '">' . $replaceWith . '</a>';
                     }
                 }
                 $content = CString::str_ireplace($val[0], $replaceWith, $content);
             }
         }
     }
     return $content;
 }
Exemple #3
0
 function onActivityContentDisplay($args)
 {
     $model =& CFactory::getModel('Wall');
     $wall =& JTable::getInstance('Wall', 'CTable');
     $my = CFactory::getUser();
     if (empty($args->content)) {
         return '';
     }
     $wall->load($args->cid);
     CFactory::load('libraries', 'privacy');
     CFactory::load('libraries', 'comment');
     $comment = CComment::stripCommentData($wall->comment);
     $config = CFactory::getConfig();
     $commentcut = false;
     if (strlen($comment) > $config->getInt('streamcontentlength')) {
         $origcomment = $comment;
         $comment = JString::substr($comment, 0, $config->getInt('streamcontentlength')) . ' ...';
         $commentcut = true;
     }
     if (CPrivacy::isAccessAllowed($my->id, $args->target, 'user', 'privacyProfileView')) {
         CFactory::load('helpers', 'videos');
         CFactory::load('libraries', 'videos');
         CFactory::load('libraries', 'wall');
         $videoContent = '';
         $params = new CParameter($args->params);
         $videoLink = $params->get('videolink');
         $image = $params->get('url');
         // For older activities that does not have videoLink , we need to process it the old way.
         if (!$videoLink) {
             $html = CWallLibrary::_processWallContent($comment);
             $tmpl = new CTemplate();
             $html = CStringHelper::escape($html);
             if ($commentcut) {
                 //add read more/less link for content
                 $html .= '<br /><br /><a href="javascript:void(0)" onclick="jQuery(\'#shortcomment_' . $args->cid . '\').hide(); jQuery(\'#origcomment_' . $args->cid . '\').show();" >' . JText::_('COM_COMMUNITY_READ_MORE') . '</a>';
                 $html = '<div id="shortcomment_' . $args->cid . '">' . $html . '</div>';
                 $html .= '<div id="origcomment_' . $args->cid . '" style="display:none;">' . $origcomment . '<br /><br /><a href="javascript:void(0);" onclick="jQuery(\'#shortcomment_' . $args->cid . '\').show(); jQuery(\'#origcomment_' . $args->cid . '\').hide();" >' . JText::_('COM_COMMUNITY_READ_LESS') . '</a></div>';
             }
             $tmpl->set('comment', $html);
             $html = $tmpl->fetch('activity.wall.post');
         } else {
             $html = '<ul class ="cDetailList clrfix">';
             $html .= '<li>';
             $image = !$image ? rtrim(JURI::root(), '/') . '/components/com_community/assets/playvideo.gif' : $image;
             $videoLib = new CVideoLibrary();
             $provider = $videoLib->getProvider($videoLink);
             $html .= '<!-- avatar --><div class="avatarWrap"><a href="javascript:void(0);" onclick="joms.activities.showVideo(\'' . $args->id . '\');"><img width="64" src="' . $image . '" class="cAvatar"/></a></div><!-- avatar -->';
             $videoPlayer = $provider->getViewHTML($provider->getId(), '300', '300');
             $comment = CString::str_ireplace($videoLink, '', $comment);
             $html .= '<!-- details --><div class="detailWrap alpha">' . $comment . '</div><!-- details -->';
             if (!empty($videoPlayer)) {
                 $html .= '<div style="display: none;clear: both;padding-top: 5px;" class="video-object">' . $videoPlayer . '</div>';
             }
             $html .= '</li>';
             $html .= '</ul>';
         }
         return $html;
     }
 }
 public function getMessage($field)
 {
     $params = new CParameter($field['params']);
     if ($params->get('min_char') && $params->get('max_char') && !$this->validLength($field['value'])) {
         return JText::sprintf('COM_COMMUNITY_FIELD_CONTAIN_OUT_OF_RANGE', $field['name'], $params->get('max_char'), $params->get('min_char'));
     }
     return JText::sprintf('COM_COMMUNITY_FIELD_CONTAIN_IMPROPER_VALUES', JText::_($field['name']));
 }
Exemple #5
0
 public static function getConfiguration()
 {
     static $configuration = null;
     if (is_null($configuration)) {
         $plugin = JPluginHelper::getPlugin('community', 'twitter');
         $params = new CParameter($plugin->params);
         $my = CFactory::getUser();
         $oauth = JTable::getInstance('Oauth', 'CTable');
         $loaded = $oauth->load($my->id, 'twitter');
         $accesstoken = unserialize($oauth->accesstoken);
         $configuration = array('consumer_key' => $params->get('consumerKey', '0rSLnHLm1cpX1sTsqkQaQ'), 'consumer_secret' => $params->get('consumerSecret', 'nsCObKFeJFP9YYGOZoHAHAWfvjZIZ4Hv7M8Y1w1flQ'), 'user_token' => $accesstoken['user_token'], 'user_secret' => $accesstoken['user_secret'], 'curl_ssl_verifypeer' => false);
     }
     return $configuration;
 }
Exemple #6
0
 public static function getActivityContentHTML($act)
 {
     // Ok, the activity could be an upload OR a wall comment. In the future, the content should
     // indicate which is which
     CFactory::load('models', 'photos');
     $html = '';
     $param = new CParameter($act->params);
     $action = $param->get('action', false);
     $photoid = $param->get('photoid', 0);
     $url = $param->get('url', false);
     CFactory::load('helpers', 'albums');
     if ($action == 'wall') {
         // unfortunately, wall post can also have 'photo' as its $act->apps. If the photo id is availble
         // for (newer activity stream, inside the param), we will show the photo snippet as well. Otherwise
         // just print out the wall content
         // Version 1.6 onwards, $params will contain photoid information
         // older version would have #photoid in the $title, since we link it to the photo
         $photoid = $param->get('photoid', false);
         if ($photoid) {
             $photo = JTable::getInstance('Photo', 'CTable');
             $photo->load($act->cid);
             $helper = new CAlbumsHelper($photo->albumid);
             if ($helper->showActivity()) {
                 $tmpl = new CTemplate();
                 return $tmpl->set('url', $url)->set('photo', $photo)->set('param', $param)->set('act', $act)->fetch('activity.photos.wall');
             }
         }
         return '';
     } elseif ($action == 'upload' && $photoid > 0) {
         $photoModel = CFactory::getModel('photos');
         $album = JTable::getInstance('Album', 'CTable');
         $album->load($act->cid);
         $albumsHelper = new CAlbumsHelper($album);
         if ($albumsHelper->isPublic()) {
             // If content has link to image, we could assume it is "upload photo" action
             // since old content add this automatically.
             // The $act->cid will be the album id, Retrive the recent photos uploaded
             // If $act->activities has data, that means this is an aggregated content
             // display some of them
             if (empty($act->activities)) {
                 $acts[] = $act;
             } else {
                 $acts = $act->activities;
             }
             $tmpl = new CTemplate();
             return $tmpl->set('album', $album)->set('acts', $acts)->set('stream', $param->get('stream', false))->fetch('activity.photos.upload');
         }
     }
     return $html;
 }
Exemple #7
0
 public function getFieldHTML($field, $required)
 {
     $html = '';
     $selectedElement = 0;
     $elementSelected = 0;
     $elementCnt = 0;
     $params = new CParameter($field->params);
     $readonly = $params->get('readonly') && !COwnerHelper::isCommunityAdmin() ? ' disabled="disabled"' : '';
     for ($i = 0; $i < count($field->options); $i++) {
         $option = $field->options[$i];
         $selected = $option == $field->value ? ' checked="checked"' : '';
         if (empty($selected)) {
             $elementSelected++;
         }
         $elementCnt++;
     }
     $cnt = 0;
     $html .= '<div style="display:inline-block" title="' . CStringHelper::escape(JText::_($field->tips)) . '">';
     for ($i = 0; $i < count($field->options); $i++) {
         $option = $field->options[$i];
         $selected = html_entity_decode($option) == html_entity_decode($field->value) ? ' checked="checked"' : '';
         $html .= '<label class="lblradio-block">';
         $html .= '<input type="radio" name="field' . $field->id . '" value="' . $option . '"' . $selected . $readonly . ' style="margin: 2px 5px 0 0" />';
         $html .= JText::_($option) . '</label>';
     }
     $html .= '</div>';
     return $html;
 }
Exemple #8
0
 public static function removeUserTag($id, $type = 'comment')
 {
     $my = CFactory::getUser();
     $pattern = '/@\\[\\[(' . $my->id . '):([a-z]+):([^\\]]+)\\]\\]/';
     if ($type == 'post') {
         $activity = CApiActivities::get($id);
         $result = $activity->title = preg_replace($pattern, '$3', $activity->title);
         $activity->save();
     } else {
         if ($type == 'inbox') {
             $message = JTable::getInstance('Message', 'CTable');
             $message->load($id);
             $params = new CParameter($message->body);
             $result = $params->get('content');
             $result = preg_replace($pattern, '$3', $result);
             $params->set('content', $result);
             $message->body = $params->toString();
             $message->store();
         } else {
             $wall = JTable::getInstance('Wall', 'CTable');
             $wall->load($id);
             $result = $wall->comment = preg_replace($pattern, '$3', $wall->comment);
             $wall->store();
         }
     }
     return $result;
 }
Exemple #9
0
 public function getFieldHTML($field, $required)
 {
     $html = '';
     $selectedElement = 0;
     $required = $field->required == 1 ? ' data-required="true"' : '';
     $style = ' style="margin: 0 5px 0 0;' . $this->getStyle() . '" ';
     $params = new CParameter($field->params);
     $disabled = '';
     if ($params->get('readonly') == 1) {
         $disabled = 'disabled="disabled"';
     }
     // Gender contain only male and female
     $options = array("" => "COM_COMMUNITY_SELECT_GENDER", "COM_COMMUNITY_MALE" => "COM_COMMUNITY_MALE", "COM_COMMUNITY_FEMALE" => "COM_COMMUNITY_FEMALE");
     $cnt = 0;
     //CFactory::load( 'helpers' , 'string' );
     // REMOVE 3.3
     // $class = !empty($field->tips) ? 'jomNameTips tipRight' : '';
     // REMOVE 3.3
     // $html .= '<div class="' . $class . '" style="display: inline-block;" title="' . CStringHelper::escape(JText::_($field->tips)) . '">';
     $html .= '<select class="joms-select" name="field' . $field->id . '" ' . $required . ' ' . $disabled . ' >';
     foreach ($options as $key => $val) {
         $selected = $key == $field->value ? ' selected="selected" ' : '';
         $html .= '<option value="' . $key . '" ' . $selected . '>' . JText::_($val) . '</option>';
     }
     $html .= '</select>';
     // REMOVE 3.3
     // $html .= '<span id="errfield' . $field->id . 'msg" style="display: none;">&nbsp;</span>';
     // $html .= '</div>';
     return $html;
 }
Exemple #10
0
    public function getFieldHTML($field, $required)
    {
        // If maximum is not set, we define it to a default
        $field->max = empty($field->max) ? 200 : $field->max;
        //get the value in param
        $params = new CParameter($field->params);
        $style = $this->getStyle() ? '' : ' style="' . $this->getStyle() . '" ';
        $class = $field->required == 1 ? ' required' : '';
        $class .= $params->get('min_char') != '' && $params->get('max_char') != '' ? ' minmax_' . $params->get('min_char') . '_' . $params->get('max_char') : '';
        $class .= !empty($field->tips) ? ' jomNameTips tipRight' : '';
        CFactory::load('helpers', 'string');
        ob_start();
        ?>
	<input class="inputbox validate-profile-email<?php 
        echo $class;
        ?>
" title="<?php 
        echo CStringHelper::escape(JText::_($field->tips));
        ?>
" type="text" value="<?php 
        echo $field->value;
        ?>
" id="field<?php 
        echo $field->id;
        ?>
" name="field<?php 
        echo $field->id;
        ?>
" maxlength="<?php 
        echo $field->max;
        ?>
" size="40" <?php 
        echo $style;
        ?>
	 />
	<span id="errfield<?php 
        echo $field->id;
        ?>
msg" style="display:none;">&nbsp;</span>
<?php 
        $html = ob_get_contents();
        ob_end_clean();
        return $html;
    }
Exemple #11
0
 public function getFieldHTML($field, $required)
 {
     $params = new CParameter($field->params);
     $readonly = $params->get('readonly') && !COwnerHelper::isCommunityAdmin() ? ' readonly=""' : '';
     $style = $this->getStyle() ? ' style="' . $this->getStyle() . '"' : '';
     $required = $field->required == 1 ? ' data-required="true"' : '';
     // If maximum is not set, we define it to a default
     $field->max = empty($field->max) ? 200 : $field->max;
     $html = '<input type="text" value="' . $field->value . '" id="field' . $field->id . '" name="field' . $field->id . '" maxlength="' . $field->max . '" class="joms-input" ' . $readonly . $required . $style . ' />';
     return $html;
 }
Exemple #12
0
 public function getFieldData($field)
 {
     $value = $field['value'];
     if (empty($value)) {
         return $value;
     }
     $params = new CParameter($field['params']);
     $format = $params->get('display');
     if (!class_exists('CFactory')) {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php';
     }
     $ret = '';
     if ($format == 'age') {
         // PHP version > 5.2
         $datetime = new DateTime($value);
         $now = new DateTime('now');
         // PHP version > 5.3
         if (method_exists($datetime, 'diff')) {
             $interval = $datetime->diff($now);
             $ret = $interval->format('%Y');
         } else {
             $mth = $now->format('m') - $datetime->format('m');
             $day = $now->format('d') - $datetime->format('d');
             $ret = $now->format('Y') - $datetime->format('Y');
             if ($mth >= 0) {
                 if ($day < 0 && $mth == 0) {
                     $ret--;
                 }
             } else {
                 $ret--;
             }
         }
     } else {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'models' . DS . 'profile.php';
         $model = CFactory::getModel('profile');
         //overwrite Profile date format in Configuration
         $format = $params->get('date_format');
         $ret = $model->formatDate($value, $format);
     }
     return $ret;
 }
Exemple #13
0
 public function getFieldHTML($field, $required)
 {
     $params = new CParameter($field->params);
     $readonly = $params->get('readonly') && !COwnerHelper::isCommunityAdmin() ? ' readonly=""' : '';
     // REMOVE 3.3
     // $style = $this->getStyle() ? ' style="' . $this->getStyle() . '" ' : '';
     //extract the max char since the settings is in params
     $max_char = $params->get('max_char');
     $config = CFactory::getConfig();
     // $js = 'assets/validate-1.5.min.js';
     // CFactory::attach($js, 'js');
     // If maximum is not set, we define it to a default
     $required = $field->required == 1 ? ' data-required="true"' : '';
     // REMOVE 3.3
     // $class .=!empty($field->tips) ? ' jomNameTips tipRight' : '';
     $html = '<textarea id="field' . $field->id . '" name="field' . $field->id . '" class="joms-textarea" ' . $readonly . $required . ' >' . $field->value . '</textarea>';
     // REMOVE 3.3
     // $html .= '<span id="errfield' . $field->id . 'msg" style="display:none;">&nbsp;</span>';
     if (!empty($max_char)) {
         $html .= '<script type="text/javascript">cvalidate.setMaxLength("#field' . $field->id . '", "' . $max_char . '");</script>';
     }
     return $html;
 }
Exemple #14
0
 public function getFieldHTML($field, $required)
 {
     $lists = array();
     //a fix for wrong data input
     $field->value = JString::trim($field->value);
     if (is_array($field->value)) {
         $tmplist = $field->value;
     } else {
         if (JString::strrpos($field->value, ',') == JString::strlen($field->value) - 1) {
             $field->value = JString::substr($field->value, 0, -1);
         }
         $tmplist = explode(',', $field->value);
     }
     if ($tmplist) {
         foreach ($tmplist as $value) {
             $lists[] = JString::trim($value);
         }
     }
     $html = '';
     $elementSelected = 0;
     $elementCnt = 0;
     $cnt = 0;
     $params = new CParameter($field->params);
     $readonly = '';
     if ($params->get('readonly') == 1) {
         $readonly = ' disabled="disabled"';
     }
     $html .= '<div style="display:inline-block">';
     if (is_array($field->options)) {
         foreach ($field->options as $option) {
             if (JString::trim($option) == '') {
                 //do not display blank options
                 continue;
             }
             $selected = in_array(JString::trim($option), $lists) ? ' checked="checked"' : '';
             if (empty($selected)) {
                 $elementSelected++;
             }
             $html .= '<label class="lblradio-block">';
             $html .= '<input type="checkbox" name="field' . $field->id . '[]" value="' . $option . '" class="joms-checkbox" ' . $selected . $readonly . ' style="margin: 2px 5px 0 0" />';
             $html .= JText::_($option) . '</label>';
             $elementCnt++;
         }
     }
     $html .= '</div>';
     return $html;
 }
Exemple #15
0
 public function getFieldHTML($field, $required)
 {
     $params = new CParameter($field->params);
     $readonly = $params->get('readonly') ? ' readonly=""' : '';
     $style = $this->getStyle() ? '' : ' style="' . $this->getStyle() . '" ';
     // If maximum is not set, we define it to a default
     $field->max = empty($field->max) ? 200 : $field->max;
     CFactory::load('helpers', 'string');
     $class = $field->required == 1 ? ' required' : '';
     $class .= !empty($field->tips) ? ' jomNameTips tipRight' : '';
     $tooltipcss = "";
     if (!empty($field->tips)) {
         $tooltipcss = "jomNameTips";
     }
     $html = '<input title="' . CStringHelper::escape(JText::_($field->tips)) . '" type="text" value="' . $field->value . '" id="field' . $field->id . '" name="field' . $field->id . '" maxlength="' . $field->max . '" size="40" class="' . $tooltipcss . ' tipRight inputbox' . $class . '" ' . $style . $readonly . ' />';
     $html .= '<span id="errfield' . $field->id . 'msg" style="display:none;">&nbsp;</span>';
     return $html;
 }
Exemple #16
0
 public function getFieldHTML($field, $required)
 {
     $params = new CParameter($field->params);
     $readonly = $params->get('readonly') ? ' readonly=""' : '';
     $style = $this->getStyle() ? '' : ' style="' . $this->getStyle() . '" ';
     $config = CFactory::getConfig();
     $js = 'assets/validate-1.5';
     $js .= $config->getBool('usepackedjavascript') ? '.pack.js' : '.js';
     CAssets::attach($js, 'js');
     // If maximum is not set, we define it to a default
     $field->max = empty($field->max) ? 200 : $field->max;
     $class = $field->required == 1 ? ' required' : '';
     $class .= !empty($field->tips) ? ' jomNameTips tipRight' : '';
     CFactory::load('helpers', 'string');
     $html = '<textarea id="field' . $field->id . '" name="field' . $field->id . '" class="inputbox textarea' . $class . '" title="' . CStringHelper::escape(JText::_($field->tips)) . '"' . $style . $readonly . '>' . $field->value . '</textarea>';
     $html .= '<span id="errfield' . $field->id . 'msg" style="display:none;">&nbsp;</span>';
     $html .= '<script type="text/javascript">cvalidate.setMaxLength("#field' . $field->id . '", "' . $field->max . '");</script>';
     return $html;
 }
Exemple #17
0
 public static function getActivityContentHTML($act)
 {
     // Ok, the activity could be an upload OR a wall comment. In the future, the content should
     // indicate which is which
     $html = '';
     $param = new CParameter($act->params);
     $action = $param->get('action', false);
     if ($action == 'events.create') {
         return CEvents::getEventSummary($act->cid, $param);
     } else {
         if ($action == 'event.join' || $action == 'event.attendence.attend') {
             return CEvents::getEventSummary($act->cid, $param);
         } else {
             if ($action == 'event.wall.create' || $action == 'events.wall.create') {
                 $wallid = $param->get('wallid', 0);
                 $html = CWallLibrary::getWallContentSummary($wallid);
                 return $html;
             }
         }
     }
     return $html;
 }
Exemple #18
0
 /**
  * To remove url fetching
  * @param $msgId
  */
 public function ajaxRemovePreview($msgId)
 {
     $filter = JFilterInput::getInstance();
     $msgId = $filter->clean($msgId, 'int');
     $my = CFactory::getUser();
     $messageTable = $photo = JTable::getInstance('Message', 'CTable');
     $messageTable->load($msgId);
     $params = new CParameter($messageTable->body);
     //if there is a fetched content
     if ($params->get('url')) {
         $newParam = new CParameter();
         $newParam->set('content', $params->get('content'));
         $messageTable->body = $newParam->toString();
         $messageTable->store();
         $params = $newParam;
     }
     $deleteLink = CRoute::_('index.php?option=com_community&view=inbox&task=remove&msgid=' . $messageTable->id);
     $authorLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $messageTable->from);
     // Escape content
     $content = $originalContent = $params->get('content');
     $content = CTemplate::escape($content);
     $content = CStringHelper::autoLink($content);
     $content = nl2br($content);
     $content = CStringHelper::getEmoticon($content);
     $content = CStringHelper::converttagtolink($content);
     //get thumbnail if available
     $photoThumbnail = '';
     if ($params->get('attached_photo_id')) {
         $photo = JTable::getInstance('Photo', 'CTable');
         $photo->load($params->get('attached_photo_id'));
         $photoThumbnail = $photo->getThumbURI();
     }
     $tmpl = new CTemplate();
     $tmpl->set('user', CFactory::getUser($messageTable->from));
     $tmpl->set('msg', $messageTable);
     $tmpl->set('originalContent', $originalContent);
     $tmpl->set('content', $content);
     $tmpl->set('params', $params);
     $tmpl->set('removeLink', $deleteLink);
     $tmpl->set('authorLink', $authorLink);
     $tmpl->set('photoThumbnail', $photoThumbnail);
     $html = $tmpl->fetch('inbox.message');
     $json = array();
     $json['success'] = true;
     $json['html'] = $html;
     die(json_encode($json));
 }
Exemple #19
0
 /**
  * Load List of album
  * @param  [String] $type  [Profile/Group/Event]
  * @param  [Int] $parentId [Profile/Group/Event Id]
  * @return [JSON Object]          [description]
  */
 public function ajaxChangeCover($type, $parentId)
 {
     $my = CFactory::getUser();
     $photoModel = CFactory::getModel('photos');
     $type = ucfirst($type);
     $albums = $photoModel->getUserAllAlbums($my->id);
     foreach ($albums as $key => $album) {
         $params = new CParameter($album->params);
         $albums[$key]->total_photo = $params->get('count');
     }
     $tmpl = new CTemplate();
     $html = $tmpl->set('albums', $albums)->set('type', $type)->set('parentId', $parentId)->fetch('photos.cover.add');
     $json = array('title' => JText::_('COM_COMMUNITY_' . strtoupper($type) . '_COVER_CHANGE'), 'html' => $html);
     die(json_encode($json));
 }
Exemple #20
0
 public function ajaxSaveStatus($actId, $value)
 {
     $my = CFactory::getUser();
     $json = array();
     if ($my->id == 0) {
         $this->ajaxBlockUnregister();
     }
     $filter = JFilterInput::getInstance();
     $actId = $filter->clean($actId, 'int');
     $value = trim($value);
     $activity = JTable::getInstance('Activity', 'CTable');
     $activity->load($actId);
     if (empty($value)) {
         $json['error'] = JText::_('COM_COMMUNITY_CANNOT_EDIT_POST_ERROR');
         die(json_encode($json));
     } else {
         //before storing, check if there is any hashtag, if yes, remove the hash tag before adding a new one
         $hashtags = CContentHelper::getHashTags($value);
         // check current title or message has any hashtag
         $oldHashtags = CContentHelper::getHashTags($activity->title);
         //old hashtag from the prebious message or title if there is any
         $removeTags = array_diff($oldHashtags, $hashtags);
         // this are the tags need to be removed
         $addTags = array_diff($hashtags, $oldHashtags);
         // tags that need to be added
         // remove tags if there's any
         if (count($removeTags)) {
             $hashtagModel = CFactory::getModel('hashtags');
             foreach ($removeTags as $tag) {
                 $hashtagModel->removeActivityHashtag($tag, $activity->id);
             }
         }
         // add new tags if there's any
         if (count($addTags)) {
             $hashtagModel = CFactory::getModel('hashtags');
             foreach ($addTags as $tag) {
                 $hashtagModel->addActivityHashtag($tag, $activity->id);
             }
         }
         $activity->title = $value;
         $activity->store();
         $status = $this->getModel('status');
         $status->update($my->id, $value, $activity->access);
         $today = JFactory::getDate();
         $my->set('_status', $value);
         $my->set('_posted_on', $today->toSql());
     }
     $params = new CParameter($activity->params);
     $mood = $params->get('mood', null);
     $value = CActivities::format($activity->title, $mood);
     $json['success'] = true;
     $json['data'] = $value;
     $json['unparsed'] = $activity->title;
     die(json_encode($json));
 }
Exemple #21
0
 public static function _getWallHTML($wall, $wallComments, $appType, $isOwner, $processFunc, $templateFile, $banned = 0)
 {
     $my = CFactory::getUser();
     $user = CFactory::getUser($wall->post_by);
     $date = CTimeHelper::getDate($wall->date);
     $config = CFactory::getConfig();
     // @rule: for site super administrators we want to allow them to view the remove link
     $isOwner = COwnerHelper::isCommunityAdmin() ? true : $isOwner;
     $isEditable = CWall::isEditable($processFunc, $wall->id);
     $commentsHTML = '';
     $comment = new CComment();
     /*
      * @todo 3.3 revise what is this code about
      */
     // If the wall post is a user wall post (in profile pages), we
     // add wall comment feature
     if ($appType == 'user' || $appType == 'groups' || $appType == 'events') {
         if ($banned == 1) {
             $commentsHTML = $comment->getHTML($wallComments, 'wall-cmt-' . $wall->id, false);
         } else {
             $commentsHTML = $comment->getHTML($wallComments, 'wall-cmt-' . $wall->id, CWall::canComment($wall->type, $wall->contentid));
         }
     }
     $avatarHTML = CUserHelper::getThumb($wall->post_by, 'avatar');
     // Change '->created to lapse format if stream uses lapse format'
     if ($config->get('activitydateformat') == 'lapse') {
         $wall->created = CTimeHelper::timeLapse($date);
     } else {
         $wall->created = $date->Format(JText::_('DATE_FORMAT_LC2'), true);
     }
     $wallParam = new CParameter($wall->params);
     $photoThumbnail = '';
     $paramsHTML = '';
     $image = (array) $wallParam->get('image');
     if ($wallParam->get('attached_photo_id') > 0) {
         $photo = JTable::getInstance('Photo', 'CTable');
         $photo->load($wallParam->get('attached_photo_id'));
         $photoThumbnail = $photo->getThumbURI();
     } else {
         if ($wallParam->get('title')) {
             $video = self::detectVideo($wallParam->get('url'));
             if (is_object($video)) {
                 $paramsHTML .= '<div class="joms-media--video joms-js--video"';
                 $paramsHTML .= ' data-type="' . $video->type . '"';
                 $paramsHTML .= ' data-id="' . $video->id . '"';
                 $paramsHTML .= ' data-path="' . ($video->type === 'file' ? JURI::root(true) . '/' : '') . $video->path . '"';
                 $paramsHTML .= ' style="margin-top:10px;">';
                 $paramsHTML .= '<div class="joms-media__thumbnail">';
                 $paramsHTML .= '<img src="' . $video->getThumbnail() . '">';
                 $paramsHTML .= '<a href="javascript:" class="mejs-overlay mejs-layer mejs-overlay-play joms-js--video-play joms-js--video-play-' . $wall->id . '">';
                 $paramsHTML .= '<div class="mejs-overlay-button"></div>';
                 $paramsHTML .= '</a>';
                 $paramsHTML .= '</div>';
                 $paramsHTML .= '<div class="joms-media__body">';
                 $paramsHTML .= '<h4 class="joms-media__title">' . JHTML::_('string.truncate', $video->title, 50, true, false) . '</h4>';
                 $paramsHTML .= '<p class="joms-media__desc">' . JHTML::_('string.truncate', $video->description, $config->getInt('streamcontentlength'), true, false) . '</p>';
                 $paramsHTML .= '</div>';
                 $paramsHTML .= '</div>';
             } else {
                 $paramsHTML .= '<div class="joms-gap"></div>';
                 $paramsHTML .= '<div class="joms-media--album joms-js--comment-preview">';
                 if ($isOwner) {
                     $paramsHTML .= '<span data-action="remove-preview" class="joms-fetched-close" style="top:0;right:0;left:auto" onclick="joms.api.commentRemovePreview(\'' . $wall->id . '\');"><i class="joms-icon-remove"></i></span>';
                 }
                 if ($wallParam->get('image')) {
                     $paramsHTML .= '<div class="joms-media__thumbnail">';
                     $paramsHTML .= '<a href="' . $wallParam->get('link') ? $wallParam->get('link') : '#' . '">';
                     $paramsHTML .= '<img src="' . array_shift($image) . '" />';
                     $paramsHTML .= '</a>';
                     $paramsHTML .= '</div>';
                 }
                 $url = $wallParam->get('url') ? $wallParam->get('url') : '#';
                 $paramsHTML .= '<div class="joms-media__body">';
                 $paramsHTML .= '<h4 class="joms-media__title"><a href="' . $url . '">' . $wallParam->get('title') . '</a></h4>';
                 $paramsHTML .= '<p class="joms-media__desc">' . CStringHelper::trim_words($wallParam->get('description')) . '</p>';
                 if ($wallParam->get('link')) {
                     $paramsHTML .= '<cite>' . preg_replace('#^https?://#', '', $wallParam->get('link')) . '</cite>';
                 }
                 $paramsHTML .= '</div></div>';
             }
         }
     }
     $CComment = new CComment();
     $wall->originalComment = $wall->comment;
     $wall->comment = $CComment->stripCommentData($wall->comment);
     $CTemplate = new CTemplate();
     $wall->comment = CStringHelper::autoLink($wall->comment);
     $wall->comment = nl2br($wall->comment);
     $wall->comment = CUserHelper::replaceAliasURL($wall->comment);
     $wall->comment = CStringHelper::getEmoticon($wall->comment);
     $wall->comment = CStringHelper::converttagtolink($wall->comment);
     // convert to hashtag
     $canDelete = $my->authorise('community.delete', 'walls', $wall);
     $like = new CLike();
     $likeCount = $like->getLikeCount('comment', $wall->id);
     $isLiked = $like->userLiked('comment', $wall->id, $my->id) == COMMUNITY_LIKE;
     // Create new instance of the template
     $tmpl = new CTemplate();
     return $tmpl->set('id', $wall->id)->set('author', $user->getDisplayName())->set('avatarHTML', $avatarHTML)->set('authorLink', CUrlHelper::userLink($user->id))->set('created', $wall->created)->set('content', $wall->comment)->set('commentsHTML', $commentsHTML)->set('avatar', $user->getThumbAvatar())->set('isMine', $isOwner)->set('canDelete', $canDelete)->set('isEditable', $isEditable)->set('processFunc', $processFunc)->set('config', $config)->set('photoThumbnail', $photoThumbnail)->set('paramsHTML', $paramsHTML)->set('wall', $wall)->set('likeCount', $likeCount)->set('isLiked', $isLiked)->fetch($templateFile);
 }
 /**
  * Return list of core apps, as assigned by admin
  */
 public function getCoreApps()
 {
     $applications = array();
     $enableLimit = false;
     $availableApps = $this->getAvailableApps($enableLimit);
     for ($i = 0; $i < count($availableApps); $i++) {
         $application = $availableApps[$i];
         $params = $this->getPluginParams($this->getPluginId($application->name));
         $params = new CParameter($params);
         if ($params->get('coreapp')) {
             $obj = new stdClass();
             $obj->apps = $application->name;
             $applications[] = $obj;
         }
     }
     return $applications;
 }
Exemple #23
0
 public static function activitiesLikeAdd($userId, $assetId, $obj = NULL)
 {
     //some activity that cannot be liked
     $cannotLikeApp = array('photos.comment');
     if (isset($obj->app) && in_array($obj->app, $cannotLikeApp)) {
         return false;
     }
     // Guest can never leave a comment
     if ($userId == 0) {
         return false;
     }
     if (isset($obj->params)) {
         $params = new CParameter($obj->params);
         $likesPermission = $params->get('likesPermission', NULL);
         if ($likesPermission == false && !is_null($likesPermission)) {
             return false;
         }
     }
     return true;
 }
Exemple #24
0
 public function saveGroup()
 {
     $group = JTable::getInstance('Groups', 'CommunityTable');
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $id = $jinput->post->get('id', '', 'INT');
     if (empty($id)) {
         JError::raiseError('500', JText::_('COM_COMMUNITY_INVALID_ID'));
     }
     $postData = JRequest::get('post');
     $description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $postData['description'] = $description;
     if (!isset($postData['groupdiscussionfilesharing'])) {
         $postData['groupdiscussionfilesharing'] = 0;
     }
     if (!isset($postData['groupannouncementfilesharing'])) {
         $postData['groupannouncementfilesharing'] = 0;
     }
     $group->load($id);
     $groupParam = new CParameter($group->params);
     $group->bind($postData);
     foreach ($postData as $key => $data) {
         if (!is_null($groupParam->get($key, NULL))) {
             $groupParam->set($key, $data);
         }
     }
     $group->params = $groupParam->toString();
     $message = '';
     if ($group->store()) {
         $message = JText::_('COM_COMMUNITY_GROUP_SAVED');
     } else {
         $message = JText::_('COM_COMMUNITY_GROUP_SAVE_ERROR');
     }
     $mainframe = JFactory::getApplication();
     $mainframe->redirect('index.php?option=com_community&view=groups', $message, 'message');
 }
Exemple #25
0
 public function ajaxAddApp($name, $position)
 {
     // Check permissions
     $my =& JFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     $filter = JFilterInput::getInstance();
     $name = $filter->clean($name, 'string');
     $position = $filter->clean($position, 'string');
     // Add application
     $appModel = CFactory::getModel('apps');
     $appModel->addApp($my->id, $name, $position);
     // Activity stream
     $act = new stdClass();
     $act->cmd = 'application.add';
     $act->actor = $my->id;
     $act->target = 0;
     $act->title = JText::_('COM_COMMUNITY_ACTIVITIES_APPLICATIONS_ADDED');
     $act->content = '';
     $act->app = $name;
     $act->cid = $my->id;
     CFactory::load('libraries', 'activities');
     CActivityStream::add($act);
     // User points
     CFactory::load('libraries', 'userpoints');
     CUserPoints::assignPoint('application.add');
     // Get application
     $id = $appModel->getUserApplicationId($name, $my->id);
     $appInfo = $appModel->getAppInfo($name);
     $params = new CParameter($appModel->getPluginParams($id, null));
     $isCoreApp = $params->get('coreapp');
     $app->id = $id;
     $app->title = isset($appInfo->title) ? $appInfo->title : '';
     $app->description = isset($appInfo->description) ? $appInfo->description : '';
     $app->isCoreApp = $isCoreApp;
     $app->name = $name;
     if (JFile::exists(CPluginHelper::getPluginPath('community', $name) . DS . $name . DS . 'favicon.png')) {
         $app->favicon['16'] = rtrim(JURI::root(), '/') . CPluginHelper::getPluginURI('community', $name) . '/' . $name . '/favicon.png';
     } else {
         $app->favicon['16'] = rtrim(JURI::root(), '/') . '/components/com_community/assets/app_favicon.png';
     }
     $tmpl = new CTemplate();
     $tmpl->set('apps', array($app));
     $tmpl->set('itemType', 'edit');
     $html = $tmpl->fetch('application.item');
     $objResponse = new JAXResponse();
     $objResponse->addScriptCall('joms.apps.showSettingsWindow', $app->id, $app->name);
     $objResponse->addScriptCall('joms.editLayout.addAppToLayout', $position, $html);
     // $objResponse->addScriptCall('cWindowHide();');
     return $objResponse->sendResponse();
 }
Exemple #26
0
 public function ajaxeditComment($id, $value, $photoId = 0)
 {
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     $actModel = CFactory::getModel('activities');
     $objResponse = new JAXResponse();
     $json = array();
     if ($my->id == 0) {
         $this->blockUnregister();
     }
     $wall = JTable::getInstance('wall', 'CTable');
     $wall->load($id);
     $cid = isset($wall->contentid) ? $wall->contentid : null;
     $activity = $actModel->getActivity($cid);
     $ownPost = $my->id == $wall->post_by;
     $targetPost = $activity->target == $my->id;
     $allowEdit = COwnerHelper::isCommunityAdmin() || ($ownPost || $targetPost) && !empty($my->id);
     $value = trim($value);
     if (empty($value)) {
         $json['error'] = JText::_('COM_COMMUNITY_CANNOT_EDIT_COMMENT_ERROR');
     } else {
         if ($config->get('wallediting') && $allowEdit) {
             $params = new CParameter($wall->params);
             //if photo id is not 0, this wall is appended with a picture
             if ($photoId > 0 && $params->get('attached_photo_id') != $photoId) {
                 //lets check if the photo belongs to the uploader
                 $photo = JTable::getInstance('Photo', 'CTable');
                 $photo->load($photoId);
                 if ($photo->creator == $my->id && $photo->albumid == '-1') {
                     $params->set('attached_photo_id', $photoId);
                     //sets the status to ready so that it wont be deleted on cron run
                     $photo->status = 'ready';
                     $photo->store();
                 }
             } else {
                 if ($photoId == -1) {
                     //if there is nothing, remove the param if applicable
                     //delete from db and files
                     $photoModel = CFactory::getModel('photos');
                     $photoTable = $photoModel->getPhoto($params->get('attached_photo_id'));
                     $photoTable->delete();
                     $params->set('attached_photo_id', 0);
                 }
             }
             $wall->params = $params->toString();
             $wall->comment = $value;
             $wall->store();
             $CComment = new CComment();
             $value = $CComment->stripCommentData($value);
             // Need to perform basic formatting here
             // 1. support nl to br,
             // 2. auto-link text
             $CTemplate = new CTemplate();
             $value = $origValue = $CTemplate->escape($value);
             $value = CStringHelper::autoLink($value);
             $value = nl2br($value);
             $value = CUserHelper::replaceAliasURL($value);
             $value = CStringHelper::getEmoticon($value);
             $json['comment'] = $value;
             $json['originalComment'] = $origValue;
             // $objResponse->addScriptCall("joms.jQuery('div[data-commentid=" . $id . "] .cStream-Content span.comment').html", $value);
             // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] [data-type=stream-comment-editor] textarea").val', $origValue);
             // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] [data-type=stream-comment-editor] textarea").removeData', 'initialized');
             // if ($photoId == -1) {
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-thumb").parent().remove', '');
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-attachment").css("display", "none").attr("data-no_thumb", 1);');
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-thumbnail").html', '<img/>');
             // } else if ($photoId != 0) {
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-fetch-wrapper").remove', '');
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-thumb").parent().remove', '');
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] [data-type=stream-comment-content] .cStream-Meta").before', '<div style="padding: 5px 0"><img class="joms-stream-thumb" src="' . JUri::root(true) ."/". $photo->thumbnail . '" /></div>');
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-attachment").css("display", "block").removeAttr("data-no_thumb");');
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-thumbnail img").attr("src", "' . JUri::root(true) ."/". $photo->thumbnail . '").attr("data-photo_id", "0").data("photo_id", 0);');
             // }
         } else {
             $json['error'] = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_EDIT');
         }
     }
     if (!isset($json['error'])) {
         $json['success'] = true;
     }
     die(json_encode($json));
 }
Exemple #27
0
    $eventsModel = CFactory::getModel('Events');
    $totalEvents = $eventsModel->getTotalGroupEvents($group->id);
    $showEvents = $config->get('group_events') && $config->get('enableevents') && $params->get('eventpermission', 1) >= 1;
    $videoModel = CFactory::getModel('videos');
    $showVideo = $params->get('videopermission') != -1 && $config->get('enablevideos') && $config->get('groupvideos');
    if ($showVideo) {
        $videoModel->getGroupVideos($group->id, '', $params->get('grouprecentvideos', GROUP_VIDEO_RECENT_LIMIT));
        $totalVideos = $videoModel->total ? $videoModel->total : 0;
    }
    $showPhoto = $params->get('photopermission') != -1 && $config->get('enablephotos') && $config->get('groupphotos');
    $photosModel = CFactory::getModel('photos');
    $albums = $photosModel->getGroupAlbums($group->id, true, false, $params->get('grouprecentphotos', GROUP_PHOTO_RECENT_LIMIT));
    $totalPhotos = 0;
    foreach ($albums as $album) {
        $albumParams = new CParameter($album->params);
        $totalPhotos = $totalPhotos + $albumParams->get('count');
    }
    $bulletinModel = CFactory::getModel('bulletins');
    $bulletins = $bulletinModel->getBulletins($group->id);
    $totalBulletin = $bulletinModel->total;
    // Check if "Invite friends" and "Settings" buttons should be added or not.
    $canInvite = false;
    $canEdit = false;
    if ($isMember && !$isBanned || $isCommunityAdmin) {
        $canInvite = true;
        if ($isMine || $isAdmin || $isCommunityAdmin) {
            $canEdit = true;
        }
    }
}
?>
Exemple #28
0
 public function addLike($element, $itemId)
 {
     $my = CFactory::getUser();
     $like = JTable::getInstance('Like', 'CTable');
     $like->loadInfo($element, $itemId);
     $like->element = $element;
     $like->uid = $itemId;
     // Check if user already like
     $likesInArray = explode(',', trim($like->like, ','));
     /* Like once time */
     if (in_array($my->id, $likesInArray)) {
         return;
     }
     array_push($likesInArray, $my->id);
     $likesInArray = array_unique($likesInArray);
     $like->like = ltrim(implode(',', $likesInArray), ',');
     // Check if the user already dislike
     $dislikesInArray = explode(',', trim($like->dislike, ','));
     if (in_array($my->id, $dislikesInArray)) {
         // Remove user dislike from array
         $key = array_search($my->id, $dislikesInArray);
         unset($dislikesInArray[$key]);
         $like->dislike = implode(',', $dislikesInArray);
     }
     switch ($element) {
         case 'comment':
             //get the instance of the wall
             $wall = JTable::getInstance('Wall', 'CTable');
             $wall->load($itemId);
             if (!$wall->id) {
                 break;
             }
             if ($wall->type == "profile.status") {
                 $wall->type = "profile";
             }
             //load the stream id from activity stream
             $stream = JTable::getInstance('Activity', 'CTable');
             $stream->load(array('comment_id' => $wall->contentid, 'app' => $wall->type));
             if ($stream->id) {
                 $profile = CFactory::getUser($stream->actor);
                 $url = 'index.php?option=com_community&view=profile&userid=' . $profile->id . '&actid=' . $stream->id . '#activity-stream-container';
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('comment', JText::_('COM_COMMUNITY_SINGULAR_COMMENT'));
                 $params->set('comment_url', $url);
                 $params->set('actor', $my->getDisplayName());
                 //add to notifications
                 CNotificationLibrary::add('comments_like', $my->id, $wall->post_by, JText::sprintf('COM_COMMUNITY_PROFILE_WALL_LIKE_EMAIL_SUBJECT'), '', 'comments.like', $params);
             }
             break;
         case 'photo':
             $photo = JTable::getInstance('Photo', 'CTable');
             $photo->load($itemId);
             if ($photo->id) {
                 $url = $photo->getRawPhotoURI();
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('photo', JText::_('COM_COMMUNITY_SINGULAR_PHOTO'));
                 $params->set('photo_url', $url);
                 CNotificationLibrary::add('photos_like', $my->id, $photo->creator, JText::sprintf('COM_COMMUNITY_PHOTO_LIKE_EMAIL_SUBJECT'), '', 'photos.like', $params);
                 /* Adding user points */
                 CUserPoints::assignPoint('photos.like');
             }
             break;
         case 'album':
             $album = JTable::getInstance('Album', 'CTable');
             $album->load($itemId);
             if ($album->id) {
                 if ($album->groupid) {
                     $url = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&groupid=' . $album->groupid;
                 } else {
                     $url = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id;
                 }
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('album', $album->name);
                 $params->set('album_url', $url);
                 CNotificationLibrary::add('photos_like', $my->id, $album->creator, JText::sprintf('COM_COMMUNITY_ALBUM_LIKE_EMAIL_SUBJECT'), '', 'album.like', $params);
                 /* Adding user points */
                 CUserPoints::assignPoint('album.like');
             }
             break;
         case 'videos':
             $video = JTable::getInstance('Video', 'CTable');
             $video->load($itemId);
             if ($video->id) {
                 if ($video->groupid) {
                     $url = 'index.php?option=com_community&view=videos&task=video&groupid=' . $video->groupid . '&videoid=' . $video->id;
                 } else {
                     $url = 'index.php?option=com_community&view=videos&task=video&videoid=' . $video->id;
                 }
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('video', $video->title);
                 $params->set('video_url', $url);
                 CNotificationLibrary::add('videos_like', $my->id, $video->creator, JText::sprintf('COM_COMMUNITY_VIDEO_LIKE_EMAIL_SUBJECT'), '', 'videos.like', $params);
                 /* Adding user points */
                 CUserPoints::assignPoint('videos.like');
             }
             break;
         case 'profile':
             $profile = CFactory::getUser($itemId);
             if ($profile->id) {
                 $url = 'index.php?option=com_community&view=profile&userid=' . $profile->id;
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('profile', strtolower(JText::_('COM_COMMUNITY_NOTIFICATIONGROUP_PROFILE')));
                 $params->set('profile_url', $url);
                 CNotificationLibrary::add('profile_like', $my->id, $profile->id, JText::sprintf('COM_COMMUNITY_PROFILE_LIKE_EMAIL_SUBJECT'), '', 'profile.like', $params);
                 /* Adding user points */
                 CUserPoints::assignPoint('profile.like');
             }
             break;
         case 'profile.status':
             $stream = JTable::getInstance('Activity', 'CTable');
             $stream->load($itemId);
             if ($stream->id) {
                 $profile = CFactory::getUser($stream->actor);
                 $url = 'index.php?option=com_community&view=profile&userid=' . $profile->id . '&actid=' . $stream->id;
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                 $params->set('stream_url', $url);
                 CNotificationLibrary::add('profile_stream_like', $my->id, $profile->id, JText::sprintf('COM_COMMUNITY_PROFILE_STREAM_LIKE_EMAIL_SUBJECT'), '', 'profile.stream.like', $params);
                 /* Adding user points */
                 CUserPoints::assignPoint('profile.stream.like');
             }
             break;
         case 'cover.upload':
             $photo = JTable::getInstance('Photo', 'CTable');
             $photo->load(CPhotosHelper::getPhotoOfStream($itemId));
             if ($photo->id) {
                 $url = $photo->getRawPhotoURI();
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('photo', JText::_('COM_COMMUNITY_SINGULAR_PHOTO'));
                 $params->set('photo_url', $url);
                 CNotificationLibrary::add('photos_like', $my->id, $photo->creator, JText::sprintf('COM_COMMUNITY_COVER_LIKE_EMAIL_SUBJECT'), '', 'photos.like', $params);
                 /* Adding user points */
                 CUserPoints::assignPoint('photos.like');
             }
             break;
         case 'profile.avatar.upload':
             $stream = JTable::getInstance('Activity', 'CTable');
             $stream->load($itemId);
             if ($stream->id) {
                 $profile = CFactory::getUser($stream->actor);
                 $url = 'index.php?option=com_community&view=profile&userid=' . $profile->id . '&actid=' . $stream->id;
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                 $params->set('stream_url', $url);
                 CNotificationLibrary::add('profile_stream_like', $my->id, $profile->id, JText::sprintf('COM_COMMUNITY_PROFILE_AVATAR_LIKE_EMAIL_SUBJECT'), '', 'profile.stream.like', $params);
                 /* Adding user points */
                 CUserPoints::assignPoint('profile.stream.like');
             }
             break;
         case 'album.self.share':
             $stream = JTable::getInstance('Activity', 'CTable');
             $stream->load($itemId);
             $profile = CFactory::getUser($stream->actor);
             //get total photo(s) uploaded and determine the string
             $actParam = new CParameter($stream->params);
             if ($actParam->get('batchcount') > 1) {
                 $content = JText::sprintf('COM_COMMUNITY_ACTIVITY_ALBUM_PICTURES_LIKE_SUBJECT');
             } else {
                 $content = JText::sprintf('COM_COMMUNITY_ACTIVITY_ALBUM_PICTURE_LIKE_SUBJECT');
             }
             $url = 'index.php?option=com_community&view=profile&userid=' . $profile->id . '&actid=' . $stream->id;
             $params = new CParameter('');
             $params->set('url', $url);
             $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
             $params->set('stream_url', $url);
             CNotificationLibrary::add('profile_stream_like', $my->id, $profile->id, $content, '', 'profile.stream.like', $params);
         default:
             CUserPoints::assignPoint($element . '.like');
     }
     // Log user engagement
     CEngagement::log($element . '.like', $my->id);
     $like->store();
 }
Exemple #29
0
 public function _getAllAlbumsHTML($albums, $type = PHOTOS_USER_TYPE, $pagination = NULL, $isMyOwnPhoto = false)
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $task = $jinput->getCmd('task');
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $groupId = JRequest::getInt('groupid', '', 'REQUEST');
     $handler = $this->_getHandler();
     $tmpl = new CTemplate();
     // Use for redirect after editAlbum
     $displaygrp = $groupId == 0 ? 'display' : 'displaygrp';
     $photoModel = CFactory::getModel('Photos');
     for ($i = 0; $i < count($albums); $i++) {
         $albums[$i]->count = count($photoModel->getPhotos($albums[$i]->id, 1000, 0));
         //change the album name according to the latest name of profile, event or groups avatars
         // act as trigger, have to move this somewhere later. //change album name
         switch ($albums[$i]->type) {
             case 'group.avatar':
                 $table = JTable::getInstance('Group', 'CTable');
                 $table->load($albums[$i]->groupid);
                 $tmpName = JText::sprintf('COM_COMMUNITY_GROUP_AVATAR_NAME', ucfirst($table->name));
                 if ($albums[$i]->name != $tmpName) {
                     $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                     $albums[$i]->name = $tmpName;
                 }
                 break;
             case 'event.avatar':
                 $table = JTable::getInstance('Event', 'CTable');
                 $table->load($albums[$i]->eventid);
                 $tmpName = JText::sprintf('COM_COMMUNITY_EVENT_AVATAR_NAME', ucfirst($table->title));
                 if ($albums[$i]->name != $tmpName) {
                     $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                     $albums[$i]->name = $tmpName;
                 }
                 break;
             case 'profile.avatar':
                 $creator = CFactory::getUser($albums[$i]->creator);
                 $tmpName = JText::sprintf('COM_COMMUNITY_PROFILE_AVATAR_NAME', ucfirst($creator->getDisplayName()));
                 if ($albums[$i]->name != $tmpName) {
                     $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                     $albums[$i]->name = $tmpName;
                 }
                 break;
             case 'user':
                 //default album only
                 if ($albums[$i]->default == 1) {
                     $creator = CFactory::getUser($albums[$i]->creator);
                     $tmpName = JText::sprintf('COM_COMMUNITY_DEFAULT_ALBUM_CAPTION', ucfirst($creator->getDisplayName()));
                     if ($albums[$i]->name != $tmpName) {
                         $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                         $albums[$i]->name = $tmpName;
                     }
                 }
                 break;
             case 'profile.Cover':
                 $creator = CFactory::getUser($albums[$i]->creator);
                 $tmpName = JText::sprintf('COM_COMMUNITY_PROFILE_COVER_NAME', ucfirst($creator->getDisplayName()));
                 if ($albums[$i]->name != $tmpName) {
                     $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                     $albums[$i]->name = $tmpName;
                 }
                 break;
             case 'event.Cover':
                 $table = JTable::getInstance('Event', 'CTable');
                 $table->load($albums[$i]->eventid);
                 $tmpName = JText::sprintf('COM_COMMUNITY_EVENT_COVER_NAME', ucfirst($table->title));
                 if ($albums[$i]->name != $tmpName) {
                     $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                     $albums[$i]->name = $tmpName;
                 }
                 break;
             case 'group.Cover':
                 $table = JTable::getInstance('Group', 'CTable');
                 $table->load($albums[$i]->groupid);
                 $tmpName = JText::sprintf('COM_COMMUNITY_GROUP_COVER_NAME', ucfirst($table->name));
                 if ($albums[$i]->name != $tmpName) {
                     $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                     $albums[$i]->name = $tmpName;
                 }
                 break;
             case 'group':
                 //group default photo
                 if ($albums[$i]->default == 1) {
                     $table = JTable::getInstance('Group', 'CTable');
                     $table->load($albums[$i]->groupid);
                     $tmpName = JText::sprintf('COM_COMMUNITY_GROUP_DEFAULT_ALBUM_NAME', ucfirst($table->name));
                     if ($albums[$i]->name != $tmpName) {
                         $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                         $albums[$i]->name = $tmpName;
                     }
                 }
         }
         $albums[$i]->user = CFactory::getUser($albums[$i]->creator);
         $albums[$i]->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$albums[$i]->id}");
         $albums[$i]->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$albums[$i]->id}&userid={$albums[$i]->creator}&referrer=myphotos");
         $albums[$i]->uploadLink = "javascript:joms.notifications.showUploadPhoto({$albums[$i]->id});";
         //CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$albums[$i]->id}&userid={$albums[$i]->creator}");
         $albums[$i]->isOwner = $my->id == $albums[$i]->creator;
         $albums[$i]->totalComments = CWallLibrary::getWallCount('albums', $albums[$i]->id);
         //$albums[$i]->totalPhotos = $photosModel->getTotalPhotos($albums[$i]->id);
         if ($type == PHOTOS_GROUP_TYPE) {
             $albums[$i]->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$albums[$i]->id}&groupid={$albums[$i]->groupid}");
             $albums[$i]->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$albums[$i]->id}&groupid={$albums[$i]->groupid}&referrer={$displaygrp}");
             $albums[$i]->uploadLink = "javascript:joms.notifications.showUploadPhoto({$albums[$i]->id},{$albums[$i]->groupid});";
             //CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$albums[$i]->id}&groupid={$albums[$i]->groupid}");
             $albums[$i]->isOwner = $my->authorise('community.view', 'photos.group.album.' . $groupId, $albums[$i]);
         }
         // If new albums that has just been created and
         // does not contain any images, the lastupdated will always be 0000-00-00 00:00:00:00
         // Try to use the albums creation date instead.
         if ($albums[$i]->lastupdated == '0000-00-00 00:00:00' || $albums[$i]->lastupdated == '') {
             $albums[$i]->lastupdated = $albums[$i]->created;
             if ($albums[$i]->lastupdated == '' || $albums[$i]->lastupdated == '0000-00-00 00:00:00') {
                 $albums[$i]->lastupdated = JText::_('COM_COMMUNITY_PHOTOS_NO_ACTIVITY');
             } else {
                 $lastUpdated = new JDate($albums[$i]->lastupdated);
                 $albums[$i]->lastupdated = CActivityStream::_createdLapse($lastUpdated, false);
             }
         } else {
             $params = new CParameter($albums[$i]->params);
             $lastUpdated = new JDate($params->get('lastupdated'));
             $albums[$i]->lastupdated = CActivityStream::_createdLapse($lastUpdated, false);
         }
     }
     $featured = new CFeatured(FEATURED_ALBUMS);
     $featuredList = $featured->getItemIds();
     $createLink = $handler->getAlbumCreateLink();
     if ($type == PHOTOS_GROUP_TYPE) {
         $isOwner = CGroupHelper::allowManagePhoto($groupId);
         $baselink = "index.php?option=com_community&view=photos&task=display&groupid=" . $groupId;
         $groupModel = CFactory::getModel('groups');
         $group = JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         $params = $group->getParams();
         $photopermission = $params->get('photopermission') == GROUP_PHOTO_PERMISSION_ADMINS || $params->get('photopermission') == GROUP_PHOTO_PERMISSION_ALL ? 1 : 0;
         $isMember = $groupModel->isMember($my->id, $group->id);
         $isAdmin = $groupModel->isAdmin($my->id, $group->id);
         $tmpl->set('photoPermission', $photopermission)->set('isMember', $isMember)->set('isAdmin', $isAdmin);
     } else {
         $userId = JRequest::getInt('userid', '', 'REQUEST');
         $user = CFactory::getUser($userId);
         if ($task) {
             $baselink = "index.php?option=com_community&view=photos&task=" . $task;
         } else {
             $baselink = "index.php?option=com_community&view=photos";
         }
         $isOwner = $my->id == $userId ? true : false;
     }
     $sortBy = JRequest::getString('sort', 'date');
     $task = JRequest::getCmd('task', '');
     return $tmpl->set('isMember', $my->id != 0)->set('isMyOwnPhoto', $isMyOwnPhoto)->set('sortBy', $sortBy)->set('baseLink', $baselink)->set('config', $config)->set('isOwner', $isOwner)->set('type', $type)->set('createLink', $createLink)->set('currentTask', $task)->set('showFeatured', $config->get('show_featured'))->set('featuredList', $featuredList)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('my', $my)->set('albums', $albums)->set('pagination', $pagination)->set('isSuperAdmin', COwnerHelper::isCommunityAdmin())->set('groupId', $groupId)->set('submenu', $this->showSubmenu(false))->fetch('album/list');
 }
Exemple #30
0
        echo CRoute::_('index.php?option=com_community&view=profile&userid=' . $video->creator);
        ?>
"><?php 
        echo $video->getCreatorName();
        ?>
</a>
                    <?php 
        if ($video->groupid) {
            $group = JTable::getInstance('Group', 'CTable');
            $group->load($video->groupid);
            echo JText::sprintf('COM_COMMUNITY_VIDEOS_FROM_GROUP', '<a href="' . CUrlHelper::groupLink($group->id) . '">' . $group->name . '</a>');
        } elseif ($video->eventid) {
            $event = JTable::getInstance('Event', 'CTable');
            $event->load($video->eventid);
            echo JText::sprintf('COM_COMMUNITY_VIDEOS_FROM_EVENT', '<a href="' . CUrlHelper::eventLink($event->id) . '">' . $event->title . '</a>');
        } elseif ($params->get('activity_id')) {
            $targetUser = CFactory::getUser($params->get('target_id'));
            ?>
                        ▶ <?php 
            echo CLinkGeneratorHelper::getUserURL($targetUser->id, $targetUser->getDisplayName());
            ?>
 <a href="<?php 
            echo CUrlHelper::streamURI($params->get('activity_id'), $targetUser->id);
            ?>
"><?php 
            echo JText::_('COM_COMMUNITY_SINGULAR_STREAM');
            ?>
</a>
                    <?php 
        }
        ?>